Implementing Scale-Dependent Styles in a WMS Server

Gregor Mosheh gregor at HOSTGIS.COM
Thu Jul 26 10:53:15 EDT 2007


Bill Thoen wrote:
> For example, I've got a US Interstates layer that has been 
> thinned so that it is appropriate for scales smaller than 1:10,000,000, 
> and I've got another one that I'd use at larger scales (but from 
> 1:10,000,000 to 1:5,000,000 I want to use one style and for scales 
> between 1:5,000,000 and 1:1,000,000 I want to use another style on this 
> layer).

How I'd do it, and I'd love to hear other methods/opinions...

Set up multiple layers, and give them all the same GROUP. In case you're 
not familiar with it, a group defines a "virtual multi-layer layer" and 
the WMS client would get all of those layers together when it requests 
the one layer.

Then, define your multiple layers to each use appropriate MINSCALE and 
MAXSCALE.

e.g

LAYER
   GROUP "roads"
   NAME "allstreets"
   MAXSCALE 100000
END
LAYER
   GROUP "roads"
   NAME "countyroads"
   MINSCALE 100001
   MAXSCALE 1999999
END
LAYER
   GROUP "roads"
   NAME "highways"
   MINSCALE 2000000
END

Ta-da, now the "roads layer" will automagically change with the scale.

Hope that helps.

-- 
Gregor Mosheh / Greg Allensworth
System Administrator, HostGIS cartographic development & hosting services
http://www.HostGIS.com/

"Remember that no one cares if you can back up,
  only if you can restore." - AMANDA



More information about the mapserver-users mailing list