aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs2
-rw-r--r--OpenSim/Server/Handlers/Map/MapAddServerConnector.cs5
-rw-r--r--OpenSim/Server/Handlers/Map/MapGetServerConnector.cs12
-rw-r--r--OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs252
-rw-r--r--OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs8
-rw-r--r--OpenSim/Services/Interfaces/IMapImageService.cs6
-rw-r--r--OpenSim/Services/MapImageService/MapImageService.cs39
7 files changed, 297 insertions, 27 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 4a61969..c2c575c 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 4502b7d..5454c6f 100644
--- a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
@@ -38,6 +38,7 @@ using OpenSim.Server.Base;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Server.Handlers.Base; 40using OpenSim.Server.Handlers.Base;
41using OpenMetaverse;
41 42
42namespace OpenSim.Server.Handlers.MapImage 43namespace 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
new file mode 100644
index 0000000..8a31579
--- /dev/null
+++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
@@ -0,0 +1,252 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Xml;
33
34using Nini.Config;
35using log4net;
36using OpenMetaverse;
37
38using OpenSim.Framework;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Server.Handlers.Base;
43
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45
46namespace OpenSim.Server.Handlers.MapImage
47{
48 public class MapRemoveServiceConnector : ServiceConnector
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private IMapImageService m_MapService;
53 private IGridService m_GridService;
54 private string m_ConfigName = "MapImageService";
55
56 public MapRemoveServiceConnector(IConfigSource config, IHttpServer server, string configName) :
57 base(config, server, configName)
58 {
59 IConfig serverConfig = config.Configs[m_ConfigName];
60 if (serverConfig == null)
61 throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
62
63 string mapService = serverConfig.GetString("LocalServiceModule",
64 String.Empty);
65
66 if (mapService == String.Empty)
67 throw new Exception("No LocalServiceModule in config file");
68
69 Object[] args = new Object[] { config };
70 m_MapService = ServerUtils.LoadPlugin<IMapImageService>(mapService, args);
71
72 string gridService = serverConfig.GetString("GridService", String.Empty);
73 if (gridService != string.Empty)
74 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
75
76 if (m_GridService != null)
77 m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is ON");
78 else
79 m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF");
80
81 bool proxy = serverConfig.GetBoolean("HasProxy", false);
82 server.AddStreamHandler(new MapServerRemoveHandler(m_MapService, m_GridService, proxy));
83
84 }
85 }
86
87 class MapServerRemoveHandler : BaseStreamHandler
88 {
89 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
90 private IMapImageService m_MapService;
91 private IGridService m_GridService;
92 bool m_Proxy;
93
94 public MapServerRemoveHandler(IMapImageService service, IGridService grid, bool proxy) :
95 base("POST", "/removemap")
96 {
97 m_MapService = service;
98 m_GridService = grid;
99 m_Proxy = proxy;
100 }
101
102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
103 {
104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
105 StreamReader sr = new StreamReader(requestData);
106 string body = sr.ReadToEnd();
107 sr.Close();
108 body = body.Trim();
109
110 try
111 {
112 Dictionary<string, object> request = ServerUtils.ParseQueryString(body);
113
114 if (!request.ContainsKey("X") || !request.ContainsKey("Y"))
115 {
116 httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest;
117 return FailureResult("Bad request.");
118 }
119 int x = 0, y = 0;
120 Int32.TryParse(request["X"].ToString(), out x);
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);
125
126 m_log.DebugFormat("[MAP REMOVE SERVER CONNECTOR]: Received position data for region at {0}-{1}", x, y);
127
128 if (m_GridService != null)
129 {
130 System.Net.IPAddress ipAddr = GetCallerIP(httpRequest);
131 GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize);
132 if (r != null)
133 {
134 if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString())
135 {
136 m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be trying to impersonate region in IP {1}", ipAddr, r.ExternalEndPoint.Address);
137 return FailureResult("IP address of caller does not match IP address of registered region");
138 }
139
140 }
141 else
142 {
143 m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue. Region not found at coordinates {1}-{2}",
144 ipAddr, x, y);
145 return FailureResult("Region not found at given coordinates");
146 }
147 }
148
149 string reason = string.Empty;
150 bool result = m_MapService.RemoveMapTile(x, y, scopeID, out reason);
151
152 if (result)
153 return SuccessResult();
154 else
155 return FailureResult(reason);
156
157 }
158 catch (Exception e)
159 {
160 m_log.ErrorFormat("[MAP SERVICE IMAGE HANDLER]: Exception {0} {1}", e.Message, e.StackTrace);
161 }
162
163 return FailureResult("Unexpected server error");
164 }
165
166 private byte[] SuccessResult()
167 {
168 XmlDocument doc = new XmlDocument();
169
170 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
171 "", "");
172
173 doc.AppendChild(xmlnode);
174
175 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
176 "");
177
178 doc.AppendChild(rootElement);
179
180 XmlElement result = doc.CreateElement("", "Result", "");
181 result.AppendChild(doc.CreateTextNode("Success"));
182
183 rootElement.AppendChild(result);
184
185 return DocToBytes(doc);
186 }
187
188 private byte[] FailureResult(string msg)
189 {
190 XmlDocument doc = new XmlDocument();
191
192 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
193 "", "");
194
195 doc.AppendChild(xmlnode);
196
197 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
198 "");
199
200 doc.AppendChild(rootElement);
201
202 XmlElement result = doc.CreateElement("", "Result", "");
203 result.AppendChild(doc.CreateTextNode("Failure"));
204
205 rootElement.AppendChild(result);
206
207 XmlElement message = doc.CreateElement("", "Message", "");
208 message.AppendChild(doc.CreateTextNode(msg));
209
210 rootElement.AppendChild(message);
211
212 return DocToBytes(doc);
213 }
214
215 private byte[] DocToBytes(XmlDocument doc)
216 {
217 MemoryStream ms = new MemoryStream();
218 XmlTextWriter xw = new XmlTextWriter(ms, null);
219 xw.Formatting = Formatting.Indented;
220 doc.WriteTo(xw);
221 xw.Flush();
222
223 return ms.ToArray();
224 }
225
226 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
227 {
228 if (!m_Proxy)
229 return request.RemoteIPEndPoint.Address;
230
231 // We're behind a proxy
232 string xff = "X-Forwarded-For";
233 string xffValue = request.Headers[xff.ToLower()];
234 if (xffValue == null || (xffValue != null && xffValue == string.Empty))
235 xffValue = request.Headers[xff];
236
237 if (xffValue == null || (xffValue != null && xffValue == string.Empty))
238 {
239 m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header");
240 return request.RemoteIPEndPoint.Address;
241 }
242
243 System.Net.IPEndPoint ep = Util.GetClientIPFromXFF(xffValue);
244 if (ep != null)
245 return ep.Address;
246
247 // Oops
248 return request.RemoteIPEndPoint.Address;
249 }
250
251 }
252}
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index 267dd71..6095598 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
@@ -209,7 +211,7 @@ namespace OpenSim.Services.Connectors
209 211
210 } 212 }
211 213
212 public byte[] GetMapTile(string fileName, out string format) 214 public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
213 { 215 {
214 format = string.Empty; 216 format = string.Empty;
215 new Exception("GetMapTile method not Implemented"); 217 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 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;