Nouveaux OUTPUTFORMAT de Mapserver 6.0

Une des nouveautés de Mapserver 6.0 est l’ajout de nouveaux formats de sortie liés aux requêtes GetFeature via WFS. Attention par contre, on doit obligatoirement installer GDAL/OGR 1.8. Dans mon cas test sur mon serveur Debian, je devais utiliser une connexion Oracle. J'ai donc compilé GDAL/OGR avec le support Oracle et compilé Mapserver pour lire ce format via GDAL/OGR. J'ai aussi préparé un fichier regroupant les formats de sortie suivant: OUTPUTFORMAT   NAME "SHAPEZIP"   DRIVER "OGR/ESRI Shapefile"   MIMETYPE "application/shapefile"   FORMATOPTION "STORAGE=filesystem"   FORMATOPTION "FORM=zip"   FORMATOPTION "FILENAME=result.zip" END OUTPUTFORMAT   NAME "MIDMIF"   DRIVER "OGR/MapInfo File"   FORMATOPTION "STORAGE=filesystem"   FORMATOPTION "FORM=multipart"   FORMATOPTION "DSCO:FORMAT=MIF"   FORMATOPTION "FILENAME=result.mif" END OUTPUTFORMAT   NAME "MultiMIDMIF"   DRIVER "OGR/MapInfo File"   FORMATOPTION "STORAGE=filesystem"   FORMATOPTION "FORM=multipart"   FORMATOPTION "DSCO:FORMAT=MIF"   FORMATOPTION "FILENAME=result" END OUTPUTFORMAT   NAME "CSV"   DRIVER "OGR/CSV"   MIMETYPE "text/csv"   FORMATOPTION "LCO:GEOMETRY=AS_WKT"   FORMATOPTION "STORAGE=filesystem"   FORMATOPTION "FORM=simple"   FORMATOPTION "FILENAME=result.csv" END OUTPUTFORMAT   NAME "CSVSTREAM"   DRIVER "OGR/CSV"   MIMETYPE "text/csv; streamed"   FORMATOPTION "LCO:GEOMETRY=AS_WKT"   FORMATOPTION "STORAGE=stream"   FORMATOPTION "FORM=simple"   FORMATOPTION "FILENAME=result.csv" #-- If “stream” then the datasource will be created with a name “/vsistdout” as an attempt to write directly to stdout. Only a few OGR drivers will work properly in this mode (ie. CSV, perhaps kml, gml) END OUTPUTFORMAT   NAME "OGRGML"   DRIVER "OGR/GML"   MIMETYPE "text/xml; subtype=gml/2.1.2; driver=ogr"   FORMATOPTION "STORAGE=memory"   FORMATOPTION "FORM=multipart"   FORMATOPTION "FILENAME=result.gml" END OUTPUTFORMAT   NAME kml   DRIVER "KML"   MIMETYPE "application/vnd.google-earth.kml+xml"   IMAGEMODE RGB   EXTENSION "kml"   FORMATOPTION 'ATTACHMENT=result.kml'   FORMATOPTION "maxfeaturestodraw=100" END OUTPUTFORMAT   NAME kmz   DRIVER "KMZ"   MIMETYPE "application/vnd.google-earth.kmz"   IMAGEMODE RGB   EXTENSION "kmz"   FORMATOPTION 'ATTACHMENT=result.kmz' END OUTPUTFORMAT   NAME "geojson"   DRIVER "TEMPLATE"   MIMETYPE "application/json; subtype=geojson"   FORMATOPTION "FILE=../template/geojson.txml" END OUTPUTFORMAT   NAME "customxml"   DRIVER "TEMPLATE"   FORMATOPTION "FILE=mon_template.xml" END J'ai testé avec ce Mapfile WFS plusieurs de ces formats. Pour le type “SHAPEZIP” par exemple, on fait simplement cette requête URL: http://sigtest.gouc.qc/cgi-bin/extract?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&typename=SMDTS_TERR&OUTPUTFORMAT=SHAPEZIP NOTE 1: Je n'ai pas ajouter de clause FILTER pour mon test mais c'est possible. Voir ici pour plus d'explications NOTE 2: J'ai n'ai pas fait d'essais avec le format de sortie TEMPLATE qui nous permet de personnaliser un format de sortie texte comme geojson par exemple. Cette option est très puissante et mérite d'être mieux connue. Imaginer utiliser Mapserver pour générer du code javascript pour jQuery par exemple...! NOTE 3: Par comparaison, avec Geoserver qui support déjà ce type de format de sortie (SHAPEFILES) depuis plus longtemps: http://sigtest.gouv.qc:8180/geoserver/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&typename=SMDTS_TERR&OUTPUTFORMAT=SHAPE-ZIP

