Changes between Initial Version and Version 1 of LabelEncoding


Ignore:
Timestamp:
Aug 10, 2010, 12:30:45 PM (14 years ago)
Author:
jmckenna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LabelEncoding

    v1 v1  
     1= Display of International Characters in !MapServer Labels =
     2
     3== Credit ==
     4
     5The following functionality was added to !MapServer 4.4.0 as a part of a project sponsored by the Information-technology Promotion Agency (IPA), in Japan.  Project members included: Venkatesh Raghavan, Masumoto Shinji, Nonogaki Susumu, Nemoto Tatsuya, Hirai Naoki (Osaka City University, Japan),
     6Mario Basa, Hagiwara Akira, Niwa Makoto, Mori Toru (Orkney Inc., Japan),
     7and Hattori Norihiro (E-Solution Service, Inc., Japan).
     8
     9== Related Links ==
     10
     11* !MapServer ticket:858
     12
     13== Requirements ==
     14
     15 * !MapServer >= 4.4.0
     16 * !MapServer compiled with the libiconv library
     17
     18== Description ==
     19
     20A MAPFILE LABEL parameter, named ''ENCODING'', can be used to convert strings from its original encoding system into one that can be understood by the True Type Fonts.
     21The ''ENCODING'' parameter accepts the encoding system as its parameter.
     22
     23This uses GNU's libiconv ( http://www.gnu.org/software/libiconv/ ) so theoretically, every string with an encoding system supported by libiconv can be displayed as labels in MapServer as long as it has a matching font-set.
     24
     25== Step 1: Verify ICONV Support and MapServer Version ==
     26
     27Execute ''mapserv -v' at the commandline, and verify that your MapServer version >= 4.4.0 and it includes ''SUPPORTS=ICONV'', such as:
     28
     29{{{
     30   > mapserv -v
     31
     32     MapServer version 5.6.5 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG
     33     SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER
     34     SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER
     35     SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=RGBA_PNG SUPPORTS=TILECACHE INPUT=JPEG
     36     INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
     37}}}
     38
     39== Step 2: Verify That Your Files' Encoding is Supported by ICONV ==
     40
     41Since !MapServer uses the libiconv library to handle encodings, you can check the list of supported encodings here: http://www.gnu.org/software/libiconv/
     42
     43Unix users can also use the ''iconv -l'' command on a system with
     44libiconv installed to get the complete list of supported encodings on
     45that specific system.
     46
     47== Step 3: Add ENCODING Parameter to your LABEL Object ==
     48
     49Now you can simply add the ENCODING parameter to your mapfile LAYER object, such as:
     50
     51{{{
     52  MAP
     53   ...
     54   LAYER
     55     ...
     56     CLASS
     57       ...
     58       LABEL
     59         ...
     60         ENCODING "SHIFT_JIS"
     61       END
     62     END
     63   END
     64  END
     65}}}
     66
     67One of the benefits of having an "ENCODING" parameter within the LABEL object is that different LAYERS with different encoding systems can be combined together and display labels within a single map.  For example, labels from a Layer using Shapefile as it source which contains attributes in SHIFT-JIS can be combined with a Layer from a PostGIS database server with EUC-JP attributes.
     68A sample Mapfile can look like this:
     69
     70{{{
     71  LAYER
     72    NAME "chimei"
     73    DATA chimei
     74    STATUS DEFAULT
     75    TYPE POINT
     76    LABELITEM "NAMAE"
     77    CLASS
     78      NAME "CHIMEI"
     79      STYLE
     80        COLOR 10 100 100
     81      END
     82      LABEL
     83        TYPE TRUETYPE
     84        FONT kochi-gothic
     85        COLOR 220 20 20
     86        SIZE 10
     87        POSITION CL
     88        PARTIALS FALSE
     89        BUFFER 0
     90        ENCODING SJIS
     91      END
     92    END
     93  END
     94
     95  LAYER
     96    NAME "chimeipg"
     97    CONNECTION "user=username password=password dbname=gis host=localhost port=5432"
     98    CONNECTIONTYPE postgis
     99    DATA "the_geom from chimei"
     100    STATUS DEFAULT
     101    TYPE POINT
     102    LABELITEM "NAMAE"
     103    CLASS
     104      NAME "CHIMEI PG"
     105      STYLE
     106        COLOR 10 100 100
     107      END
     108      LABEL
     109        TYPE TRUETYPE
     110        FONT kochi-mincho
     111        COLOR 20 220 20
     112        SIZE 10
     113        POSITION CL
     114        PARTIALS FALSE
     115        BUFFER 0
     116        ENCODING EUC-JP
     117      END
     118    END
     119  END
     120
     121== Step 4: Test with the shp2img utility ==
     122
     123 * see http://mapserver.org/utilities/shp2img.html