Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

New Post: Shapefile loading from database and indexing

$
0
0
Hello,

I'm using MapWinGIS 4.9.3 in a C# application to load vector data from a database (SQL Server 2012). My test data is fairly modest, with about 180k features, and the application needs to support murch larger datasets than this.

The test data I'm using is from this source: ftp://ftp2.census.gov/geo/tiger/TIGER2014/RAILS/tl_2014_us_rails.zip. It's in Shapefile format and I used OgrDatasource.ImportShapefile() to import this data into SQL Server.

The issue I'm running into is that the loading via Map.AddLayer() takes a long time and appears to load all at once and blocking the UI. After spending a good amount of time reading past discussions here and browsing the documentation, I have found and tried some suggestions:
1) Lock the map when loading large datasets via tkLockMode.
2) Turn on spatial indexes via Shapefile.CreateSpatialIndex().
3) Use OgrLayer.DynamicLoading property to do data loading dynamically.
4) Use SQL and call OgrLayer.RedefineQuery() to load only the data that's visible in the current Extents.

Unfortunately, none of these tactics helped, and some (such as #4) actually caused more problems. The spatial index and dynamic loading property seem like the most promising approaches, but they don't work. While I'm able to generate a spatial index for my database-loaded Shapefile, the method requires a filename parameter and appears to generate the index on disk rather than in the database. I don't think the index is being used when loading data from the database. Using a spatial database index would be ideal, but I would settle for an on-disk index as long as it's used at load time. The OgrLayer.DynamicLoading property is a mystery to me and it either results in nothing visible on the map, AccessViolationExceptions or other problems which I haven't been able to pin down reliably. DynamicLoading seems to slow down map movements and makes me think it is working at some level, but I've been unable to make it work. Part of the problem is my lack of understanding what the best practices are for loading data from a database since there are multiple ways to achieve the same thing. Namely, there's Map.AddLayerFromDatabase(), OgrDatasource.GetLayerByName(), OgrDatasource.RunQuery() and various combinations of Map.AddLayer().

OgrLayer.RedefineQuery() almost worked. The data was loaded only for the map extents, which resulted in suitable performance at low zoom levels. The problem was that the layer would get randomly restyled on every call, and Shapefile.SelectShapes() would no longer work due to the Shapefile having no shapes (NumShapes = 0).

Sorry for the long post again, but can anybody give me any advice?

Thanks

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>