[Mapserver-users] maxcount of characters in a line

Katarina Kobesova katarina.kobesova at chello.at
Sun Jan 5 10:47:17 EST 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>&nbsp;</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 &lt;br&gt;in HTML). =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>LAYER #start of =
layer<BR>&nbsp;&nbsp; NAME=20
"apotheken"<BR>&nbsp;&nbsp; DATA apotheken<BR>&nbsp;&nbsp; STATUS=20
ON<BR>&nbsp;&nbsp; TYPE POINT<BR>&nbsp;&nbsp; CLASSITEM =
"FIRMA"<BR>&nbsp;&nbsp;=20
CLASS<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NAME "Apotheken"&nbsp;&nbsp; #in =
the=20
legend</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>#EXPRESSION,&nbsp;SYMBOL=20
and&nbsp;TEXT&nbsp;are in a phpfile defined</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
LABEL&nbsp;&nbsp; #important for=20
TEXT<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE=20
TRUETYPE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FONT=20
Verdana<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; POSITION=20
UC<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WRAP=20
'-'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BUFFER=20
10<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SIZE=20
7<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END<BR>&nbsp;&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2>&lt;?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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>reset($_SESSION);<BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>/***** Class&nbsp;for Symbols =
is here=20
defined&nbsp;*****/<BR>if($_SESSION["s_shape"] =3D=3D "apotheke") =
{<BR>&nbsp;&nbsp;=20
$layer =3D $map-&gt;getLayerByName("apotheken");<BR>}=20
else<BR>if($_SESSION["s_shape"] =3D=3D "spital") {<BR>&nbsp;&nbsp; =
$layer =3D=20
$map-&gt;getLayerByName("spitaele");<BR>}</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>$result_class =3D=20
$layer-&gt;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>&nbsp;</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();&nbsp;&nbsp; #defined=20
in an <BR>while(list($key, $value) =3D each($_SESSION)) =
{<BR>&nbsp;&nbsp;=20
if(substr($key, 0,3) =3D=3D "loc") {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$m-&gt;addLocationToShape($value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$expr=20
.=3D&nbsp; $value-&gt;getFirma() . "|";<BR>&nbsp;&nbsp; =
}<BR>}</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>//2. from-values (start =
position - home -=20
only a point)<BR>$m-&gt;addXYToShape($_SESSION["s_fromx"],=20
$_SESSION["s_fromy"]);</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>//3.&nbsp;perhaps to-values =
(start position=20
- for example a line, not a point)<BR>if($_SESSION["s_tox"] &amp;&amp;=20
$_SESSION["s_toy"]) {<BR>&nbsp;&nbsp; =
$m-&gt;addXYToShape($_SESSION["s_tox"],=20
$_SESSION["s_toy"]);<BR>}</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New"><STRONG>/*****!!! relevant=20
****/</STRONG></FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2><STRONG>/***********&nbsp;symbol&nbsp;with=20
a label (TEXT)&nbsp;*******/<BR>$expr =3D substr($expr, 0, =
strlen($expr)-1);&nbsp;=20
//das letze "|" entfernen<BR>$expr =3D "/(" . $expr .=20
")/";<BR>$result_class-&gt;setexpression($expr);<BR>$result_class-&gt;set=
("symbol",=20
4);<BR>$result_class-&gt;settext($layer, "([FIRMA], [STRASSE], [HNR],=20
[PLZ])");<BR>/***********&nbsp;symbol with a label=20
(TEXT)&nbsp;*******/</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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>/**********&nbsp;draw a=20
map&nbsp;*****/<BR>$extent =3D=20
$m-&gt;getMapExtent();<BR>$map-&gt;setextent($extent-&gt;minx, =
$extent-&gt;miny,=20
$extent-&gt;maxx, $extent-&gt;maxy);<BR>$image =3D =
$map-&gt;draw();<BR>$image_url=20
=3D $image-&gt;saveWebImage(MS_PNG, 1, 1, 0);<BR>/**********&nbsp;draw a =

map&nbsp;*****/<BR>?&gt;</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV><FONT size=3D2>
<DIV><FONT face=3D"Courier New">&lt;input class=3D"image" type=3D"image" =
src=3D"&lt;?php=20
echo $map_path . $image_url; ?&gt;"&gt;<BR></FONT></FONT><FONT =
face=3DArial=20
size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My problem: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>how I&nbsp;can define the "maxcount=20
of&nbsp;characters in a line",&nbsp;which means that the company name =
(for=20
example) can extend over 3 lines ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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