diff options
Diffstat (limited to 'OpenSim/Services/MapImageService/MapImageService.cs')
-rw-r--r-- | OpenSim/Services/MapImageService/MapImageService.cs | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs index e2f256f..9de5085 100644 --- a/OpenSim/Services/MapImageService/MapImageService.cs +++ b/OpenSim/Services/MapImageService/MapImageService.cs | |||
@@ -94,10 +94,10 @@ namespace OpenSim.Services.MapImageService | |||
94 | 94 | ||
95 | #region IMapImageService | 95 | #region IMapImageService |
96 | 96 | ||
97 | public bool AddMapTile(int x, int y, byte[] imageData, out string reason) | 97 | public bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason) |
98 | { | 98 | { |
99 | reason = string.Empty; | 99 | reason = string.Empty; |
100 | string fileName = GetFileName(1, x, y); | 100 | string fileName = GetFileName(1, x, y, scopeID); |
101 | 101 | ||
102 | lock (m_Sync) | 102 | lock (m_Sync) |
103 | { | 103 | { |
@@ -114,13 +114,13 @@ namespace OpenSim.Services.MapImageService | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | return UpdateMultiResolutionFiles(x, y, out reason); | 117 | return UpdateMultiResolutionFiles(x, y, scopeID, out reason); |
118 | } | 118 | } |
119 | 119 | ||
120 | public bool RemoveMapTile(int x, int y, out string reason) | 120 | public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) |
121 | { | 121 | { |
122 | reason = String.Empty; | 122 | reason = String.Empty; |
123 | string fileName = GetFileName(1, x, y); | 123 | string fileName = GetFileName(1, x, y, scopeID); |
124 | 124 | ||
125 | lock (m_Sync) | 125 | lock (m_Sync) |
126 | { | 126 | { |
@@ -136,10 +136,10 @@ namespace OpenSim.Services.MapImageService | |||
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | return UpdateMultiResolutionFiles(x, y, out reason); | 139 | return UpdateMultiResolutionFiles(x, y, scopeID, out reason); |
140 | } | 140 | } |
141 | 141 | ||
142 | private bool UpdateMultiResolutionFiles(int x, int y, out string reason) | 142 | private bool UpdateMultiResolutionFiles(int x, int y, UUID scopeID, out string reason) |
143 | { | 143 | { |
144 | reason = String.Empty; | 144 | reason = String.Empty; |
145 | lock (m_Sync) | 145 | lock (m_Sync) |
@@ -153,7 +153,7 @@ namespace OpenSim.Services.MapImageService | |||
153 | int x1 = x - (x % width); | 153 | int x1 = x - (x % width); |
154 | int y1 = y - (y % width); | 154 | int y1 = y - (y % width); |
155 | 155 | ||
156 | if (!CreateTile(zoomLevel, x1, y1)) | 156 | if (!CreateTile(zoomLevel, x1, y1, scopeID)) |
157 | { | 157 | { |
158 | m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel); | 158 | m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel); |
159 | reason = string.Format("Map tile at zoom level {0} failed", zoomLevel); | 159 | reason = string.Format("Map tile at zoom level {0} failed", zoomLevel); |
@@ -165,12 +165,13 @@ namespace OpenSim.Services.MapImageService | |||
165 | return true; | 165 | return true; |
166 | } | 166 | } |
167 | 167 | ||
168 | public byte[] GetMapTile(string fileName, out string format) | 168 | public byte[] GetMapTile(string fileName, UUID scopeID, out string format) |
169 | { | 169 | { |
170 | // m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName); | 170 | // m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName); |
171 | 171 | ||
172 | format = ".jpg"; | 172 | format = ".jpg"; |
173 | string fullName = Path.Combine(m_TilesStoragePath, fileName); | 173 | string fullName = Path.Combine(m_TilesStoragePath, scopeID.ToString()); |
174 | fullName = Path.Combine(fullName, fileName); | ||
174 | if (File.Exists(fullName)) | 175 | if (File.Exists(fullName)) |
175 | { | 176 | { |
176 | format = Path.GetExtension(fileName).ToLower(); | 177 | format = Path.GetExtension(fileName).ToLower(); |
@@ -191,10 +192,12 @@ namespace OpenSim.Services.MapImageService | |||
191 | #endregion | 192 | #endregion |
192 | 193 | ||
193 | 194 | ||
194 | private string GetFileName(uint zoomLevel, int x, int y) | 195 | private string GetFileName(uint zoomLevel, int x, int y, UUID scopeID) |
195 | { | 196 | { |
196 | string extension = "jpg"; | 197 | string extension = "jpg"; |
197 | return Path.Combine(m_TilesStoragePath, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); | 198 | string path = Path.Combine(m_TilesStoragePath, scopeID.ToString()); |
199 | Directory.CreateDirectory(path); | ||
200 | return Path.Combine(path, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); | ||
198 | } | 201 | } |
199 | 202 | ||
200 | private Bitmap GetInputTileImage(string fileName) | 203 | private Bitmap GetInputTileImage(string fileName) |
@@ -235,7 +238,7 @@ namespace OpenSim.Services.MapImageService | |||
235 | return null; | 238 | return null; |
236 | } | 239 | } |
237 | 240 | ||
238 | private bool CreateTile(uint zoomLevel, int x, int y) | 241 | private bool CreateTile(uint zoomLevel, int x, int y, UUID scopeID) |
239 | { | 242 | { |
240 | // m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel); | 243 | // m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel); |
241 | int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2); | 244 | int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2); |
@@ -250,13 +253,13 @@ namespace OpenSim.Services.MapImageService | |||
250 | int yOut = y - (y % thisWidth); | 253 | int yOut = y - (y % thisWidth); |
251 | 254 | ||
252 | // Try to open the four input tiles from the previous zoom level | 255 | // Try to open the four input tiles from the previous zoom level |
253 | Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn)); | 256 | Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn, scopeID)); |
254 | Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn)); | 257 | Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn, scopeID)); |
255 | Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth)); | 258 | Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth, scopeID)); |
256 | Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth)); | 259 | Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth, scopeID)); |
257 | 260 | ||
258 | // Open the output tile (current zoom level) | 261 | // Open the output tile (current zoom level) |
259 | string outputFile = GetFileName(zoomLevel, xOut, yOut); | 262 | string outputFile = GetFileName(zoomLevel, xOut, yOut, scopeID); |
260 | Bitmap output = GetOutputTileImage(outputFile); | 263 | Bitmap output = GetOutputTileImage(outputFile); |
261 | if (output == null) | 264 | if (output == null) |
262 | return false; | 265 | return false; |