iLast Update: 2004/04/15j
Japanese

New Function of MapServer i18n Version



1. Mapfile

The patch does is that it creates a new MAPFILE LABEL item, named "ENCODING", that can be used to convert strings from its original encoding system into one that can be understood by the True Type Fonts.
The "ENCODING" item accepts the encoding system as its parameter.


This 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.

ne 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.
A sample Mapfile can look like this:

LAYER
NAME "chimei"
DATA chimei
STATUS DEFAULT
TYPE POINT

LABELITEM "NAMAE"

CLASS
NAME "CHIMEI"
COLOR 10 100 100
LABEL
TYPE TRUETYPE
FONT kochi-gothic
COLOR 220 20 20
SIZE 10
POSITION CL
PARTIALS FALSE
BUFFER 0

ENCODING SJIS

END
END
END

LAYER
NAME "chimeipg"

CONNECTION "user=username password=password dbname=gis host=localhost port=5432"
CONNECTIONTYPE postgis
DATA "the_geom from chimei"
STATUS DEFAULT
TYPE POINT

LABELITEM "NAMAE"

CLASS
NAME "CHIMEI PG"
COLOR 10 100 100
LABEL
TYPE TRUETYPE
FONT kochi-mincho
COLOR 20 220 20
SIZE 10
POSITION CL
PARTIALS FALSE
BUFFER 0

ENCODING EUC-JP

END
END
END

This patch was tested using the different Japanese encoding system, Shift-JIS, EUC-JP, UTF-8, as well as Thai's TIS-620 encoding system.


2. PHP-Mapscript

For PHP-Mapscript, the "Encoding" attribute is added into the LabelObj Class, so that the encoding parameter of a layer can be modified.


// Loading the php_mapscript library
dl("php_mapscript.so");

// Loading the map file
$map = ms_newMapObj("example.map");

// get the desired layer
$layer = $map->getLayerByName("chimei");

// get the layer's class object
$class = $layer->getClass(0);

// get the class object's label object
$clabel= $class->label;

// get encoding parameter
$encode_str = $clabel->encoding;
print "Encoding = ".$encode_str."\n";

// set encoding parameter
$clabel->set("encoding","UTF-8");



LabelObj Class:
---------------

Constructor:

LabelObj are always embedded inside other classes.

Members:

string font
string encoding
int type
colorObj color
colorObj outlinecolor
colorObj shadowcolor
int shadowsizex
int shadowsizey
colorObj backgroundcolor
colorObj backgroundshadowcolor
int backgroundshadowsizex
int backgroundshadowsizey
int size
int minsize
int maxsize
int position
int offsetx
int offsety
double angle
int autoangle
int buffer
int antialias
int wrap
int minfeaturesize
int autominfeaturesize
int mindistance
int partials
int force

Methods:

int set(string property_name, new_value)
Set object property to a new value. Returns -1 on error.


License
Copyright (c) 1996-2003 Regents of the University of Minnesota.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies of this Software or works derived from this Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



Mapserver i18n Project Members:
Venkatesh Raghavan, Masumoto Shinji, Nonogaki Susumu, Nemoto Tatsuya, Hirai Naoki (Osaka City University, Japan),
Mario Basa, Hagiwara Akira, Niwa Makoto, Mori Toru (Orkney Inc., Japan),
Hattori Norihiro (E-Solution Service, Inc., Japan)


Sponsored by:
IPA (Information-technology Promotion Agency, Japan)