In my last weblog entry I announced the redesigned Ogr provider for SharpMap.
Now I will describe in short how to use it in your own GIS projects.
1. Compile the latest change set of SharpMap
– Download the latest change set from the SharpMap project page and extract it.
– Also don’t forget to loaded the dependencies for compiling SharpMap.Extensions properly. Dependencies.zip & DependenciesForGdal.zip
– In the folder SharpMap you open the SharpMap.sln with Visual Studio
– The SharpMap.Extensions needs the following references: NetTopologySuite.dll, Npgsql.dll, Mono.Security.dll, PostgreSql.Data.PostgreSqlClient.dll, Oracle.DataAccess.dll, gdal_gdalconst_csharp.dll, gdal_ogr_csharp.dll, gdal_osr_csharp.dll, gdal_gdal_csharp.dll
– Also copy all the other dll’s from Gdal’s dependencies into your Debug/Release folder, because they do the “magic” wrapping work.
– Now should SharpMap compile fine with the extensions included.
2. Reference the extensions in your code
– Don’t forget to reference the SharpMap and SharpMap.Extensions assembly we created in the step before. And also copy all not managed dll’s into your Debug/Release folder. This are the Gdal wrapping dlls (*_wrap.dll) and the Gdal14.dll .
3. Use the Ogr provider
This is really simple. Just hack it as usual.
SharpMap.Map mymap = new SharpMap.Map(mapImage1.Size);
SharpMap.Layers.VectorLayer vLayer = new SharpMap.Layers.VectorLayer(“OgrSample”);
vLayer.DataSource = new SharpMap.Data.Providers.Ogr(@”D:\GeoData\MapInfo\World.TAB”);
mapImage1.Map = mymap;
4. Enjoy it!
Christian – Mainz/Germany