[mapserver-users] Slow mapfile

Steven M. Ottens steven at minst.net
Fri Nov 30 02:16:58 PST 2012


Hi all,

I'm having troubles generating tiles with mapserver, they take up to 
half an hour per tile (256x256pixels).
The data is stored as a series of 32bit float GeoTIFFs, internally tiled 
with gdal and provided in four different levels (5meter, 25meter, 
100meter and overview) as a series of files in separate directories 
which are indexed with gdaltindex.

The data is a detailed height model of the Netherlands with a vertical 
resolution of 1cm - this way the Netherlands doesn't look so flat ;). I 
need to encode this data into a specially crafted PNG to be able to do 
dynamic classification in the browser. This means that for the range 
-12m to 350m I want each centimetre as a different colour. I end up with 
36200 classes and a mapserver which is working for half an hour on 100% 
on a 2.6GHZ Quad-Xeon server with 8GB RAM, Ubuntu 12.04, gdal 1.9.2 and 
mapserver 6.2.0.
The tiles are created by TileCache 2.11 and a tileseed.py run on the 
same server and the data is in the same projection as the tiles.

I'm aware that 36200 classes are a lot, but I do need the 36200 values 
encoded in my PNG-tiles. Currently I use an include to include the 
classification for the different layers, since the classification alone 
is almost 3MB.
Any suggestions on how to improve the render-speed, either in data 
preparation, the mapfile or a different approach all together?

Regards,
Steven

Snippet of the included class.map:
CLASSITEM "[pixel]"
         CLASS EXPRESSION ( [pixel] < -11.99 ) COLOR 0 0 0 END
         CLASS EXPRESSION ( [pixel] >= -11.99 AND [pixel] < -11.98 ) 
COLOR 0 0 1 END
###36000+ more classes###
         CLASS EXPRESSION ( [pixel] >= 349.99 AND [pixel] < 350 ) COLOR 
0 141 103 END
         CLASS EXPRESSION ( [pixel] >= 350 ) COLOR 0 141 104 END

The main mapfile:

MAP
   EXTENT 10000 305000 280000 619000
   UNITS METERS
   NAME "AHN hoogtes"
     SHAPEPATH "/var/data/hoogte/nederland"

   PROJECTION
     "init=epsg:28992"
   END

   LEGEND
     IMAGECOLOR 255 255 255
     KEYSIZE 18 12
     KEYSPACING 5 5
     LABEL
       ANTIALIAS TRUE
       SIZE 9
       TYPE TRUETYPE
       FONT "Arial"
       BUFFER 0
       COLOR 0 0 89
       FORCE FALSE
       MINDISTANCE -1
       MINFEATURESIZE -1
       OFFSET 0 0
       PARTIALS TRUE
     END
     POSITION UR
     STATUS ON
     TRANSPARENT TRUE
   END #legend

   QUERYMAP
     COLOR 255 0 0
     SIZE -1 -1
     STATUS OFF
     STYLE HILITE
   END #querymap

   DEBUG 0

   WEB
     # Path to the temporary directory fro writing temporary files and 
images.
     # Must be writable by the user the web server is running as.
     # Must end with a / or \ depending on your platform.
     IMAGEPATH "/tmp"
     # Base URL for IMAGEPATH. This is the URL that will take the web 
browser to
     # IMAGEPATH to get the images.
     IMAGEURL "/tmp/"
     MAXSCALE 30000000
     MINSCALE 1000
     METADATA
       WMS_TITLE "Algemeen Hoogtebestand Nederland"
       WMS_ABSTRACT "Algemeen Hoogtebestand Nederland"
       WMS_ONLINERESOURCE 
"http://localhost/cgi-bin/mapserv?map=maps/hoogte.map"
       WMS_SRS "EPSG:28992"
       WMS_ENABLE_REQUEST "*"
     END
   END # web

   OUTPUTFORMAT
     NAME png
     DRIVER "GD/PNG"
     MIMETYPE "image/png"
     IMAGEMODE PC256
     EXTENSION "png"
   END # outputformat

     LAYER
     GROUP "ahn2"
     NAME "ahn2_max"
     METADATA
      WMS_TITLE "Hoogte Max Res"
      WMS_ABSTRACT "Hoogte Max Res"
      WMS_NAME "Hoogte Max Res"
      WMS_SRS "EPSG:28992"
      WFS_TITLE "Hoogte Max Res"
      WMS_GROUP_TITLE   "hoogte"
     END
     PROJECTION
      "init=epsg:28992"
     END

     DATA "ahn2-2012/overview.tif"
     STATUS ON
     DEBUG 0
     TEMPLATE "blank.html"
     TYPE RASTER
     UNITS METERS
       PROCESSING "SCALE=-12,350"
        PROCESSING "SCALE_BUCKETS=36200"
        MINSCALE 500000
        MAXSCALE 30000000