New Spatialite format with Mapserver and GDAL/OGR 1.7.0

Sometime we find something such simple as stupide ... I think that Spatialite is one of that.  If you look for a GIS storage format AND tabular data, very simple, open, easy to use and manage with Mapserver, python or php, take a look to this solution. Note that with a single database file you can build, query and manage your data like MySql or Postgresql. For my test, I use the open data Natural Earth, and it work at my first try ..! :) Rock On!! My NaturalEarth.sqlite file can be dowload here. (Natural Earth. Free vector and raster map data @ naturalearthdata.com). I load it with the Spatiallite-gui tools and than visualize them with the Spatiallite-gis... It take's me 15 minutes... Including the download and install steps... To make my first WMS Spatialite data test, I build a mapfile for Mapserver with this cool free vector dataset of Natural Earth. I just have to replace the shapefiles connection string with a OGR connection type and specify the table name:         CONNECTIONTYPE OGR         CONNECTION "path_to_spatialite_file"         DATA "50m-geography-marine-polys" Also, note that you HAVE to use the latest GDAL/OGR(version 1.7.0). If you use MS4W, you can download the beta10 or later. My first impression is that is not as fast as shapefile format. I gona test for larger dataset later... But, according to OGR specification web page, this driver still don't take advantage of spatial index?. So it's not a negative tips of this format... My mapfile test is here: MAP     NAME "spatialite"     EXTENT -180 -90 180 90       SIZE 700 500     IMAGETYPE PNG     IMAGECOLOR 0 0 0       UNITS METERS     SYMBOLSET                   "/ms4w/msp/symbols/commun/symbols.map"     FONTSET                     "/ms4w/msp/fonts/commun/fonts.txt"     CONFIG MS_ERRORFILE         "/ms4w/tmp/mapserv.log"     WEB         QUERYFORMAT     "text/xml"         BROWSEFORMAT    "text/xml"         IMAGEPATH       "/srv/www/msp/services/tmp/"         IMAGEURL        "/ms_tmp/"             METADATA            "wms_title"                  "spatialite test"            "wms_name"                   "spatialite"            "wms_abstract"               ""            "wms_description"            ""            "wms_keywordlist"            "Spatialite test"            "wms_onlineresource"         "http://localhost/cgi-bin/mapserv.exe?map=C:/Travail/spatialite/spatialite.map"         END     END     PROJECTION         "init=epsg:4326"     END     LAYER         NAME "50m-admin-1-states-provinces-shp"         DATA "C:/Travail/spatialite/NaturalEarth/50m-admin-1-states-provinces-shp.shp"          TYPE polygon         PROJECTION             "init=epsg:4326"         END         METADATA             "wms_name"              "50m-admin-1-states-provinces-shp"             "wms_title"             "states-provinces shapefiles"             "wms_keywordlist"       ""             "wms_server_version"    "1.1.1"         END         CLASS             NAME "states-provinces"             STYLE                 COLOR 255 90 90             END         END     END         LAYER         NAME "50m-admin-0-countries"         CONNECTIONTYPE OGR         CONNECTION "C:/Travail/spatialite/NaturalEarth/NaturalEarth.sqlite"  # full path to SQLite db file         DATA "50m-admin-0-countries"         TYPE polygon         PROJECTION             "init=epsg:4326"         END         METADATA             "wms_name"              "50m-admin-0-countries"             "wms_title"             "50m-admin-0-countries"             "wms_keywordlist"       ""             "wms_server_version"    "1.1.1"             "wms_extent"            "-180 -90 180 90"         END         CLASS             NAME "states-provinces"             STYLE                 COLOR 255 190 190             END         END     END      LAYER         NAME "50m-geography-marine-polys"         CONNECTIONTYPE OGR         CONNECTION "C:/Travail/spatialite/NaturalEarth/NaturalEarth.sqlite"  # full path to SQLite db file         DATA "50m-geography-marine-polys"          TYPE polygon         PROJECTION             "init=epsg:4326"         END         METADATA             "wms_name"              "50m-geography-marine-polys"             "wms_title"             "50m-geography-marine-polys"             "wms_keywordlist"       ""             "wms_server_version"    "1.1.1"             "wms_extent"            "-180 -90 180 90"         END         CLASS             NAME "states-provinces"             STYLE                 COLOR 24 116 205             END         END     END  END 

