[mapserver-users] display feature name beside feature

sunny74 sb.ray at hotmail.com
Mon Sep 21 08:34:13 EDT 2009


Hi Lars,

I have added the fontset file and also the Label and other definitions at
the appropriate places but still the Labels are not being displayed for the
layer RailwayStation.

My map file now looks like this:

# Map file created from QGIS project file D:/QGIS/newwr.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME newwr.map
  # Map image size
  SIZE 600 600
  UNITS dd

  EXTENT 67.440106 17.379867 78.390250 25.122977
  FONTSET 'c:/ms4w/Apache/cgi-bin/shape/fonts.txt'
  PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 192 192 192
  IMAGEQUALITY 95
  IMAGETYPE gif
  OUTPUTFORMAT
    NAME gif
    DRIVER 'GD/GIF'
    MIMETYPE 'image/gif'
    #IMAGEMODE PC256
    EXTENSION 'gif'
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'wms_title'           'newwr.map'
      'wms_onlineresource' 
'http://my.host.com/cgi-bin/mapserv?map=wms.map&'
      'wms_srs'             'EPSG:4326'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See
MapServer documentation
  END

  LAYER
    NAME 'STATE'
    TYPE POLYGON
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\STATE.shp'
    LABELITEM 'STATE'
    CLASSITEM 'STATE'
    METADATA
      'wms_title' 'STATE'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
   
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'STATE' 
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 255 255 127
       END
    END
  END

  LAYER
    GROUP 'basic1'
    NAME 'WaterBody'
    TYPE POLYGON
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\WaterBody.shp'
    METADATA
      'wms_title' 'WaterBody'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'WaterBody' 
       MAXSCALEDENOM 2000000
       MINSCALEDENOM 1500000
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 150 123 90
       END
    END
  END

  LAYER
    GROUP 'basic1'
    NAME 'Rail_Buffer'
    TYPE POLYGON
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\Rail_Buffer.shp'
    METADATA
      'wms_title' 'Rail_Buffer'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'Rail_Buffer'
       MAXSCALEDENOM 2000000
       MINSCALEDENOM 1500000
 
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 117 232 255
       END
    END
  END

  LAYER
    GROUP 'basic1'
    NAME 'Roads'
    TYPE LINE
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\Roads.shp'
    METADATA
      'wms_title' 'Roads'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'Roads'
       MAXSCALEDENOM 2000000
       MINSCALEDENOM 1500000
 
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 45 220 182
         COLOR 0 0 0
       END
    END
  END

  LAYER
    GROUP 'basic2'
    NAME 'Diversions'
    TYPE LINE
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\Diversions.shp'
    METADATA
      'wms_title' 'Diversions'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'Diversions'
       MAXSCALEDENOM 1500000
       MINSCALEDENOM 1000000
 
 
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 144 50 207
         COLOR 0 0 0
       END
    END
  END

  LAYER
    GROUP 'basic2'
    NAME 'Rail_Side_Line'
    TYPE LINE
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\Rail_Side_Line.shp'
    METADATA
      'wms_title' 'Rail_Side_Line'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'Rail_Side_Line'
       MAXSCALEDENOM 1500000
       MINSCALEDENOM 1000000
 
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 170 115 90
         COLOR 0 0 0
       END
    END
  END

  LAYER
    GROUP 'basic'
    NAME 'RailwayLine'
    TYPE LINE
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\RailwayLine.shp'
    
    METADATA
      'wms_title' 'RailwayLine'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'RailwayLine'
       
 
       STYLE
         SYMBOL 0 
         SIZE 2 
         OUTLINECOLOR 255 0 0
         COLOR 255 0 0
       END
    END
  END

  LAYER
    GROUP 'basic2'
    NAME 'LANDMARKS'
    TYPE POINT
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\LANDMARKS.shp'
    METADATA
      'wms_title' 'LANDMARKS'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'LANDMARKS' 
       MAXSCALEDENOM 1500000
       MINSCALEDENOM 1000000

       STYLE
         SYMBOL 'CIRCLE' 
         SIZE 8 
         OUTLINECOLOR 0 0 0
         COLOR 229 210 191
       END
    END
  END

  LAYER
    GROUP 'basic'
    NAME 'RailwayStations'
    TYPE POINT
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\RailwayStations.shp'
    CLASSITEM 'S_NAME'
    LABELITEM 'S_NAME'
    METADATA
      'wms_title' 'RailwayStations'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'RailwayStations' 
       STYLE
         SYMBOL 'CIRCLE' 
         SIZE 8 
         OUTLINECOLOR 0 0 0
         COLOR 255 0 0
       END
        LABEL
        COLOR 132 31 31
        SHADOWCOLOR 218 218 218
        SHADOWSIZE 2 2
        TYPE TRUETYPE
        FONT arial-bold  
        SIZE 12
        ANTIALIAS TRUE
        POSITION CL
        PARTIALS FALSE
        MINDISTANCE 300
        BUFFER 4
      END # end of label 
       
    END
    
  END

  LAYER
    GROUP 'basic3'
    NAME 'LC_Gate'
    TYPE POINT
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\LC_Gate.shp'
    METADATA
      'wms_title' 'LC_Gate'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'LC_Gate'
       MAXSCALEDENOM 1000000
       MINSCALEDENOM 500000
 
       STYLE
         SYMBOL 'CIRCLE' 
         SIZE 8 
         OUTLINECOLOR 0 0 0
         COLOR 15 155 200
       END
    END
  END

  LAYER
    GROUP 'basic3'
    NAME 'Bridges_Minor'
    TYPE POINT
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\Bridges_Minor.shp'
    METADATA
      'wms_title' 'Bridges_Minor'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'Bridges_Minor'
       MAXSCALEDENOM 1000000
       MINSCALEDENOM 500000
 
       STYLE
         SYMBOL 'CIRCLE' 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 43 253 114
       END
    END
  END

  LAYER
    GROUP 'basic3'
    NAME 'Bridge_Major'
    TYPE POINT
    DATA 'C:\ms4w\Apache\cgi-bin\Shape\Bridge_Major.shp'
    METADATA
      'wms_title' 'Bridge_Major'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    CLASS
       NAME 'Bridge_Major'
       MAXSCALEDENOM 1000000
       MINSCALEDENOM 500000
 
       STYLE
         SYMBOL 'CIRCLE' 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 97 136 146
       END
    END
  END

      #Circle symbol
      SYMBOL
        NAME 'CIRCLE'
        TYPE ellipse
        FILLED true
        POINTS
          1 1
        END
      END 
