Hi,
I would like to clear the cache when newer imagery is available on Bing. Is there a way to compare the cached image to the live Bing image and clear the cache if they are different?
Thanks!
Hi,
I would like to clear the cache when newer imagery is available on Bing. Is there a way to compare the cached image to the live Bing image and clear the cache if they are different?
Thanks!
Chris,
I am afraid we don’t have API to compare the cached image and clear the cached image, the workaround I think you can hookup the SendingRequest event, and you can get the request uri from eventargs, at this time you can write your method to get resonse stream and convert to image, and then compare the cached image to decide use it or override it.
Sorry for inconvenience.
Thanks,
James
James,
I'm running in to a problem with this approach. If the image is in the cache, SendingRequest event does not fire. SendingRequest only seems to fire when a request is being sent to Bing. Please advise.
Thanks!
Chris,
Yes, you’re right, I didn’t notice that. So probably you couldn’t implement your reqirement so far. We will consider to expose more API to let users do some extend.
James
James,
How are images organized in the cache folder? I would like to request image date from Bing using Bing SDK and compare it to an image file date in the cache folder.
Thanks.
Chris,
The following code is that how we generate cache folder, from it I think you can get idea about the cache folder organization.
private string GetCacheFilePath()
{
if (string.IsNullOrEmpty(this.CacheDirectory))
{
return null;
}
string format;
switch (this.PictureFormat)
{
case BingMapsPictureFormat.Gif:
format = "gif"; break;
case BingMapsPictureFormat.Png:
format = "png"; break;
default:
format = "jpg"; break;
}
return string.Format(CultureInfo.InvariantCulture, "{0}\\{1}{2}-{3}-{4}.{5}",
this.CacheDirectory + this.ZoomLevel + "\\" + this.Column,
GetMapType(this.MapType),
this.ZoomLevel,
this.Column,
this.Row,
format);
}
Thanks,
James
James,
How are column and row calculated?
Thanks again.
Chris,
I attached the sample code for caculating columns and rows. Please refer to it.
Thanks,
James
ColumnRowCalculated.txt (2.29 KB)
James,
My columns and rows don't seem to be coming out quite right with these calculations. I'm using EPSG 4326 projection and a zoom level of 10. The problem code is in the click event of btnCheckBing. Could you take a look?
Thanks!
001_bing.zip (97.1 KB)
Chris,
It seems your data is EPSG 4326, but you convert them to Bing map projection, so that it should be working, and I don’t find your shp files in attachement so couldn’t debug clear, could you provide data as well so that I can reproduce it in my local machine?
Thanks,
James
James,
My shape files are located here:
gis.thinkgeo.com/Portals/1/activeforums_Attach/IA167ctycu.zip
Thanks.
Chris,
I have sent sample code to your mailbox, hope it can help you solve your problem.
Thanks,
James
That works. Thanks!
Chris,
I am glad it’s working with you.
James