How to produce 8bits AGG homemade colors palette with Mapserver

The format of the output image affects the quality and size of the image to be transferred to the client on the web. We are always trying to minimize the size without losing image quality. With Mapserver, we can use the format AGG (24bit or 32bit PNG) of high quality although it's also a format that produces larger image size(in Kb). But, it's possible to force Mapserver to produce images of excellent qualities AGG 8bit format. The default image format output in Mapserver is 8bit PNG format (256 colors). To test a 24bits or 32bits format, you must overwrite the default format in your mapfile with this in your MAP tag. OUTPUTFORMAT    NAME "png"    MIMETYPE "image/png"    DRIVER "GD/PNG"    EXTENSION "png"    #--IMAGEMODE RGB #-- Driver PNG 24bit    IMAGEMODE RGBA #-- Driver PNG 32bit    TRANSPARENT ON END The default AGG format in Mapserver is a 24bits driver but you can use a 8bits driver. This type of driver in your mapfile will cause a slower performence of Mapserver. You can specify a predefined colors palette to improved performance and get accurate colors of your map. To build your homemade colors palette, you have first to produce a 8bits AGG image by mapserver with this driver in your mapfile: OUTPUTFORMAT    NAME "png8bitaggauto"    DRIVER "AGG/PNG"    MIMETYPE "image/png"    IMAGEMODE "pc256"    EXTENSION "png"    FORMATOPTION "TRANSPARENT=ON"    FORMATOPTION "INTERLACE=OFF"    FORMATOPTION "QUANTIZE_FORCE=ON"    FORMATOPTION "QUANTIZE_COLORS=256" END I suggest to produce more than just one image. Get images from multiple scales and different sectors of your WMS to get every colors. After, build a mosaic all images with an imaging tool like Microsoft Paint or Gymp. Finally, use gdalinfo to get your palette colors and paste them in a ASCII file. To use your new palette colors and realy improve your Mapserver AGG image output, add this driver specification in your mapfile(in MAP tag) #-- Driver AGG 8bits OUTPUTFORMAT    NAME "png8bitsagg"    DRIVER "AGG/PNG"    MIMETYPE "image/png"    IMAGEMODE "rgba"    EXTENSION "png"    FORMATOPTION "TRANSPARENT=ON"    FORMATOPTION "PALETTE_FORCE=TRUE"    FORMATOPTION "PALETTE=E:ms4wpalpal_agg256.txt"    FORMATOPTION "INTERLACE=OFF" END

GDAL/OGR 1.7.0 beta2 for testing

A new released of GDAL is now packaged for testing.   Major issue is:
* New GDAL drivers : BAG, EPSILON, Northwood/VerticalMapper, R, Rasterlite,
                     SAGA GIS Binary, SRP (USRP/ASRP), EarthWatch .TIL, WKT Raster
* GDAL PCIDSK driver using the nw PCIDSK SDK by default
* New OGR drivers : DXF, GeoRSS, GTM, PCIDSK and VFK
* New utility : gdaldem, gdalbuildvrt now compiled by default
* Add support for Python 3.X. Compatibility with Python 2.X preserved (#3265)
* Remove old-generation Python bindings.
* Significantly improved GDAL drivers: GeoRaster, GeoTIFF, HFA, JPEG2000 Jasper,
                                       JPEG2000 Kakadu, NITF
* Significantly improved OGR drivers: CSV, KML, SQLite (SpatiaLite support), VRT
The complet list of bug fix,  general change and notes are here: http://svn.osgeo.org/gdal/trunk/gdal/NEWS Feedback as tickets or otherwise is welcome on GDAL/OGR Tracker and Wiki web site.  Official released(1.7.0) is wish before the end of the month. Update january 20, 2010 First Release candidate 1.7.0 RC1 http://download.osgeo.org/gdal/gdal-1.7.0RC1.tar.gz http://download.osgeo.org/gdal/gdal170RC1.zip