This little installment is about the configuration of MapServer to work properly on IIS. All the guides available focus on the installation along with Apache, but this is not always an option, especially on microsoft based production servers.
1. Get MapServer. Get the stable zip package (not the installer!) from the MS4W download page.2. Setup your website in IIS. It can be the default website, or a new one.
3. Create a directory within your website directory, let's say ~/MapServ. Unpack the MS4W package somewhere else, and copy the contents of the apache\cgi-bin directory to the directory you just created.4. Enable CGI. You need to be able to run ~/MapServ/mapserv.exe as a CGI script. This is the quickest way, suitable only for your own development box. Select your website, select Handler Mappings, allow CGI-exe. Go to server level, select ISAPI and CGI restrictions, add a new one which points to MapServ\mapserv.exe (use path on disk) and check the Allow checkbox in the popup.
5. Get your map. You need a map file to serve through MapServer. Let's say you have an ecw file with the corresponding aux. Create a directory somewhere on your website, for example within the MapServ directory, or on the same level. Let's say ~/Map. Put your ecw and aux file there.6. Create the .map file and place it within the ~/Map directory, where the ecw file is. This is a tricky part which will require patience. You will need to know a few fundamental details about your map:
- Imagetype: how is your map encoded. This is a file format like PNG, JPG, ...
- The map extent. This is the area that the map covers, its four corners. This depends on the projection that the map uses, hopefully someone will be able to tell that. My map had coordinates in the form of four numbers in the range of millions.
- The map current projection. This will be a name of the projection. My map was in Gauss Boaga coordinates, Roma 40. And I wanted output in geographical coordinates, the ones google uses. Ouch.
Now you can start creating your Map File.
MAP
IMAGETYPE PNG
EXTENT 1000000 5000000 1001000 5100000
SIZE 400 400
SHAPEPATH "." #Esterna
LAYER NAME main DATA "mymap.ecw" TYPE RASTER # Map source projection goes here END # Output projection goes here END
But how about projections? You know already that there are TONS of coordinate systems and projection, and they are not exacly easy to convert. MapServer is however smart enough to handle all that for you. You only need to know the source and destination projections. This means: how is your map currently saved (and its extent) and how you want to communicate coordinates to MapServer to get meaningful results to you.The holy grail is the spatialreference.org website.
- Source projection: gauss boaga, fuso ovest? It's officially called "SR-ORG:4685". And there is this beautiful page which has a little link called MapServer Mapfile. Get the contents and replace them in the above listing.
- Output projection: same as above, but for geographic coordinates.
http://localhost/MapServ/mapserv.exe?mode=map&map=MAPFILEPATH&mapext=LON1+LAT1+LON2+LAT2&layers=LAYERNAME
- MAPFILEPATH is the path to the .map file you created. It is relative to the root of your website without the leading /, for example Map/mymapfile.map
- LAT1... those are the coordinates. Note that the order is lon, lat, not lat, lon as google's "what's here" function outputs them
- Layer name: is the NAME in the LAYER block in your .map file
Good luck with your mapping!!