From 9df18bb5444d1e3e6416f82d5fcf49b54b0c39d6 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 15 Aug 2008 07:28:28 +0000 Subject: [PATCH] From: Richard Alimi The following patch implements retrieving prims in Xml2 format via the REST interface. For example: http://localhost:9000/admin/regions//prims/ It also allows an additional parameter which specifies a bounding box. If this parameter is specified, only prims within the bounding box are retrieved. For example: http://localhost:9000/admin/regions/8cd759b4-e077-489d-9a34-e1ff70ef65dd/prims/0,0,0,128,128,128 will retrieve only the prims whose positions are in the bounding box with corners (0,0,0) and (128,128,128). --- .../Rest/Regions/GETHandler.cs | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs index a605d09e64..e5ec94b71f 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs @@ -149,9 +149,38 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions return RegionStats(httpResponse, scene); case "prims": - return RegionPrims(httpResponse, scene); + return RegionPrims(httpResponse, scene, LLVector3.Zero, LLVector3.Zero); } } + + if (3 == comps.Length) { + switch (comps[1].ToLower()) + { + case "prims": + string[] subregion = comps[2].Split(','); + if (subregion.Length == 6) + { + LLVector3 min, max; + try + { + min = new LLVector3((float)Double.Parse(subregion[0]), (float)Double.Parse(subregion[1]), (float)Double.Parse(subregion[2])); + max = new LLVector3((float)Double.Parse(subregion[3]), (float)Double.Parse(subregion[4]), (float)Double.Parse(subregion[5])); + } + catch (Exception e) + { + return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest, + "GET", "invalid subregion parameter"); + } + return RegionPrims(httpResponse, scene, min, max); + } + else + { + return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest, + "GET", "invalid subregion parameter"); + } + } + } + return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest, "GET", "too many parameters {0}", param); } @@ -184,10 +213,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions return XmlWriterResult; } - protected string RegionPrims(OSHttpResponse httpResponse, Scene scene) + protected string RegionPrims(OSHttpResponse httpResponse, Scene scene, LLVector3 min, LLVector3 max) { - return Failure(httpResponse, OSHttpStatusCode.ServerErrorNotImplemented, - "GET", "prims not implemented"); + httpResponse.SendChunked = true; + httpResponse.ContentType = "text/xml"; + scene.SavePrimsToXml2(new StreamWriter(httpResponse.OutputStream), min, max); + return ""; } } }