diff options
author | Melanie Thielker | 2014-08-23 17:27:01 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-08-23 17:27:01 +0200 |
commit | cbd7c7b9ecbe7bbe19d5c675322206bc8a977c5f (patch) | |
tree | 16b07a06b057f3ee29a4581e1810dbc5b34ad7cb /OpenSim | |
parent | Merge branch 'ubitworkmaster' (diff) | |
download | opensim-SC-cbd7c7b9ecbe7bbe19d5c675322206bc8a977c5f.zip opensim-SC-cbd7c7b9ecbe7bbe19d5c675322206bc8a977c5f.tar.gz opensim-SC-cbd7c7b9ecbe7bbe19d5c675322206bc8a977c5f.tar.bz2 opensim-SC-cbd7c7b9ecbe7bbe19d5c675322206bc8a977c5f.tar.xz |
Change the map tile system to be multi-grid hosting compatible
Diffstat (limited to 'OpenSim')
7 files changed, 49 insertions, 28 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index b61062f..40bedc1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -227,7 +227,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
227 | } | 227 | } |
228 | 228 | ||
229 | string reason = string.Empty; | 229 | string reason = string.Empty; |
230 | if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason)) | 230 | if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, scene.RegionInfo.ScopeID, out reason)) |
231 | { | 231 | { |
232 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", | 232 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", |
233 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason); | 233 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason); |
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index d438fc7..7ee347c 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -117,8 +117,11 @@ namespace OpenSim.Server.Handlers.MapImage | |||
117 | return FailureResult("Bad request."); | 117 | return FailureResult("Bad request."); |
118 | } | 118 | } |
119 | int x = 0, y = 0; | 119 | int x = 0, y = 0; |
120 | UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992"); | ||
120 | Int32.TryParse(request["X"].ToString(), out x); | 121 | Int32.TryParse(request["X"].ToString(), out x); |
121 | Int32.TryParse(request["Y"].ToString(), out y); | 122 | Int32.TryParse(request["Y"].ToString(), out y); |
123 | if (request.ContainsKey("SCOPE")) | ||
124 | UUID.TryParse(request["SCOPE"].ToString(), out scopeID); | ||
122 | 125 | ||
123 | m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y); | 126 | m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y); |
124 | 127 | ||
@@ -151,7 +154,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
151 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); | 154 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); |
152 | 155 | ||
153 | string reason = string.Empty; | 156 | string reason = string.Empty; |
154 | bool result = m_MapService.AddMapTile(x, y, data, out reason); | 157 | bool result = m_MapService.AddMapTile(x, y, data, scopeID, out reason); |
155 | 158 | ||
156 | if (result) | 159 | if (result) |
157 | return SuccessResult(); | 160 | return SuccessResult(); |
diff --git a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs index bd1ddbd..e2c8f35 100644 --- a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs | |||
@@ -38,6 +38,7 @@ using OpenSim.Server.Base; | |||
38 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Server.Handlers.Base; | 40 | using OpenSim.Server.Handlers.Base; |
41 | using OpenMetaverse; | ||
41 | 42 | ||
42 | namespace OpenSim.Server.Handlers.MapImage | 43 | namespace OpenSim.Server.Handlers.MapImage |
43 | { | 44 | { |
@@ -93,7 +94,16 @@ namespace OpenSim.Server.Handlers.MapImage | |||
93 | 94 | ||
94 | byte[] result = new byte[0]; | 95 | byte[] result = new byte[0]; |
95 | string format = string.Empty; | 96 | string format = string.Empty; |
96 | result = m_MapService.GetMapTile(path.Trim('/'), out format); | 97 | |
98 | UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992"); | ||
99 | |||
100 | string[] bits = path.Trim('/').Split(new char[] {'/'}); | ||
101 | if (bits.Length > 1) | ||
102 | { | ||
103 | scopeID = new UUID(bits[0]); | ||
104 | path = bits[1]; | ||
105 | } | ||
106 | result = m_MapService.GetMapTile(path.Trim('/'), scopeID, out format); | ||
97 | if (result.Length > 0) | 107 | if (result.Length > 0) |
98 | { | 108 | { |
99 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | 109 | httpResponse.StatusCode = (int)HttpStatusCode.OK; |
diff --git a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs index 80e3535..8a31579 100644 --- a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs | |||
@@ -119,6 +119,9 @@ namespace OpenSim.Server.Handlers.MapImage | |||
119 | int x = 0, y = 0; | 119 | int x = 0, y = 0; |
120 | Int32.TryParse(request["X"].ToString(), out x); | 120 | Int32.TryParse(request["X"].ToString(), out x); |
121 | Int32.TryParse(request["Y"].ToString(), out y); | 121 | Int32.TryParse(request["Y"].ToString(), out y); |
122 | UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992"); | ||
123 | if (request.ContainsKey("SCOPE")) | ||
124 | UUID.TryParse(request["SCOPE"].ToString(), out scopeID); | ||
122 | 125 | ||
123 | m_log.DebugFormat("[MAP REMOVE SERVER CONNECTOR]: Received position data for region at {0}-{1}", x, y); | 126 | m_log.DebugFormat("[MAP REMOVE SERVER CONNECTOR]: Received position data for region at {0}-{1}", x, y); |
124 | 127 | ||
@@ -144,7 +147,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
144 | } | 147 | } |
145 | 148 | ||
146 | string reason = string.Empty; | 149 | string reason = string.Empty; |
147 | bool result = m_MapService.RemoveMapTile(x, y, out reason); | 150 | bool result = m_MapService.RemoveMapTile(x, y, scopeID, out reason); |
148 | 151 | ||
149 | if (result) | 152 | if (result) |
150 | return SuccessResult(); | 153 | return SuccessResult(); |
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index 725204d..ba4c3c5 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs | |||
@@ -86,13 +86,14 @@ namespace OpenSim.Services.Connectors | |||
86 | m_ServerURI = serviceURI.TrimEnd('/'); | 86 | m_ServerURI = serviceURI.TrimEnd('/'); |
87 | } | 87 | } |
88 | 88 | ||
89 | public bool RemoveMapTile(int x, int y, out string reason) | 89 | public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) |
90 | { | 90 | { |
91 | reason = string.Empty; | 91 | reason = string.Empty; |
92 | int tickstart = Util.EnvironmentTickCount(); | 92 | int tickstart = Util.EnvironmentTickCount(); |
93 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 93 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
94 | sendData["X"] = x.ToString(); | 94 | sendData["X"] = x.ToString(); |
95 | sendData["Y"] = y.ToString(); | 95 | sendData["Y"] = y.ToString(); |
96 | sendData["SCOPE"] = scopeID.ToString(); | ||
96 | 97 | ||
97 | string reqString = ServerUtils.BuildQueryString(sendData); | 98 | string reqString = ServerUtils.BuildQueryString(sendData); |
98 | string uri = m_ServerURI + "/removemap"; | 99 | string uri = m_ServerURI + "/removemap"; |
@@ -146,13 +147,14 @@ namespace OpenSim.Services.Connectors | |||
146 | return false; | 147 | return false; |
147 | } | 148 | } |
148 | 149 | ||
149 | public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) | 150 | public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string reason) |
150 | { | 151 | { |
151 | reason = string.Empty; | 152 | reason = string.Empty; |
152 | int tickstart = Util.EnvironmentTickCount(); | 153 | int tickstart = Util.EnvironmentTickCount(); |
153 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 154 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
154 | sendData["X"] = x.ToString(); | 155 | sendData["X"] = x.ToString(); |
155 | sendData["Y"] = y.ToString(); | 156 | sendData["Y"] = y.ToString(); |
157 | sendData["SCOPE"] = scopeID.ToString(); | ||
156 | sendData["TYPE"] = "image/jpeg"; | 158 | sendData["TYPE"] = "image/jpeg"; |
157 | sendData["DATA"] = Convert.ToBase64String(jpgData); | 159 | sendData["DATA"] = Convert.ToBase64String(jpgData); |
158 | 160 | ||
@@ -212,7 +214,7 @@ namespace OpenSim.Services.Connectors | |||
212 | 214 | ||
213 | } | 215 | } |
214 | 216 | ||
215 | public byte[] GetMapTile(string fileName, out string format) | 217 | public byte[] GetMapTile(string fileName, UUID scopeID, out string format) |
216 | { | 218 | { |
217 | format = string.Empty; | 219 | format = string.Empty; |
218 | new Exception("GetMapTile method not Implemented"); | 220 | new Exception("GetMapTile method not Implemented"); |
diff --git a/OpenSim/Services/Interfaces/IMapImageService.cs b/OpenSim/Services/Interfaces/IMapImageService.cs index 78daa5f..b8d45dd 100644 --- a/OpenSim/Services/Interfaces/IMapImageService.cs +++ b/OpenSim/Services/Interfaces/IMapImageService.cs | |||
@@ -34,8 +34,8 @@ namespace OpenSim.Services.Interfaces | |||
34 | public interface IMapImageService | 34 | public interface IMapImageService |
35 | { | 35 | { |
36 | //List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY); | 36 | //List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY); |
37 | bool AddMapTile(int x, int y, byte[] imageData, out string reason); | 37 | bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason); |
38 | bool RemoveMapTile(int x, int y, out string reason); | 38 | bool RemoveMapTile(int x, int y, UUID scopeID, out string reason); |
39 | byte[] GetMapTile(string fileName, out string format); | 39 | byte[] GetMapTile(string fileName, UUID scopeID, out string format); |
40 | } | 40 | } |
41 | } | 41 | } |
diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs index 31e147b..4887d1c 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; |