Multiple Levels-Of-Detail

Dave Weaver dave.weaver at ZEN.CO.UK
Wed May 30 06:48:25 PDT 2007


I'm playing around with OpenLayers in conjuntion with MapServer.
What's the best way to have different levels of detail as I zoom in on my map?

At the moment I've done it like this:
My .map file has one layer per LOD, each using a MINSCALE/MAXSCALE directive
to determine when it's visible.

But that means I have multiple named layers, so the WMS request made by
OpenLayers needs to request all layers.

e.g: (mapfile)

  LAYER
    NAME         lod1
    STATUS       OFF
    TYPE         RASTER
    PROJECTION
      "init=epsg:4326"
    END
    MINSCALE 75000000
    METADATA
        "wms_title"     "lod1"
        "wms_onlineresource"
"http://example.com/cgi-bin/mapserv?map=map/earth.map&"
        "wms_srs"       "EPSG:4326 EPSG:54004"
    END
    TILEINDEX  "lod1.shp"
    TILEITEM   "location"
  END

  LAYER
    NAME         lod2
    STATUS       OFF
    TYPE         RASTER
    PROJECTION
      "init=epsg:4326"
    END
    MAXSCALE 74999999
    MINSCALE 50000000
    METADATA
        "wms_title"     "lod2"
        "wms_onlineresource"
"http://example.com/cgi-bin/mapserv?map=map/earth.map&"
        "wms_srs"       "EPSG:4326 EPSG:54004"
    END
    TILEINDEX  "lod2.shp"
    TILEITEM   "location"
  END

  # ... etc ...

then in the OpenLayers code:

  layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
		"http://example.com/cgi-bin/mapserv?map=map/earth2.map&", {layers:
'lod1,lod2,lod3,lod4,lod5'});

Is there a better way to handle multiple LODs ?

Many thanks,
Dave.



More information about the MapServer-users mailing list