0

I'm trying to display a text layer using MapServer, but I'm kind of confused how to get it to display properly.

When opening the .TAB file in a GIS application (in this case, MapInfo Profressional) the labels show up correctly. They all show up in the correct location with varying sizes and angles.

When looking at the output of MapServer for this layer, there are the following problems:

The layer is blank unless I set STYLEITEM "AUTO" for the layer. If I try to set the style manually, the settings seem to be ignored.

When displaying the layer using STYLEITEM "AUTO", all of the labels are rendered in the same font size and with no rotation.

Excerpt from the .map file is below (I've excluded other layers):

        MAP
        NAME    mymap
        IMAGETYPE   PNG
        EXTENT          259997 100002 399997 160002
        SIZE        550 450
        SHAPEPATH   "./"
        CONFIG "MS_ERRORFILE" "/var/log/mapserver/mymap_error.log"
    WEB
            LOG '/var/log/mapserver/mymap.log'
            METADATA
            WMS_TITLE   "My WMS Title"
            wms_srs     "EPSG:27700"
            wfs_srs     "EPSG:27700"
            wfs_title   "WFS Test"
            wfs_enable_request  "*"
            ows_enable_request  "*"
            wfs_onlineresource  "http://[AN IP]/maps/vectors/mymap&"
            ows_onlineresource  "http://[AN IP]/maps/vectors/mymap&"
            wfs_maxfeatures "50"
        END #METADATA
    END #WEB

    PROJECTION
        "init=epsg:27700"
    END #PROJECTION

LAYER
        NAME "Mastermap_Text"
        DEBUG 2
        METADATA
                "wfs_typename"          "Mastermap_Text"
                wfs_title               "Mastermap_Text"
                wfs_srs                 "EPSG:27700"
                gml_include_items       "all"
                gml_featureid           "PRN"
                wfs_enable_request      "*"
                ows_enable_request      "*"
        END #METADATA

        TYPE ANNOTATION
        STATUS OFF
        DUMP    TRUE
        CONNECTIONTYPE OGR
        CONNECTION "/path/to/maps/vectors/Mastermap_Text.tab"
        STYLEITEM "AUTO"

        PROJECTION
            "init=epsg:27700"
        END #PROJECTION

        CLASS
            NAME "Mastermap_Text"
        END #CLASS
END #LAYER

When trying to view this layer, I'm using an URL similar to:

http://[AN IP ADDRESS]/maps/vectors/mymap?LAYERS=Mastermap_Text&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A27700&BBOX=328800,146642,329680,147522&WIDTH=256&HEIGHT=256

As states, the above .map file results in an image of the text labels being generated, but they are all the same font size and they have no rotation.

If I remove the STYLEITEM "AUTO" line and add a STYLE block to the CLASS (with COLOR and SIZE attributes), I get a blank image.

Similarly, adding a LABEL block with the respective styles also doesn't help.

What am I doing wrong?

Edit to add images:

Mastermap_Text layer viewed using MapInfo Professional Mastermap_Text layer viewed using MapInfo Professional

Mastermap_Text layer rendered by MapServer when using the above URL Mastermap_Text layer rendered by MapServer when using the above URL

Mastermap_Text layer generated by shp2img: shp2img -m mymap.map -o test.png -l Mastermap_Text Mastermap_Text layer generated by shp2img

2

As Julien pointed out in a comment, you should make sure you have defined a valid FONTSET and reference one of its fonts in your layer. Indeed, the images you are showing are using BITMAP labels (which are the default if not overridden in the mapfile), which do not support rotation.

Here's a minimal set of keywords you might want to try:

map
 ...
 fontset "fonts.lst"  #make sure your fonts.lst file references an "arial" entry
 ...
 layer
  ...
  styleitem "auto"
  class
   ...
   label
    type truetype
    font "arial"
    ...
   end
  end
 end
end
  • You can determine the font specified by the MapInfo style using ogrinfo: ogrinfo -sql "select distinct ogr_style from Mastermap_Text" Mastermap_Text.tab Once you know which font is used add it to your font.list – walkermatt Dec 22 '15 at 15:17
0

It seems that this is a known bug, check here: http://osgeo-org.1560.x6.nabble.com/rotation-of-vector-symbol-td4246128.html

However, I think that you can show this problem with some images:

  1. coming from the above URL
  2. as result of

    shp2img -m your.map -o test.png

btw, what version do you have? upgrading may help you.

Hope this helps,

  • I've added images to the original question: The shp2img command obviously shows the entire map, not the small section that was being requested in the URL. As you can see, as the labels are all the same size they overlap a little bit... – user2889370 Oct 24 '13 at 11:44
  • Also, I'm using MapServer 6.0.3, so a slightly older version. I'll look into upgrading and see if that fixes it. – user2889370 Oct 24 '13 at 11:44
  • it's better now, so in MapInfo=oriented texts, MapServer=no orientation at all. Using ANGLE in LABEL (mapserver.org/mapfile/label.html) would help you? – Gery Oct 24 '13 at 12:04
  • I've tried adding LABEL ANGLE AUTO END inside the CLASS block, but it doesn't do anything. Similarly, if I use ANGLE 90 it doesn't do anything either. Presumably the STYLEITEM AUTO part is overriding anything I put into the CLASS block? – user2889370 Oct 24 '13 at 12:35
  • that one could be the reason, how about if you forget getting the orientation from mapinfo, and directly separate everything in the map file, so you assign indiviadually (by classes or layers I mean) the orientation to texts. Try a couple in this way and if it works just keep doing it in this way. It seems that mapserver doesn't understand what mapinfo/autocad/ect says regarding to orientation stuff (especially in autocad where those things are located in "columns"). – Gery Oct 24 '13 at 12:45

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.