HG map tile fetch: handle cached images appropriately.
parent
5b43f9cac4
commit
21dedb573b
|
@ -158,10 +158,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WebClient c = new WebClient();
|
WebClient c = new WebClient();
|
||||||
//m_log.Debug("JPEG: " + imageURL);
|
|
||||||
string name = regionID.ToString();
|
string name = regionID.ToString();
|
||||||
filename = Path.Combine(storagePath, name + ".jpg");
|
filename = Path.Combine(storagePath, name + ".jpg");
|
||||||
c.DownloadFile(imageURL, filename);
|
m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename);
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading...");
|
||||||
|
c.DownloadFile(imageURL, filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image");
|
||||||
|
|
||||||
bitmap = new Bitmap(filename);
|
bitmap = new Bitmap(filename);
|
||||||
//m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
|
//m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
|
||||||
byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true);
|
byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true);
|
||||||
|
@ -172,10 +179,11 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||||
|
|
||||||
ass.Data = imageData;
|
ass.Data = imageData;
|
||||||
|
|
||||||
m_AssetService.Store(ass);
|
mapTile = ass.FullID;
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
mapTile = ass.FullID;
|
m_AssetService.Store(ass);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||||
{
|
{
|
||||||
|
|
|
@ -324,7 +324,7 @@ namespace OpenSim.Services.GridService
|
||||||
regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);
|
regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);
|
||||||
|
|
||||||
AddHyperlinkRegion(regInfo, handle);
|
AddHyperlinkRegion(regInfo, handle);
|
||||||
m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID);
|
m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region_uuid {0} with image {1}", regInfo.RegionID, regInfo.TerrainImage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue