MapType.MapBenderWMS, SQLitePureImageCache

Topics: General
May 3, 2011 at 11:44 PM

Hello,

I'm having good fun using and learning about this software!

I had a few questions/ideas that i would like to toss out for consideration. For code ideas approx line numbers shown with #

1) MapType.MapBenderWMS - I was trying this out and had some sucess!

1A) Would it make sense to use a public property to allow the user to select the URL, currently it is hardcoded

    GMap.NET.GMaps.cs
    #43   public string MapBenderWMSUrl = "http://mapbender.wheregroup.com/cgi-bin/mapserv?map=/data/umn/osm/osm_basic.map&VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=OSM_Basic&styles=&bbox={0},{1},{2},{3}&width={4}&height={5}&srs=EPSG:4326&format=image/png";
    #1798 var ret = string.Format(CultureInfo.InvariantCulture, MapBenderWMSUrl, p1.Lng, p1.Lat, p2.Lng, p2.Lat, ProjectionForWMS.TileSize.Width, ProjectionForWMS.TileSize.Height);

1B) If using this, to change the URL, the issue it the cache does not realize and serves tiles from a different WMS server.

    I figure i could delete the disk cache and then call ReloadMap(). But there might be some good stuff in the cache for other MapType.
    Could write something that selectively deletes cached tiles for MapType.MapBenderWMS
    Not sure yet the best strategy so i toss it out for consideration.


2) Caching, TilePrefetcher etc.

2A) I am wondering if it would make sense to expose these properties, perhaps as readonly. For some reason MsSQLPureImageCache is the only one that is public.
    GMap.NET.CacheProviders.SQLitePureImageCache.cs
    #25   public class SQLitePureImageCache : PureImageCache
    #28   public string gtileCache;
    #29   public string dir;
    #30   public string db;
    #391  public readonly List<string> AttachedCaches = new List<string>();

2B) As you change cache locations, new databases are added to the AttachedCaches collection. So you may have some from a prevous cache location.
I'm not sure if this makes sense or not. Or should the AttachedCaches list be cleared when you change cache locations?


2C) I'm trying to learn about the SQLitePureImageCache.ExportMapDataToDB function.
I noticed that it does not copy over the Tiles.CacheTime field
I'm wondering why the difference is between doing it this way, copy record by record between database, vs just copy the entire .gmdb file?
Seems to me both do about the same, not sure why to use one vs the other.

May 4, 2011 at 7:48 AM

1. You can create another custom MapType with custom urls, anyway abstract map provider system is coming, so it will be easy to add new maps

2B. I'l fix it, thx

2C. ExportMapDataToDB does not override current records, so you can can 'merge' two caches, CacheTime isn't copied because old databases doesn't have such column, i'll try to check it too

May 14, 2011 at 6:02 PM

Thank you very much for making the changes for 2B.

I am writing an application which will do a lot of management of caches for offline use.
I have made a few changes in my local copy to give access to the things in 2A - they are helpful to report to the user what is going on.

3)
I have been looking over the winforms demo and doing my own code for map caching and it is largely working,
I'm trying to better understand the ideas here so had a few questions:

3A) GMap.NET.WindowsForms.GMapControl.ShowImportDialog
- this works well to import one file
- the second file to import fails with:
SQLite error - database Source is already in use
- it appears to be failing on the destination file, perhaps left locked by the previous import?
- i didnt spot the reason for this issue, but i am not very skilled with SQLite.

3B) Using the WinForms demo, when i try to delete with the 'clear all' button
MainForm.button2_Click
"The process cannot access the file 'Data.gmdb' because it is being used by another process."

Is there a way to close so as to allow this?

3C)
My design has separate caches as follows:
        - main cache for most operational usage
        - saved cache which will be used for PreFetch, Import, Export etc.
I did this so as to keep the saved cache pure with the data selected and not mixed with the assortment of data
that is in the main cache. To do this i switch the cache location for import/export/prefetch, then restore the
normal cache after.
Later i hope to be able to have the application fetching data into one cache file (perhaps a large fetch),
and at the same time be using GMaps normally to view using the main cache.

Any thoughts on this idea and the feasability of it - or perhaps better ideas?

3D)
One other idea i had was to be able to limit the cache file size, and the download bandwidth during large prefetch.
Is there anything in place that migth help in these?

1) the abstract map provider system sounds interesting - is this present in a fork as yet?

May 16, 2011 at 8:32 AM

...need some testing, provider system is not done yet. About locked file, i forget to detach source database, fix is coming ;}

// for fast fix, in function ExportMapDataToDB
...
tr.Rollback();
ret = false;
}
}
// add this code
using(SQLiteCommand cmd = new SQLiteCommand(string.Format("DETACH DATABASE Source;", sourceFile), cn2))
{
cmd.ExecuteNonQuery();
 }
...
 
Prefetching to separate database is quite good idea, anyway we can import it easily later if we want to or just use as additional cache.

And about limiting download bandwidth, need to change prefetcher logic somehow...

May 16, 2011 at 10:53 AM

Wow, thanks for such quick response. Your export patch works well!

Glad to hear i am on a reasonable path with the separate cache - it seems to be working also but i've got more testing to do on that.

Is the issue in 3B similar to that in 3A maybe?

May 16, 2011 at 11:25 AM

3B works for me, maybe you try dear data while some tiles are still flushing bytes to cache, just wait few seconds and try again, you can use process explorer to see if you process do some I/O operations...