Thinking in GIS
a blog about GIS from a urban geogeek living at the countryside
Creating the MapFile and data configuration (c# mapscript tutorial, part 3)
Posted: July 03, 2006Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments
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:trainingmapserverTutorialdata.
Open the map file named csharp_tutorial.map:
MAP NAME "Zone Samples" SHAPEPATH "C:\training\mapServerTutorial\data" SIZE 400 400 STATUS ON EXTENT 1143759 4417539 1146436 4420390 UNITS METERS FONTSET "fonts\fonts.list" WEB IMAGEPATH "C:\Inetpub\wwwroot\temp" IMAGEURL "C:\Inetpub\wwwroot\temp" ENDSYMBOL NAME "circle" TYPE ellipse FILLED true POINTS 1 1 END END
LAYER NAME "compfun" TYPE POLYGON STATUS ON DATA "compfun" CLASS STYLE COLOR 255 235 190 OUTLINECOLOR 0 0 0 SYMBOL 0 END END END
LAYER NAME "zone" TYPE POLYGON STATUS ON DATA "zone" CLASSITEM "COD" LABELITEM "NUMLOTT" CLASS EXPRESSION ([COD]=103) STYLE COLOR 230 50 0 OUTLINECOLOR 0 0 0 SYMBOL 0 END END CLASS EXPRESSION ([COD]=105 OR [COD]=106 OR [COD]=107 OR [COD]=108 OR [COD]=102) STYLE COLOR 255 235 230 OUTLINECOLOR 0 0 0 SYMBOL 0 END LABEL COLOR 0 0 0 FONT verdana TYPE TRUETYPE SIZE 7 POSITION CC END END CLASS EXPRESSION ([COD]=109 OR [COD]=101) STYLE COLOR 255 196 171 OUTLINECOLOR 0 0 0 SYMBOL 0 END END CLASS STYLE COLOR 225 225 225 OUTLINECOLOR 0 0 0 SYMBOL 0 END END END
LAYER NAME "vestizioni" TYPE LINE STATUS ON DATA "vestizioni" CLASS STYLE COLOR 0 0 0 SYMBOL 0 END END END
LAYER NAME "POI" TYPE POINT STATUS ON DATA "POI" LABELITEM "POI_TIME" CLASS SIZE 10 STYLE COLOR 255 0 0 OUTLINECOLOR 0 0 0 SYMBOL "circle" END TEXT ([POI_USER], [POI_TIME]) LABEL COLOR 255 0 0 FONT verdana TYPE TRUETYPE SIZE 7 POSITION LC WRAP " " END END END
END
Data Configuration
As you can see this map is composed of four layer (shapefiles).
Be sure to modify the SHAPEPATH value to the path where you have extracted the data, for example: SHAPEPATH " c:trainingmapserverTutorialdata".
You are free to use your own data (shapefiles) and map files, the tutorial will easily work with your data. But if you do so don't forget to modify the EXTENT value and the LAYER attributes according to your data.
Be also sure to have a copy of the point shapefiles you intend to edit in the same path in order to have the functionality to clear a point layer correctly working. The Shapefile copies name must have the same name as the original shape followed by “copy†(with the companion data you will have for example the shape POI and its copy POICopy). Remember that this functionality will physically delete all the point features from your shapefile.
If you are impatient to look at how the tutorial is working, you can simply download the Visual Studio Project and run it.
Otherwise go on with the next steps.