[Mapserver-users] maxcount of characters in a line

Katarina Kobesova katarina.kobesova at chello.at
Sun Jan 5 07:47:17 PST 2003


This is a multi-part message in MIME format.

------=_NextPart_000_0018_01C2B4DA.1B953A30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello together !

I have a simple question:
how I can force a line break in a label ?
(comparable <br>in HTML).=20

Some code:
Mapfile:

LAYER #start of layer
   NAME "apotheken"
   DATA apotheken
   STATUS ON
   TYPE POINT
   CLASSITEM "FIRMA"
   CLASS
      NAME "Apotheken"   #in the legend
#EXPRESSION, SYMBOL and TEXT are in a phpfile defined
      LABEL   #important for TEXT
         TYPE TRUETYPE
         FONT Verdana
         POSITION UC
         WRAP '-'
         BUFFER 10
         SIZE 7
      END
   END
END #end of layer object

phpfile:

<?php
include_once("dbase_gis.inc");
$map_path =3D "ms_tmp/";
$raster_dir =3D "wigeomap10000";
$map_file =3D "wien.map";
$map =3D ms_newMapObj($map_path . $map_file);


reset($_SESSION);

/***** Class for Symbols is here defined *****/
if($_SESSION["s_shape"] =3D=3D "apotheke") {
   $layer =3D $map->getLayerByName("apotheken");
} else
if($_SESSION["s_shape"] =3D=3D "spital") {
   $layer =3D $map->getLayerByName("spitaele");
}

$result_class =3D $layer->getClass(0);
/***** Class f=FCr Symbole definieren *****/

//1. all Locations
$m =3D new ResultMap();   #defined in an=20
while(list($key, $value) =3D each($_SESSION)) {
   if(substr($key, 0,3) =3D=3D "loc") {
      $m->addLocationToShape($value);
      $expr .=3D  $value->getFirma() . "|";
   }
}

//2. from-values (start position - home - only a point)
$m->addXYToShape($_SESSION["s_fromx"], $_SESSION["s_fromy"]);

//3. perhaps to-values (start position - for example a line, not a =
point)
if($_SESSION["s_tox"] && $_SESSION["s_toy"]) {
   $m->addXYToShape($_SESSION["s_tox"], $_SESSION["s_toy"]);
}

/*****!!! relevant ****/
/*********** symbol with a label (TEXT) *******/
$expr =3D substr($expr, 0, strlen($expr)-1);  //das letze "|" entfernen
$expr =3D "/(" . $expr . ")/";
$result_class->setexpression($expr);
$result_class->set("symbol", 4);
$result_class->settext($layer, "([FIRMA], [STRASSE], [HNR], [PLZ])");
/*********** symbol with a label (TEXT) *******/
/*****!!! relevant ****/

/********** draw a map *****/
$extent =3D $m->getMapExtent();
$map->setextent($extent->minx, $extent->miny, $extent->maxx, =
$extent->maxy);
$image =3D $map->draw();
$image_url =3D $image->saveWebImage(MS_PNG, 1, 1, 0);
/********** draw a map *****/
?>

<input class=3D"image" type=3D"image" src=3D"<?php echo $map_path . =
$image_url; ?>">


My problem:=20
how I can define the "maxcount of characters in a line", which means =
that the company name (for example) can extend over 3 lines ?

Many thanks
Kati
Vienna
------=_NextPart_000_0018_01C2B4DA.1B953A30
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello together !</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have a simple question:<BR>how I can =
force a line=20
break in a label ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(comparable <br>in HTML). =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Some code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D4><STRONG>Mapfile:</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>LAYER #start of =
layer<BR>   NAME=20
"apotheken"<BR>   DATA apotheken<BR>   STATUS=20
ON<BR>   TYPE POINT<BR>   CLASSITEM =
"FIRMA"<BR>  =20
CLASS<BR>      NAME "Apotheken"   #in =
the=20
legend</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>#EXPRESSION, SYMBOL=20
and TEXT are in a phpfile defined</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>     =20
LABEL   #important for=20
TEXT<BR>         TYPE=20
TRUETYPE<BR>         FONT=20
Verdana<BR>         POSITION=20
UC<BR>         WRAP=20
'-'<BR>         BUFFER=20
10<BR>         SIZE=20
7<BR>      END<BR>   END<BR>END #end =
of layer=20
object<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D4><STRONG>phpfile:</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2><?php<BR>include_once("dbase_gis.inc");<BR>$map_path =3D=20
"ms_tmp/";<BR>$raster_dir =3D "wigeomap10000";<BR>$map_file =3D =
"wien.map";<BR>$map=20
=3D ms_newMapObj($map_path . $map_file);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>reset($_SESSION);<BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>/***** Class for Symbols =
is here=20
defined *****/<BR>if($_SESSION["s_shape"] =3D=3D "apotheke") =
{<BR>  =20
$layer =3D $map->getLayerByName("apotheken");<BR>}=20
else<BR>if($_SESSION["s_shape"] =3D=3D "spital") {<BR>   =
$layer =3D=20
$map->getLayerByName("spitaele");<BR>}</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>$result_class =3D=20
$layer->getClass(0);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2><FONT face=3D"Courier New" =
size=3D2>/*****=20
Class f=FCr Symbole definieren *****/</FONT></DIV></FONT>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>//1. all Locations</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>$m =3D new =
ResultMap();   #defined=20
in an <BR>while(list($key, $value) =3D each($_SESSION)) =
{<BR>  =20
if(substr($key, 0,3) =3D=3D "loc") {<BR>     =20
$m->addLocationToShape($value);<BR>      =
$expr=20
.=3D  $value->getFirma() . "|";<BR>   =
}<BR>}</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>//2. from-values (start =
position - home -=20
only a point)<BR>$m->addXYToShape($_SESSION["s_fromx"],=20
$_SESSION["s_fromy"]);</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>//3. perhaps to-values =
(start position=20
- for example a line, not a point)<BR>if($_SESSION["s_tox"] &&=20
$_SESSION["s_toy"]) {<BR>   =
$m->addXYToShape($_SESSION["s_tox"],=20
$_SESSION["s_toy"]);<BR>}</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT> </DIV>
<DIV><FONT face=3D"Courier New"><STRONG>/*****!!! relevant=20
****/</STRONG></FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2><STRONG>/*********** symbol with=20
a label (TEXT) *******/<BR>$expr =3D substr($expr, 0, =
strlen($expr)-1); =20
//das letze "|" entfernen<BR>$expr =3D "/(" . $expr .=20
")/";<BR>$result_class->setexpression($expr);<BR>$result_class->set=
("symbol",=20
4);<BR>$result_class->settext($layer, "([FIRMA], [STRASSE], [HNR],=20
[PLZ])");<BR>/*********** symbol with a label=20
(TEXT) *******/</STRONG></FONT></DIV>
<DIV><FONT face=3D"Courier New">
<DIV><FONT face=3D"Courier New"><STRONG>/*****!!! relevant=20
****/</STRONG></FONT></DIV></FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>/********** draw a=20
map *****/<BR>$extent =3D=20
$m->getMapExtent();<BR>$map->setextent($extent->minx, =
$extent->miny,=20
$extent->maxx, $extent->maxy);<BR>$image =3D =
$map->draw();<BR>$image_url=20
=3D $image->saveWebImage(MS_PNG, 1, 1, 0);<BR>/********** draw a =

map *****/<BR>?></FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT> </DIV><FONT size=3D2>
<DIV><FONT face=3D"Courier New"><input class=3D"image" type=3D"image" =
src=3D"<?php=20
echo $map_path . $image_url; ?>"><BR></FONT></FONT><FONT =
face=3DArial=20
size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>My problem: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>how I can define the "maxcount=20
of characters in a line", which means that the company name =
(for=20
example) can extend over 3 lines ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Many thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Kati</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Vienna</DIV></FONT></BODY></HTML>

------=_NextPart_000_0018_01C2B4DA.1B953A30--




More information about the MapServer-users mailing list