aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/SimianGrid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs133
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs18
2 files changed, 70 insertions, 81 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
index b999509..8375c95 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
@@ -181,7 +181,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
181 m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName); 181 m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName);
182 182
183 // Create a PNG map tile and upload it to the AddMapTile API 183 // Create a PNG map tile and upload it to the AddMapTile API
184 byte[] pngData = Utils.EmptyBytes;
185 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); 184 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
186 if (tileGenerator == null) 185 if (tileGenerator == null)
187 { 186 {
@@ -189,93 +188,79 @@ namespace OpenSim.Services.Connectors.SimianGrid
189 return; 188 return;
190 } 189 }
191 190
192 using (Image mapTile = tileGenerator.CreateMapTile()) 191 using (Bitmap mapTile = tileGenerator.CreateMapTile())
193 { 192 {
194 using (MemoryStream stream = new MemoryStream()) 193 if (mapTile != null)
194 {
195 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
196 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
197 {
198 ConvertAndUploadMaptile(mapTile, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY);
199 }
200 else
201 {
202 // For larger regions (varregion) we must cut the region image into legacy sized
203 // pieces since that is how the maptile system works.
204 // Note the assumption that varregions are always a multiple of legacy size.
205 for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
206 {
207 for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
208 {
209 // Images are addressed from the upper left corner so have to do funny
210 // math to pick out the sub-tile since regions are numbered from
211 // the lower left.
212 Rectangle rect = new Rectangle(
213 (int)xx,
214 mapTile.Height - (int)yy - (int)Constants.RegionSize,
215 (int)Constants.RegionSize, (int)Constants.RegionSize);
216
217 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
218 {
219 uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize);
220 uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize);
221
222 ConvertAndUploadMaptile(subMapTile, locX, locY);
223 }
224 }
225 }
226 }
227 }
228 else
195 { 229 {
196 mapTile.Save(stream, ImageFormat.Png); 230 m_log.WarnFormat("[SIMIAN MAPTILE] Tile image generation failed");
197 pngData = stream.ToArray();
198 } 231 }
199 } 232 }
200 233
234 }
235
236 ///<summary>
237 ///
238 ///</summary>
239 private void ConvertAndUploadMaptile(Image mapTile, uint locX, uint locY)
240 {
241 //m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for location {0}, {1}", locX, locY);
242
243 byte[] pngData = Utils.EmptyBytes;
244 using (MemoryStream stream = new MemoryStream())
245 {
246 mapTile.Save(stream, ImageFormat.Png);
247 pngData = stream.ToArray();
248 }
249
201 NameValueCollection requestArgs = new NameValueCollection 250 NameValueCollection requestArgs = new NameValueCollection
202 { 251 {
203 { "RequestMethod", "xAddMapTile" }, 252 { "RequestMethod", "xAddMapTile" },
204 { "X", scene.RegionInfo.RegionLocX.ToString() }, 253 { "X", locX.ToString() },
205 { "Y", scene.RegionInfo.RegionLocY.ToString() }, 254 { "Y", locY.ToString() },
206 { "ContentType", "image/png" }, 255 { "ContentType", "image/png" },
207 { "EncodedData", System.Convert.ToBase64String(pngData) } 256 { "EncodedData", System.Convert.ToBase64String(pngData) }
208 }; 257 };
209 258
210 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); 259 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
211 if (! response["Success"].AsBoolean()) 260 if (! response["Success"].AsBoolean())
212 { 261 {
213 m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString()); 262 m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString());
214 return;
215 } 263 }
216
217 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
218 // {
219 // new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
220 // new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
221 // new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
222 // };
223
224 // string errorMessage = null;
225 // int tickstart = Util.EnvironmentTickCount();
226
227 // // Make the remote storage request
228 // try
229 // {
230 // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
231 // request.Timeout = 20000;
232 // request.ReadWriteTimeout = 5000;
233
234 // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
235 // {
236 // using (Stream responseStream = response.GetResponseStream())
237 // {
238 // string responseStr = responseStream.GetStreamString();
239 // OSD responseOSD = OSDParser.Deserialize(responseStr);
240 // if (responseOSD.Type == OSDType.Map)
241 // {
242 // OSDMap responseMap = (OSDMap)responseOSD;
243 // if (responseMap["Success"].AsBoolean())
244 // return;
245
246 // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
247 // }
248 // else
249 // {
250 // errorMessage = "Response format was invalid:\n" + responseStr;
251 // }
252 // }
253 // }
254 // }
255 // catch (WebException we)
256 // {
257 // errorMessage = we.Message;
258 // if (we.Status == WebExceptionStatus.ProtocolError)
259 // {
260 // HttpWebResponse webResponse = (HttpWebResponse)we.Response;
261 // errorMessage = String.Format("[{0}] {1}",
262 // webResponse.StatusCode,webResponse.StatusDescription);
263 // }
264 // }
265 // catch (Exception ex)
266 // {
267 // errorMessage = ex.Message;
268 // }
269 // finally
270 // {
271 // // This just dumps a warning for any operation that takes more than 100 ms
272 // int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
273 // m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
274 // }
275
276 // m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
277 // pngData.Length, scene.RegionInfo.RegionName, errorMessage);
278
279 } 264 }
280 } 265 }
281} \ No newline at end of file 266} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 816591b..6b59f94 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo) 101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
102 { 102 {
103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); 103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
104 Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); 104 Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
105 105
106 OSDMap extraData = new OSDMap 106 OSDMap extraData = new OSDMap
107 { 107 {
@@ -156,15 +156,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
156 156
157 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) 157 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 { 158 {
159 const int NEIGHBOR_RADIUS = 128;
160
161 GridRegion region = GetRegionByUUID(scopeID, regionID); 159 GridRegion region = GetRegionByUUID(scopeID, regionID);
162 160
161 int NEIGHBOR_RADIUS = Math.Max(region.RegionSizeX, region.RegionSizeY) / 2;
162
163 if (region != null) 163 if (region != null)
164 { 164 {
165 List<GridRegion> regions = GetRegionRange(scopeID, 165 List<GridRegion> regions = GetRegionRange(scopeID,
166 region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + (int)Constants.RegionSize + NEIGHBOR_RADIUS, 166 region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + region.RegionSizeX + NEIGHBOR_RADIUS,
167 region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + (int)Constants.RegionSize + NEIGHBOR_RADIUS); 167 region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + region.RegionSizeY + NEIGHBOR_RADIUS);
168 168
169 for (int i = 0; i < regions.Count; i++) 169 for (int i = 0; i < regions.Count; i++)
170 { 170 {
@@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
229 else 229 else
230 { 230 {
231 // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", 231 // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
232 // x / Constants.RegionSize, y / Constants.RegionSize); 232 // Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
233 return null; 233 return null;
234 } 234 }
235 } 235 }
@@ -443,9 +443,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
443 region.RegionName = response["Name"].AsString(); 443 region.RegionName = response["Name"].AsString();
444 444
445 Vector3d minPosition = response["MinPosition"].AsVector3d(); 445 Vector3d minPosition = response["MinPosition"].AsVector3d();
446 Vector3d maxPosition = response["MaxPosition"].AsVector3d();
446 region.RegionLocX = (int)minPosition.X; 447 region.RegionLocX = (int)minPosition.X;
447 region.RegionLocY = (int)minPosition.Y; 448 region.RegionLocY = (int)minPosition.Y;
448 449
450 region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X;
451 region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y;
452
449 if ( ! extraData["HyperGrid"] ) { 453 if ( ! extraData["HyperGrid"] ) {
450 Uri httpAddress = response["Address"].AsUri(); 454 Uri httpAddress = response["Address"].AsUri();
451 region.ExternalHostName = httpAddress.Host; 455 region.ExternalHostName = httpAddress.Host;