[ka-Map-users] Repeated labels on a polygon layer

Paul Spencer pspencer at dmsolutions.ca
Wed May 31 16:26:23 EDT 2006


David,

this is a side-effect of creating tiles.  The issue is that mapserver  
has no way to deterministically place labels on tiles or to retain  
some knowledge that a label was already placed on an adjacent tile.

We try to work around this as best as possible by rendering a 'meta- 
tile' which is essentially a much larger map draw which is then  
sliced into smaller tiles that are actually served to the client.   
This just reduces the number of times the problem occurs, it doesn't  
eliminate it.

The only advice I have right now is to try increasing the size of the  
meta tile that you are creating.  You do this by modifying config.php  
and changing the metaWidth and metaHeight variables.

You need to be careful that the number of tiles wide/high times the  
size of each tile does not exceed mapserver's compiled-in limit for a  
single map draw (typically 2000x2000 I think).

Also, you need to be aware that larger map draws take more time.  If  
you are in a position to compile mapserver and change this limit (or  
can find someone to do it for you) and/or are willing to spend time  
pre-generating maps, then the best-case solution right now is to jack  
up the sizes to some large numbers and pre-generate all the tiles.

I am not aware of any effort to help out label placement for tiled  
viewers, nor of any decent way of addressing the problem in mapserver.

Actually, there is one way you could do it I think, which would be to  
pre-process all your labels into a separate point shape file with  
attributes.  I'm not a gis guy, but I think this must be possible  
(although you may need something commercial to do it).

It may be more possible to write a utility for mapserver to do this  
by walking through every layer with labels and getting each feature  
(and the extents of the feature) and having mapserver return the  
location that it would render the label at if the entire feature were  
visible, then storing that location and associated text in a separate  
shape file.  This would work for static data, but not for dynamic  
data unfortunately.

Perhaps something like this could be used in mapserver itself when  
labeling?

Cheers

Paul

On 31-May-06, at 3:09 PM, David Badke wrote:

> I have a map with two polygon layers. Two other annotation layers  
> label the polygons. This all works, except that the labels repeat -  
> each polygon has the same label, in different places, two or more  
> times. In some cases one of the repeated labels isn't even on the  
> polygon, and none of the labels are where I wanted them (POSITION  
> UL). I have tried changing the annotation layers to point or  
> polygon layers - doesn't help. The layer data is all in shapefiles  
> (except the base layer).
>
> So is this a ka-Map problem, a MapServer problem, a data problem,  
> my problem, or what? Anyone have any idea how to make it stop doing  
> this?
>
> You can see an example at
>
>         http://vihistory-dev.uvic.ca/maps/htdocs/index.php? 
> map=vicstreet1902
>
> Zoom in to 50% (the middle block in the zoom widget).
>
> The  map file for this is:
>
> MAP
>  NAME "vicstreet1902"
>  STATUS ON
>  EXTENT 0 -7452 7334 0
>  SIZE 7334 7452
>  SHAPEPATH "/workspace/imap/user/data/"
>  IMAGETYPE PNG
>  IMAGECOLOR 156 170 177
>  UNITS INCHES
>  FONTSET "/workspace/imap/user/font/fontset.fnt"
>  SYMBOLSET "/workspace/imap/user/symbol/generic.sym"
>  REFERENCE
>    STATUS ON
>    IMAGE "/workspace/imap/user/data/vicstreet1902key.png"
>    SIZE 300 305
>    EXTENT 0 -7452 7334 0
>    COLOR 255 255 255
>    OUTLINECOLOR 255 0 0
>  END
>  SCALEBAR
>    STATUS OFF
>  END
>  WEB
>    METADATA
>      "version" "55"
>    END
>  END
>  LAYER
>    NAME "Base"
>    GROUP "Base"
>    TYPE RASTER
>    STATUS ON
>    DATA "vicstreet1902.png"
>    METADATA
>      queryable "true"
>    END
>  END
>  LAYER
>    NAME "Districts"
>    GROUP "Districts"
>    TYPE POLYGON
>    STATUS ON
>    DATA "vicstreet1901district"
>    METADATA
>      queryable "true"
>      opacity "30"
>    END
>    MAXSCALE 765
>    SYMBOLSCALE 77
>    CLASS
>      STYLE
>        COLOR 102 204 204
>        OUTLINECOLOR 0 0 0
>      END
>    END
>  END
>  LAYER
>    NAME "Lots"
>    GROUP "Lots"
>    TYPE POLYGON
>    STATUS ON
>    DATA "vicstreet1901lot"
>    METADATA
>      queryable "true"
>      opacity "30"
>    END
>    MAXSCALE 765
>    SYMBOLSCALE 77
>    CLASS
>      STYLE
>        COLOR 255 255 51
>        OUTLINECOLOR 255 255 0
>      END
>    END
>  END
>  LAYER
>    NAME "District Labels"
>    GROUP "District Labels"
>    TYPE ANNOTATION
>    STATUS ON
>    DATA "vicstreet1901district"
>    METADATA
>      queryable "true"
>    END
>    LABELITEM "LABEL"
>    MAXSCALE 192
>    MINSCALE 76
>    SYMBOLSCALE 77
>    CLASS
>      LABEL
>        TYPE TRUETYPE
>        FONT "arial-bold-italic"
>        ANTIALIAS TRUE
>        SIZE 14
>        MINSIZE 12
>        MAXSIZE 16
>        POSITION UL
>        OFFSET 0 0
>        COLOR 0 0 0
>        BACKGROUNDCOLOR 255 255 255
>        BUFFER 1
>      END
>    END
>  END
>  LAYER
>    NAME "Lot Labels"
>    GROUP "Lot Labels"
>    TYPE ANNOTATION
>    STATUS ON
>    DATA "vicstreet1901lot"
>    METADATA
>      queryable "true"
>    END
>    LABELITEM "LABEL"
>    MAXSCALE 154
>    MINSCALE 76
>    SYMBOLSCALE 77
>    CLASS
>      LABEL
>        TYPE TRUETYPE
>        FONT "arial"
>        ANTIALIAS FALSE
>        SIZE 9
>        MINSIZE 8
>        MAXSIZE 10
>        POSITION UL
>        OFFSET 0 0
>        COLOR 255 153 0
>        BACKGROUNDCOLOR 255 255 255
>        BUFFER 1
>      END
>    END
>  END
> END
>
>
>
> -- 
>
> David Badke
> Humanities Computing and Media Center
> University of Victoria, BC, Canada
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users

+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+






More information about the ka-Map-users mailing list