INCLUDE "class.map"
   END # layer ahn2

  LAYER
     GROUP "ahn2"
     NAME "ahn2_100m"
     METADATA
       WMS_TITLE "Hoogte 100m"
       WMS_ABSTRACT "Hoogte 100m"
       WMS_NAME "Hoogte 100m"
       WMS_SRS "EPSG:28992"
       WFS_TITLE "Hoogte 100m"
       gml_include_items "value_0"
       gml_value_0_alias "hoogte"
       WMS_GROUP_TITLE   "hoogte"

       "wcs_label"           "Hoogte 100m"  ### required
       "wcs_rangeset_name"   "Hoogte 100m (rangeset name)"               
### required to support DescribeCoverage request
       "wcs_rangeset_label"  "Hoogte 100m (rangeset label)"              
### required to support DescribeCoverage request
     END
     PROJECTION
      "init=epsg:28992"
     END
     TILEINDEX iahn2_raster100_index
     TILEITEM "location"
     STATUS ON
     DEBUG 0
     TEMPLATE "blank.html"
     TYPE RASTER
     UNITS METERS
     PROCESSING "SCALE=-12,350"
        PROCESSING "SCALE_BUCKETS=36200"
        MINSCALE 150000
        MAXSCALE 500000
         INCLUDE "class.map"
   END # layer ahn2

   LAYER
     GROUP "ahn2"
     NAME "ahn2_25m"
     METADATA
       WMS_TITLE "Hoogte 25m"
       WMS_ABSTRACT "Hoogte 25m"
       WMS_NAME "Hoogte 25m"
       WMS_SRS "EPSG:28992"
       WFS_TITLE "Hoogte 25m"
       gml_include_items "value_0"
       gml_value_0_alias "hoogte"
       WMS_GROUP_TITLE   "hoogte"

       "wcs_label"           "Hoogte 25m"  ### required
       "wcs_rangeset_name"   "Hoogte 25m (rangeset name)"               
### required to support DescribeCoverage request
       "wcs_rangeset_label"  "Hoogte 25m (rangeset label)"              
### required to support DescribeCoverage request
     END
     PROJECTION
      "init=epsg:28992"
     END
     TILEINDEX iahn2_raster25_index
     TILEITEM "location"
     STATUS ON
     DEBUG 0
     TEMPLATE "blank.html"
     TYPE RASTER
     UNITS METERS
    PROCESSING "SCALE=-12,350"
        PROCESSING "SCALE_BUCKETS=36200"
        MINSCALE 30000
        MAXSCALE 150000
INCLUDE "class.map"

   END # layer ahn2

  LAYER
     GROUP "ahn2"
     NAME "ahn2_5m"
     METADATA
       WMS_TITLE "Hoogte 5m"
       WMS_GROUP_TITLE "hoogte"
       WMS_NAME "Hoogte 5m"
       WMS_ABSTRACT "Hoogte 5m"
       WMS_SRS "EPSG:28992"

       WFS_TITLE "Hoogte 5m"
       gml_include_items "value_0"
       gml_value_0_alias "hoogte"

       "ows_srs" "EPSG:28992"

     END
     PROJECTION
       "init=epsg:28992"
     END
     TILEINDEX iahn2_raster5_index
     TILEITEM "Location"
     STATUS ON
     DEBUG 0
     TEMPLATE "blank.html"
     TYPE RASTER
     UNITS METERS
     PROCESSING "SCALE=-12,350"
        PROCESSING "SCALE_BUCKETS=36200"
     MINSCALE 1000
     MAXSCALE 30000
INCLUDE "class.map"
   END # layer ahn2

END #map




More information about the mapserver-users mailing list