What is PostGIS

PostGIS is an extension for PostgreSQL RDBMS that spatially enables it for storing GIS content.

It could be considered something similiar to Esri ArcSDE or Oracle Spatial.
In fact PostGIS is for PostgreSQL what is Esri ArcSDE for Oracle, MS SQL Server, Informix, DB2.

PostGIS is OGC compliant and is Open Source, released under the GNU General Public License.

For more info about PostGIS you can take a look here.

PostGIS Installation

First, if it is not on your RDBMS Server, you have to download and install PostgreSQL. Refer to the PostgreSQL's Web Site for doing so.

After you have succesfully installed PostgreSQL, you can add the PostGIS module. For doing so refer to the PostGIS's Web Site.

Read more

Add reference to mapscript

Add the reference to mapscript_csharp.dll (browse to the mapscrip installation folder, for example C:\ms4w\Apache\cgi-bin\mapscript\csharp):

{{:mapserver:tutorial:add_reference.jpg|:mapserver:tutorial:add_reference.jpg}}

Remember that if you didn't set PATH environment variable to the MapServer dlls you will need to manually copy them under the bin folder of this ASP .NET application.

Read more

Create an ASP .NET C# Project

Open Visual Studio, create a new ASP .NET C# Project called TutorialMapServer:

insert_default_form.jpg

Insert application key value in web.config

Open web.config and add the following appSettings section under configuration section:

<configuration>
  <appSettings>
    <!--  Path to MapFile -->
    <add key="mapFilePath" 
         value = " C:\training\mapServerTutorial\data\csharptutorial.map"
    />
  </appSettings> 
  <!--  ........ -->
</configuration>

For the key mapFilePath be sure to put the right path to the map file (also a relative path is valid).

Read more

Creating the MapFile

For what is a MapFile and a reference about it you can view the MapFile Reference at MapServer web site.

Here you can download the data, map file and fonts needed for this tutorial.

Extract data.zip wherever you think in your hard disk, for example at c:\training\mapserverTutorial\data.

Read more

Download MapServer

Download precompiled binaries here. For the purpose of this tutorial is indifferent if you download the MS4W for PHP4 or PHP5.

(As an alternative you could download an installation toolkit like this and compile yourself MapServer, but it is more difficult).

Installation

All you need to do is to extract the zip file, for example at: C:\ms4w.
Here we will not mention how to install CGI MapServer, because we are using the other modality (MapScript).

After doing that take a look at the structures of the directories created under C:\ms4w.

All the references we need in our C# ASP .NET (or Windows) application are the dll under:
C:\ms4w\Apache\cgi-bin\mapscript\csharp and the dll under C:\ms4w\Apache\cgi-bin.

The only .NET dll is C:\ms4w\Apache\cgi-bin\mapscript\csharp\mapscript_csharp.dll.

For all the other dlls is enough for them to be accessible for our application. To get this it is possible to operate in two ways:

  • for every .NET project manually copy these dll under bin
  • or simply put the path to all these dll under PATH Windows environment variable.

Note that not even a dll need to be registered on Windows (with REGSVR32), so when your application will be complete you could easily FTP it to your web server host.

What is MapServer?

According to MapServer official site:

MapServer is an Open Source development environment for building spatially-enabled internet applications. MapServer is not a full-featured GIS system, nor does it aspire to be. Instead, MapServer excels at rendering spatial data (maps, images, and vector data) for the web.

MapServer was originally developed by the University of Minnesota (UMN) ForNet project in cooperation with NASA and the Minnesota Department of Natural Resources (MNDNR). Presently, the MapServer project is hosted by the TerraSIP project, a NASA sponsored project between the UMN and consortium of land management interests.
The software is maintained by a growing number of developers (nearing 20) from around the world and is supported by a diverse group of organizations that fund enhancements and maintenance.

Read more

In the next stops I will write a tutorial about programming MapServer with .NET c#.

This tutorial will try to guide you step by step in implementing a GIS (Geographic Information Systems) web solution, based on Open Source software (MapServer and PostGIS), within the .NET Framework.

How to download the tutorial

The tutorial's data needed to complete this tutorial are downloadable here.
In any case the tutorial is made in a way that you can easily adapt to use your own data (shapefiles).

Here you can find a complete working Visual Studio 2003 solution (ASP .NET 1.1) with the whole tutorial's solution.

Read more