Add delete maptile ability to MapImageService - yet untested
parent
ae56b946cf
commit
a53272c5fb
|
@ -86,6 +86,66 @@ namespace OpenSim.Services.Connectors
|
|||
m_ServerURI = serviceURI.TrimEnd('/');
|
||||
}
|
||||
|
||||
public bool RemoveMapTile(int x, int y, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
int tickstart = Util.EnvironmentTickCount();
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
sendData["X"] = x.ToString();
|
||||
sendData["Y"] = y.ToString();
|
||||
|
||||
string reqString = ServerUtils.BuildQueryString(sendData);
|
||||
string uri = m_ServerURI + "/removemap";
|
||||
|
||||
try
|
||||
{
|
||||
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
|
||||
uri,
|
||||
reqString);
|
||||
if (reply != string.Empty)
|
||||
{
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
|
||||
if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString());
|
||||
reason = replyData["Message"].ToString();
|
||||
return false;
|
||||
}
|
||||
else if (!replyData.ContainsKey("Result"))
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
|
||||
reason = "Unexpected result " + replyData["Result"].ToString();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Map post received null reply");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting map server at {0}: {1}", uri, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// This just dumps a warning for any operation that takes more than 100 ms
|
||||
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddMapTile(int x, int y, byte[] jpgData, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace OpenSim.Services.Interfaces
|
|||
{
|
||||
//List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY);
|
||||
bool AddMapTile(int x, int y, byte[] imageData, out string reason);
|
||||
bool RemoveMapTile(int x, int y, out string reason);
|
||||
byte[] GetMapTile(string fileName, out string format);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,9 +112,38 @@ namespace OpenSim.Services.MapImageService
|
|||
reason = e.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Also save in png format?
|
||||
return UpdateMultiResolutionFiles(x, y, out reason);
|
||||
}
|
||||
|
||||
public bool RemoveMapTile(int x, int y, out string reason)
|
||||
{
|
||||
reason = String.Empty;
|
||||
string fileName = GetFileName(1, x, y);
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e);
|
||||
reason = e.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return UpdateMultiResolutionFiles(x, y, out reason);
|
||||
}
|
||||
|
||||
private bool UpdateMultiResolutionFiles(int x, int y, out string reason)
|
||||
{
|
||||
reason = String.Empty;
|
||||
lock (m_Sync)
|
||||
{
|
||||
// Stitch seven more aggregate tiles together
|
||||
for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++)
|
||||
{
|
||||
|
@ -126,7 +155,7 @@ namespace OpenSim.Services.MapImageService
|
|||
|
||||
if (!CreateTile(zoomLevel, x1, y1))
|
||||
{
|
||||
m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0} at zoom level {1}", fileName, zoomLevel);
|
||||
m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel);
|
||||
reason = string.Format("Map tile at zoom level {0} failed", zoomLevel);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue