[Mapserver-dev] polygon outlines with classified layers

Daniel Morissette morissette at dmsolutions.ca
Wed Nov 26 15:57:00 EST 2003

Bart van den Eijnden wrote:
> If I have 2 classes in my LAYER, what determines whether or not the 
> outline of a polygon is drawn? So I mean 1 class with outline color 
> (class A), and another one without outlinecolor (class B). 

It's really the class expression that determines which class is being 
used. If an object matches class A then it is drawn with a fill and an 
outline, otherwise it ends up in class B (assuming the expression 
matches) and is drawn with no outline.

Classes really work like a switch/case statement in C, PHP and most 
languages. MapServer loops through the shapefile, and for each shape it 
tries to match it to a class. The first class that matches is used to 
draw the shape and we're back to the beginning of the loop.

> I see in my 
> map that some parts of the border of class A adjacent to a class B 
> polygon are drawn with an outline/border, and other parts are not. This 
> can also be seen in this image which contains more than 2 classes:
> http://www.vz.geodan.nl/users/bart/mapserver.png

I think it may have something to do with the order in which your shapes 
are read.  If a class B polygon is drawn *after* an adjacent class A 
polygon then it's possible that part (or all) of the outline border of 
the class A polygon could be erased by the fill color of the class B 

If you don't want any class B polygon to erase the border of adjacent 
class A polygons then you could use separate layers for class A and 
class B so that class A is drawn *after* class B. You may also want to 
consider sorting your shapefile so that all class B polygons come before 
the class A polygons in the shapefile (I've never done that, but I think 
there is a shpsort utility that comes with MapServer)

> Also is it possible, to only draw an outline when there is a 
> border/transition between two classes? If I put on outline in all of my 
> classes I have the problem that adjacent polygons which belong to the 
> same class are drawn with an outline in between. In an ideal situation I 
> would want only to have outline when there is a transition of classes.

Um... I can't think of a way to do that right now. You would almost need 
to pre-merge your polygons.

Well... maybe there is something you could do, but that's really a hack 
and may not work very well, you would need two layers:

1- First draw all your polygons as a line layer with a thickness of 2-3 

2- Then use a second layer to draw all your polygons again but with no 
outline this time.  This will have the effect of erasing the common 
borders and will erase only the 50% of the width of the outer borders.

  Daniel Morissette               morissette at dmsolutions.ca
  DM Solutions Group              http://www.dmsolutions.ca/

More information about the mapserver-dev mailing list