ThinkGeo.com    |     Documentation    |     Premium Support

WPF app with SQLite as data source

Hi,

I am looking for sample code that uses sqlite fie (for example, LasVegas3857.sqlite as in WorldMapKitSDKEval.zip) as map source.

I tried the code at http://community.thinkgeo.com/t/using-of-sqlitefeaturesource-and-wpf-map-suite-9/3935
but it did now show anything for 5 minutes or longer.

We are considering to use SQLite for our offline tablet so speed for rendering is important.

Thanks,

Liang

Hi,

You can find our samples about sqlite here:


and here
http://wiki.thinkgeo.com/wiki/map_suite_world_map_kit_sdk_all_samples

It looks impossible to render anything long than 5 mins. Please upload your sample which is using LasVegas3857.sqlite as data, you don’t need to upload the data, so we can try to reproduce it.

Regards,

Ethan

The code to use SQLite map I tried is as below:
private void map_sqlLoaded(object sender, RoutedEventArgs e)
{
map.MapUnit = GeographyUnit.Meter;
LayerOverlay overlay = new LayerOverlay();
overlay.TileType = ThinkGeo.MapSuite.Wpf.TileType.MultipleTile;

        SqliteFeatureLayer sqlLayer = new SqliteFeatureLayer(@"Data Source=C:\Liang\Code\LasVegas3857.sqlite", "osm_water_polygon", "id", "geometry");

        sqlLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
        sqlLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.GeographicColors.Grass); //WorldMapKitAreaStyles.Military(); 
        sqlLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        overlay.Layers.Add(sqlLayer);

        sqlLayer.Open();

        map.CurrentExtent = sqlLayer.GetBoundingBox();
        //map.CurrentExtent = new RectangleShape(-121.891, 55.902, -77.595, 23.866);
      
        sqlLayer.FeatureSource.BeginTransaction();
        sqlLayer.FeatureSource.AddFeature(new Feature(map.CurrentExtent.GetCenterPoint()));
        sqlLayer.FeatureSource.CommitTransaction();

        map.Overlays.Add(overlay);
        map.Refresh();
    }

Hi Ethan,

I looked at the links you provided. They don’t seem to provide code samples to render map from SQLite map files.

Thanks,

Liang

Hi,

Here is an update. It turns out the code snippets do render a few polygons. The reason it didn’t work was due to a bug in my code for zoom level.

Is there a recommended set of features (tables in SQLite file) together with styles to add to the map? Is there a way to display street names or names of POIs?

As we are discussing to buy World Street maps, we need a way to display the amp and check its performance.

Thanks,

Liang

Hi,

Here we have a sample about how to render a table in Sqlite, the data source is LasVegas3857.sqlite.

It only render a table for water:

If your data contains the information for example street name, it can render it.

If your data contains point data for POI, it can be rendered by set DefaultPointStyle for layer.

Please modify the data path for make it works.
9269.zip (101.5 KB)

Wish that’s helpful.

Regards,

Ethan

Ethan,

Thank you for the sample code. It works for me. But after I added another SqliteFeatureLayer for “osm_road_streets_linestring”, loading and zooming takes considerable longer time. Is there a way to make loading and zooming more smooth?

For online map, we tested with
map.Overlays.Add(new WorldStreetsAndImageryOverlay());
I attached a screen shot of it.


What’s the minimum set of SqliteFeatureLayers for the offline map do we need to have same amount of info (look and feel) as the online map? What are the recommended styles for the SqliteFeatureLayers?

Thanks,

Liang

Another question, for the map to use SQLite database, can I use map.MapUnit = GeorgraphyUnit.DecimalDegree? Anything else needs change for your sample since the following does not display anything:

map.MapUnit = GeographyUnit.DecimalDegree;
map.CurrentExtent = new RectangleShape(-115.4, 35.94, -115, 36.4);

Thanks,
Liang

Hi,

Here is an update:
I was able to set MapUnit as GeographyUnit.DecimalDegree through Project4Porjection.

It seems to me that theroadblocks are that time to load and time to zoom are too long. It takes 10+ seconds to load map initially and 5+ to zoom in/out for LasVegas3857.sqlite. The two SqliteFeatureLayer’s I added are “osm_water_polygon” and "“osm_road_streets_linestring”. To achieve the result of worldMap as attached screenshot, I am afraid more layers are needed, thus longer time.

Any suggestions?

Thanks,

Liang

Hi,

It looks the LasVegas3857 data don’t contains the osm_road_streets_linestring table, so I cannot test it, but I tested all the other tables, each layer render fast. If that’s your custom table , please make sure this table have its index for example:

About the WorldMapKit layer, you can learn about it’s render logic here: https://github.com/ThinkGeo/WorldStreetsLayerSDKOnWindows-ForWinForms

And I remembered the data we used is about 160GB, but you can remove unnecessary data from it follow your requirement to reduce the data size.

Reproject takes much more time on the fly, if you want to improve it, one solution is have better hardware configuration, the other solution is you create a data in 4326 for example: LasVegas4326.sqlite

Regards,

Ethan

Hi Ethan,

LasVegas3857.sqlite in WorldMapKitSDKEval.zip contains osm_road_streets_linestring table. The file size is 49MB. To render one single table might be fast, but it becomes much slower to render more than two tables, let alone all of them.

WorldMapKitSDKEval.zip (about 18MB) is available from ThinkGeo Product Center 9.0, Map Suite World Map Kit SDK 9.0, “Download Sample Database”.

I will try generate LasVegas4326 and test it.

Thanks,

Liang

Hi Ethan,

Have you got chance to download and try LasVegas3857.sqlite from WorldMapKitSDKEval.zip?

I have two follow up questions. For table osm_road_streets_linestring, column highway can have values of “service”, “residential”, “motoway”, “tertiary”, etc. Is there a way to render only highway of value “motoway” from zoom level 1 to level 10; “motorway”, “road” from level 11 to level 15; “motoway”, “road”, “residential” and others from level 16 to level 20? Or have different styles based on values of highway?

My second question is about WorldMapKitDataExtractor. I am trying to generate a dbase in 4326 as in the attached screen shot. But the output DB has only 24KB in size. It only contains one table “ne_country10m_linestring”. Am I doing something wrong?

Thanks,

Liang

Hi,

Thanks to let us know where you get the data.

Some data contains lots of records, if you render them in high zoomlevel, it need to load all data and it should take much source.

You should want to read the render logic of our WorldStreetsLayer, and you can see how to render the big data: https://github.com/ThinkGeo/WorldStreetsLayerSDKOnWindows-ForWinForms/blob/master/WorldStreetsLayerSDK/WorldStreetsLayer.cs

If you want to render special value of data, you should want to use our ValueStyle: https://github.com/thinkgeo?utf8=✓&q=valuestyle&type=&language=

I think you cannot use the Extractor to reproject 3857 to 4326, it only can cut the original dataset,

And it don’t have a result I think that should because your bouding box is not correct, source data should only contains the data in Las Vegas.

If you need 4326 data, one solution is you write custom code to build it, the other solution is contact our sales to check whether they have a 4326 version for download.

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

WorldStreetsLayer.cs is a good source for rendering map data. Thank you.

The samples I can find from Thinkgeo website that use WorldStreetsLayerSDK to render map are WinForm apps. Can you point me to a WPF sample which uses WorldStreetsLayerSDK? The extractor is a WPF app but it does not render map.

Best Regards,

Liang

Hi Liang,

We created one sample with WPF to display world streets layer, please refer below:
WorldStreetsSample_Wpf.zip (316.8 KB)

If you have any questions, please feel free to contact us.

Thank,
Mark