END

My Fontset file is fonts.txt and it is located in the same folder as the map
file.
It contains the following:

arial                           C:/WINDOWS/Fonts/arial.ttf
arial-bold                      C:/WINDOWS/Fonts/arialbd.ttf

So where is the problem?
Where am I going wrong?

Thanks for your reply.

sunny.

Lars Lingner-2 wrote:
> 
> sunny74 schrieb:
>> Hi Michael,
>> 
>> Thanks for your reply.
>> I had gone thru' the links you have given before making this post.But I
>> am
>> having the problems given in the link below:
>> 
>> http://n2.nabble.com/font-error-while-trying-to-show-Label-on-map-td3654455.html#a3654455
>> When using truetype I get the error probably bec' I am not able to
>> specify
>> the fontset file.
>> So I need to know the following:
>> 1) What kind of file is the fontset file?I think it is a text file
> 
> its just a textfile, yes
> 
>> 2) Where do I keep the fontset file - in the same folder as the map file
>> or
>> in different folder.If different folder how do I specify the path in the
>> map
>> file.
> 
> as you wish. You have to tell MapServer the place with the keywortd
> FONTSET.
> 
>> 3) Where do I keep the fonts? Is it okay if I keep it in the Windows Font
>> Folder i.e C:/Windows/Fonts
> 
> yes, you can keep it there. MapServer needs read permissions to the
> fonts. In the fonset file you can define the path.
> 
>> 4)How do I specify the path of the fonts in the fontset file?
>> 
> 
> /path/to/fonts/font.ttf
> 
> 
> Please have a look at
> 
> http://mapserver.org/mapfile/map.html
> and
> http://mapserver.org/mapfile/fontset.html
> 
> 
> Lars
> 
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/display-feature-name-beside-feature-tp3668538p3684929.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list