diff options
author | Robert Adams | 2014-01-19 05:09:03 -0800 |
---|---|---|
committer | Robert Adams | 2014-01-19 05:09:03 -0800 |
commit | 60de0bc3c29bcdfb3d1d27bcc696c0e31f202fc0 (patch) | |
tree | 23522c2bf1dac0e0f4ba651a58173e63ed8b2f3d /OpenSim/Region | |
parent | varregion: properly pack the region size parameters so he viewer will parse t... (diff) | |
download | opensim-SC_OLD-60de0bc3c29bcdfb3d1d27bcc696c0e31f202fc0.zip opensim-SC_OLD-60de0bc3c29bcdfb3d1d27bcc696c0e31f202fc0.tar.gz opensim-SC_OLD-60de0bc3c29bcdfb3d1d27bcc696c0e31f202fc0.tar.bz2 opensim-SC_OLD-60de0bc3c29bcdfb3d1d27bcc696c0e31f202fc0.tar.xz |
varregion: split up generated maptile images for storage in map. This
makes maps for varregions show up properly.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | 88 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 2 |
2 files changed, 68 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 26d22b8..e4a875d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
57 | { | 57 | { |
58 | private static readonly ILog m_log = | 58 | private static readonly ILog m_log = |
59 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
60 | private static string LogHeader = "[MAP IMAGE SERVICE MODULE]"; | ||
60 | 61 | ||
61 | private bool m_enabled = false; | 62 | private bool m_enabled = false; |
62 | private IMapImageService m_MapService; | 63 | private IMapImageService m_MapService; |
@@ -192,42 +193,87 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
192 | ///</summary> | 193 | ///</summary> |
193 | private void UploadMapTile(IScene scene) | 194 | private void UploadMapTile(IScene scene) |
194 | { | 195 | { |
195 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: upload maptile for {0}", scene.RegionInfo.RegionName); | 196 | m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.RegionInfo.RegionName); |
197 | string regionName = scene.RegionInfo.RegionName; | ||
196 | 198 | ||
197 | // Create a JPG map tile and upload it to the AddMapTile API | 199 | // Create a JPG map tile and upload it to the AddMapTile API |
198 | byte[] jpgData = Utils.EmptyBytes; | ||
199 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); | 200 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); |
200 | if (tileGenerator == null) | 201 | if (tileGenerator == null) |
201 | { | 202 | { |
202 | m_log.Warn("[MAP IMAGE SERVICE MODULE]: Cannot upload PNG map tile without an ImageGenerator"); | 203 | m_log.WarnFormat("{0} Cannot upload map tile without an ImageGenerator", LogHeader); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | 206 | using (Bitmap mapTile = tileGenerator.CreateMapTile()) | |
206 | using (Image mapTile = tileGenerator.CreateMapTile()) | ||
207 | { | 207 | { |
208 | // XXX: The MapImageModule will return a null if the user has chosen not to create map tiles and there | 208 | if (mapTile != null) |
209 | // is no static map tile. | 209 | { |
210 | if (mapTile == null) | 210 | mapTile.Save( // DEBUG DEBUG |
211 | return; | 211 | String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY), |
212 | 212 | ImageFormat.Jpeg); | |
213 | using (MemoryStream stream = new MemoryStream()) | 213 | // If the region/maptile is legacy sized, just upload the one tile like it has always been done |
214 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) | ||
215 | { | ||
216 | ConvertAndUploadMaptile(mapTile, | ||
217 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, | ||
218 | scene.RegionInfo.RegionName); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | // For larger regions (varregion) we must cut the region image into legacy sized | ||
223 | // pieces since that is how the maptile system works. | ||
224 | // Note the assumption that varregions are always a multiple of legacy size. | ||
225 | for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize) | ||
226 | { | ||
227 | for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize) | ||
228 | { | ||
229 | // Images are addressed from the upper left corner so have to do funny | ||
230 | // math to pick out the sub-tile since regions are numbered from | ||
231 | // the lower left. | ||
232 | Rectangle rect = new Rectangle( | ||
233 | (int)xx, | ||
234 | mapTile.Height - (int)yy - (int)Constants.RegionSize, | ||
235 | (int)Constants.RegionSize, (int)Constants.RegionSize); | ||
236 | using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) | ||
237 | { | ||
238 | m_log.DebugFormat("{0} ConvertAndUploadMaptile: {1}: rect={2}, xx,yy=<{3},{4}>", | ||
239 | LogHeader, regionName, rect, xx, yy); | ||
240 | ConvertAndUploadMaptile(subMapTile, | ||
241 | scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), | ||
242 | scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), | ||
243 | regionName); | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | else | ||
214 | { | 250 | { |
215 | mapTile.Save(stream, ImageFormat.Jpeg); | 251 | m_log.WarnFormat("{0} Tile image generation failed", LogHeader); |
216 | jpgData = stream.ToArray(); | ||
217 | } | 252 | } |
218 | } | 253 | } |
254 | } | ||
219 | 255 | ||
220 | if (jpgData == Utils.EmptyBytes) | 256 | private void ConvertAndUploadMaptile(Image tileImage, uint locX, uint locY, string regionName) |
257 | { | ||
258 | byte[] jpgData = Utils.EmptyBytes; | ||
259 | |||
260 | using (MemoryStream stream = new MemoryStream()) | ||
221 | { | 261 | { |
222 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Tile image generation failed"); | 262 | tileImage.Save(stream, ImageFormat.Jpeg); |
223 | return; | 263 | jpgData = stream.ToArray(); |
224 | } | 264 | } |
225 | 265 | if (jpgData != Utils.EmptyBytes) | |
226 | string reason = string.Empty; | 266 | { |
227 | if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason)) | 267 | string reason = string.Empty; |
268 | if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason)) | ||
269 | { | ||
270 | m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, | ||
271 | regionName, locX, locY, reason); | ||
272 | } | ||
273 | } | ||
274 | else | ||
228 | { | 275 | { |
229 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", | 276 | m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, regionName); |
230 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason); | ||
231 | } | 277 | } |
232 | } | 278 | } |
233 | } | 279 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 4badb12..e925f0d 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -406,7 +406,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
406 | } | 406 | } |
407 | uint xstart = 0; | 407 | uint xstart = 0; |
408 | uint ystart = 0; | 408 | uint ystart = 0; |
409 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); | 409 | Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); |
410 | if (itemtype == 6) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) | 410 | if (itemtype == 6) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) |
411 | { | 411 | { |
412 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) | 412 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) |