SharpMap and MapInfo

Topics: SharpMap v2.0
Sep 24, 2007 at 12:29 PM
Hi people!!!
Help me to open on page a card MapInfo.
I have an example how to open card ArcGis,

SharpMap.Map map = new SharpMap.Map(outputsize);
SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries");
layCountries.DataSource = new SharpMap.Data.Providers.ShapeFile(Server.MapPath(@"~\App_data\australia.shp"), true);
layCountries.Style.Fill = new SolidBrush(Color.White);
layCountries.Style.Outline = System.Drawing.Pens.Black;
layCountries.Style.EnableOutline = true;
map.Layers.Add(layCountries);

but I do not know as to open card MapInfo.
Help knowing people...
Sep 24, 2007 at 2:02 PM
Hello Dmitry!


If you are on ASP.net:

Support for opening mapinfo tab files is in the SharpMap.Extensions OGR provider. For supporting mapinfo you need some extra tools:

First install FWtools on the server from:

http://fwtools.maptools.org/

the latest version is 1.3.7 I compiled SharpMap.extensions against this library. If you want it send me a personal message.

Then you add the following to your map construction:

SharpMap.Layers.VectorLayer layWorldCountries = new SharpMap.Layers.VectorLayer("World Countries");
layWorldCountries.DataSource = new SharpMap.Data.Providers.Ogr(HttpContext.Current.Server.MapPath(@"~\App_data\worldcountries.tab"));
layWorldCountries.Style.Fill = System.Drawing.Brushes.Transparent;
map.Layers.Add(layWorldCountries);

If you find this to dificult, you can always convert to shape from within MapInfo

Kind regards,

Milo van der Linden
Sep 25, 2007 at 6:12 AM
Hi!
Has loaded and has installing on server FWtools 1.3.7, Has inserted a code, and it to me
Compiler Error Message: CS0234: The type or namespace name 'Ogr' does not exist in the namespace 'SharpMap.Data.Providers' (are you missing an assembly reference?)
Sep 25, 2007 at 9:53 AM
Edited Sep 25, 2007 at 9:55 AM
Hello Dmitriy007,

Regarding namespace changes see: http://www.codeplex.com/SharpMap/Thread/View.aspx?ThreadId=15509

But I have a compilation set ready for you, I will send you a personal message with my e-mail address. If you contact me, I will send you the zip file.

Kind regards,

Milo van der Linden
Sep 26, 2007 at 5:49 AM
Has copied all in a folder bin, and began to give out mistake "The type initializer for ' OSGeo. OGR.Ogr ' threw an exception". Now even *.shp files are not started.
Sep 26, 2007 at 7:46 AM
Make sure that for OGR support (If you have installed FWTools 1.3.7) you set your environment variables correct, the dll's that are in the bin folder HAVE TO be able to find the related OGR and GDAL functions and tools:

(%FWTOOLS_DIR% sould be replaced by the directory where your FWTools is installed!)

- To make sure it works, I always set these as System, not user variables:

PATH=%FWTOOLSDIR%\bin;%FWTOOLSDIR%\python;%PATH%
set PROJLIB=%FWTOOLSDIR%\proj_lib
set GEOTIFFCSV=%FWTOOLSDIR%\data
set GDALDATA=%FWTOOLSDIR%\data
set GDALDRIVERPATH=%FWTOOLSDIR%\gdalplugins
Sep 26, 2007 at 11:33 AM
It is possible on more in detail, that it is necessary to make.
It is established at me FWTools1.3.7 in a folder c: \Program Files.
Has copied yours dll in a folder c: \Inetpub \wwwroot \Bin\.