[Mapserver-users] Labeling lines from OGR

Frank Warmerdam warmerdam at pobox.com
Wed Jan 21 11:41:51 EST 2004


Matthew Haines wrote:
> I have a .tab file which I am currently accessing through OGR.  It 
> contains lines like this:
> 
> OGRFeature(bklion):537
>  Street (String) = FT HAMILTON
>  FromLeft (Integer) = 105
>  ToLeft (Integer) = 107
>  FromRight (Integer) = 106
>  ToRight (Integer) = 110
>  ZipLeft (Integer) = 11209
>  ZipRight (Integer) = 11209
>  Style = PEN(w:1px,c:#c0c0c0,id:"mapinfo-pen-2.ogr-pen-0")
>  LINESTRING (976686.133 162407.387,976203.783 161682.929)
> 
> When I add them to my .map file as a layer the lines draw nicely.  
> However I can't get the street ('FT HAMILTON' in this example) to draw.  
> What is the minimal stuff I can put in my layer to get these labelled?  
> Below is my current layer.  I have tried it with the STYLEITEM removed 
> and also with the LABEL block removed, but no labels.

Matthew,

Daniel might have a more detailed response, but my take on this is that
the mapinfo file itself does not by default request a rendering of the
street names.  That is, there is no "LABEL" action in the Style string.
So, the STYLEITEM AUTO will just use the PEN information to draw the line
properly.

To do the labelling you will likely have to add another LAYER definition
in your .map file, coming from the same .tab file, but in this one use
normal MapServer mechanisms to draw labels along the line from the Street
attribute -- but don't use STYLEITEM AUTO.  I am not too up on the labelling
stuff, but you should be able to find info in the normal tutorials on this.

The key think to recognise is that the .tab autostyling information does not
include the labels, so it has to be handled in a seperate rendering pass
(that is ... as an additional layer).

Good luck,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the mapserver-users mailing list