4

I'm working with mapfile. I defined new layer "contours" and I want to render with maxscale = 100000 and minscale = 50000 contours with value distance of 50. That means that I want in that scale render only those countours with values of "height" attribute of 0, 50, 100, 150, 200, 250, 300, 350.. etc.

LAYER
 NAME "contours"
 TYPE line
 STATUS off
 DATA "contours.shp"

 CLASS
   NAME "all_contours"
   STYLE
     COLOR 176 226 255
   END

  #Is this CLASS I started creating correct? 

   CLASS
       NAME "main_contours"
       MAXSCALE 99000
       MINSCALE 50000
       EXPRESSION #this is my question

   END
END
  • What version of MapServer are you using? – geographika Jun 9 '11 at 21:18
  • I'm using MapServer 6.0. – againstflow Jun 9 '11 at 23:58
4

That should work using modulo:

EXPRESSION ( ([height] % 50) = 0 )
  • +1. Very clever solution. Also note the MAXSCALE and MINSCALE keyworks have been deprecated so use the MAXSCALEDENOM and MINSCALEDENOM instead. – geographika Jun 10 '11 at 7:40
  • Thank you. If I'm using older version of Mapserver, can I use the same expression or something different? – againstflow Jun 10 '11 at 12:12
  • Seems like MapServer 5 had a bug related to the modulo operator: osgeo-org.1803224.n2.nabble.com/… - so it depends on if it has been fixed in your version. – underdark Jun 10 '11 at 12:33
  • Is the modulo operator described in the MapServer expressions on the web page? – Philip Whitten Jun 15 '18 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.