[Mapserver-users] TrueType fonts problem -- help needed
Murat Isik
muratisik at megatek.com.tr
Mon Nov 10 06:50:09 PST 2003
Thank you for answering:) I cant thank you enough....
I have again forgotten to cc to the list, but now I will do it. I am sorry.
I dont know how to use drawLableCache, since I am both a php-newbei and
mapscript-newbei at the same time (it is killing me...)
I hope it is ok for you, I am pasting my whole code. It can read mysql
coordinates and print points acordingly, zoom, pan and navigate the map. I
hope this code can help some other newbeier-than-me newbei someday...
ERENKOY_ORNEKSOKAK_PL_polyline is my streets layer.
php code:
<HEAD>
<TITLE>MEGATEK</TITLE>
</HEAD>
<CENTER>
<FORM METHOD=POST ACTION=<?php echo $PHP_SELF?>>
<H1>TEST SERVER</H1>
<IMG SRC="yeni_ust.gif">
<P>
<?php
dl("php_mapscript.so");
mysql_connect("localhost","root","sqlpass") or
die ("Could not connect to database");
mysql_select_db("pointtrack") or
die("Could not select database");
$val_zsize=3;
//$check_pan="CHECKED";
$shpFname = "target1";
$shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
$shpFname1 = "target2";
$shpFile1 = ms_newShapeFileObj($shpFname1, MS_SHP_POINT);
$pt = ms_newPointObj();
$i = 0;
$result = mysql_query("select * from track4") or
die (mysql_error());
$x[0]=0;
$y[0]=0;
while ($row = mysql_fetch_array($result))
{
++$i;
$test_x[$i] = $row["lodegrees"]+$row["lominutes"]/60;
$test_y[$i] = $row["ldegrees"]+$row["lminutes"]/60;
if($test_x[$i]==$x[$i-1] || $test_y[$i]==$y[$i-1])
{
--$i;
}else
{
$x[$i] = $test_x[$i];
$y[$i] = $test_y[$i];
}
}
mysql_free_result($result);
for($k=1;$k<=$i-1;++$k)
{
$pt->setXY($x[$k], $y[$k]);
$shpFile->addPoint($pt);
};
$pt->setXY($x[$i], $y[$i]);
$shpFile1->addPoint($pt);
$shpFile->free();
$shpFile1->free();
$def =array(array("UNIQID", "C", 13),array("NOM", "C", 128));
$dbfFile = dbase_create($shpFname.".dbf", $def);
dbase_add_record($dbfFile, array("1","TEST"));
$def =array(array("UNIQID", "C", 13),array("NOM", "C", 128));
$dbfFile = dbase_create($shpFname1.".dbf", $def);
dbase_add_record($dbfFile, array("1","TEST"));
$myMap = ms_newMapObj("demo_try.map");
//$myLayer = $myMap->getLayerByName("target1");
//$myLayer->set("data", $shpFname);
//$myLayer->set('status', MS_ON);
if ( isset($HTTP_POST_VARS["mapa_x"]) && isset($HTTP_POST_VARS["mapa_y"])
&& !isset($HTTP_POST_VARS["full"]) ) {
$extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
$myMap->setextent($extent_to_set[0],$extent_to_set[1],$extent_to_set[2],$ex
tent_to_set[3]);
$my_point = ms_newpointObj();
$my_point->setXY($HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);
$my_extent = ms_newrectObj();
$my_extent->setextent($extent_to_set[0],$extent_to_set[1],
$extent_to_set[2],$extent_to_set[3]);
$zoom_factor = $HTTP_POST_VARS["zoom"]*$HTTP_POST_VARS["zsize"];
if ($zoom_factor == 0) {
$zoom_factor = 1;
$check_pan = "CHECKED";
$check_zout = "";
$check_zin = "";
$check_right = "";
$check_left = "";
} else if ($zoom_factor < 0) {
$check_pan = "";
$check_zout = "CHECKED";
$check_zin = "";
$check_right = "";
$check_left = "";
} else {
$check_pan = "";
$check_zout = "";
$check_zin = "CHECKED";
$check_right = "";
$check_left = "";
}
$val_zsize = abs($zoom_factor);
$myMap->zoompoint($zoom_factor,$my_point,$myMap->width,$myMap->height,
$my_extent);
}
if($HTTP_POST_VARS["zoom"] == 2)
{
$extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
$xmin = $extent_to_set[0];
$xmax = $extent_to_set[2];
$ymin = $extent_to_set[1];
$ymax = $extent_to_set[3];
$xinc = ($xmax - $xmin ) / 2;
$myMap->setextent( ($xmin + 0.01), $ymin, ($xmax + 0.01), $ymax);
$check_pan = "";
$check_zout = "";
$check_zin = "";
$check_right = "CHECKED";
$check_left = "";
}
if($HTTP_POST_VARS["zoom"] == 3)
{
$extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
$xmin = $extent_to_set[0];
$xmax = $extent_to_set[2];
$ymin = $extent_to_set[1];
$ymax = $extent_to_set[3];
$myMap->setextent( ($xmin - 0.01), $ymin, ($xmax - 0.01), $ymax);
$check_pan = "";
$check_zout = "";
$check_zin = "";
$check_right = "";
$check_left = "CHECKED";
}
if($HTTP_POST_VARS["zoom"] == 4)
{
$extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
$xmin = $extent_to_set[0];
$xmax = $extent_to_set[2];
$ymin = $extent_to_set[1];
$ymax = $extent_to_set[3];
$myMap->setextent( $xmin, ($ymin - 0.01), $xmax, ($ymax - 0.01));
$check_pan = "";
$check_zout = "";
$check_zin = "";
$check_right = "";
$check_left = "";
$check_up = "CHECKED";
$check_down = "";
}
if($HTTP_POST_VARS["zoom"] == 5)
{
$extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
$xmin = $extent_to_set[0];
$xmax = $extent_to_set[2];
$ymin = $extent_to_set[1];
$ymax = $extent_to_set[3];
$myMap->setextent( $xmin, ($ymin + 0.01), $xmax, ($ymax + 0.01));
$check_pan = "";
$check_zout = "";
$check_zin = "";
$check_right = "";
$check_left = "";
$check_up = "";
$check_down = "CHECKED";
}
$img = $myMap->draw();
$image_url = $img->saveWebImage(GIF,1,1,0);
$extent_to_html = $myMap->extent->minx." ".$myMap->extent->miny." "
.$myMap->extent->maxx." ".$myMap->extent->maxy;
?>
<BODY>
<center>
<table border=0 cellspacing=0 cellpadding=4 bgcolor="#FFFFFF">
<tr>
<td valign="top" align=center>
<table cellpadding="0" cellspacing="5" border="5">
<tr><td colspan="2"><INPUT NAME="mapa" TYPE="image" SRC="<?php echo
$image_url; ?>" width=600 height=600 border=0></td></tr>
<tr>
<TR>
<TD>
Pan
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=0 <?php echo $check_pan?>>
</TD>
</TR>
<TR>
<TD>
Zoom In
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=1 <?php echo $check_zin?>>
</TD>
</TR>
<TR>
<TD>
Zoom Out
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=-1 <?php echo
$check_zout?>>
</TD>
</TR>
<TR>
<TD>
Right
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=2 <?php echo
$check_right?>>
</TD>
</TR>
<TR>
<TD>
Left
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=3 <?php echo
$check_left?>>
</TD>
</TR>
<TR>
<TD>
Up
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=4 <?php echo $check_up?>>
</TD>
</TR>
<TR>
<TD>
Down
</TD>
<TD>
<INPUT TYPE=RADIO NAME="zoom" VALUE=5 <?php echo
$check_down?>>
</TD>
</TR>
<TR>
<TD>
Zoom Size
</TD>
<TD>
<INPUT TYPE=TEXT NAME="zsize" VALUE="<?php echo $val_zsize?>"
SIZE=2>
</TD>
</TR>
<TR>
<TD>
Full Extent
</TD>
<TD>
<INPUT TYPE=SUBMIT NAME="full" VALUE="Go"
SIZE=2>
</TD>
</TABLE>
<INPUT TYPE=HIDDEN NAME="extent" VALUE="<?php echo $extent_to_html?>">
</FORM>
</CENTER>
</BODY>
</HTML>
map file at the moment: (the one I use for mapscript)
#
# Start of map file
#
NAME ERENKOY
STATUS ON
SIZE 600 600
EXTENT 29.057 40.954 29.143 40.999
UNITS DD
SHAPEPATH "/var/www/html/mapserver/itasca/"
IMAGECOLOR 255 255 255
FONTSET font.list
#OUTPUTFORMAT
# NAME PNG
# DRIVER "GD/PNG"
# MIMETYPE "image/png"
# IMAGEMODE PC256
# EXTENSION "png"
#END
IMAGETYPE GIF
WEB
MINSCALE 1000
MAXSCALE 1550000
IMAGEPATH "/var/www/html/mapserver/tmp3/"
IMAGEURL "/mapserver/tmp3/"
END
SYMBOL
NAME 'circle'
TYPE ELLIPSE
POINTS 1 1 END
FILLED TRUE
END
LAYER
NAME 'ERENKOY_ORNEKILCE_PG_region'
TYPE polygon
STATUS DEFAULT
DATA ERENKOY_ORNEKILCE_PG_region
CLASSITEM 'ID'
CLASS
EXPRESSION '3'
OUTLINECOLOR 128 128 128
COLOR 225 225 185
END
CLASS
EXPRESSION /./
OUTLINECOLOR 128 128 128
COLOR 255 255 255
END
END
#LAYER
# NAME ERENKOY_ORNEKMAHALLE_PG_region
# GROUP cities
# TYPE polygon
# DATA ERENKOY_ORNEKMAHALLE_PG_region
# STATUS ON
# CLASSITEM 'ID'
# CLASS
# EXPRESSION /./
# EXPRESSION /./
# COLOR 255 225 185
# OUTLINECOLOR 0 0 0
# END
#END
#LAYER
# NAME ERENKOY_ORNEKSOKAK_PL_polyline
# GROUP sokaklar
# TYPE line
# DATA ERENKOY_ORNEKSOKAK_PL_polyline
# STATUS ON
# CLASSITEM 'ID'
# CLASS
# EXPRESSION /./
# COLOR 66 34 249
# END
#END
LAYER
NAME ERENKOY_ORNEKSOKAK_PL_polyline
TYPE line
GROUP sokaklar
STATUS ON
DATA ERENKOY_ORNEKSOKAK_PL_polyline
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
#LABELCACHE on
LABELITEM 'ADI'
CLASS
NAME 'ADI'
EXPRESSION /./
COLOR 161 02 110
LABEL
TYPE truetype
# FORCE true
FONT arial
COLOR 0 0 0
ANGLE AUTO
BACKGROUNDCOLOR 250 250 250 #WIT
POSITION AUTO
SIZE 0
MINSIZE 2
SIZE 8
END
END
END
LAYER
NAME ERENKOY_ORNEKOTOBAN_PL_polyline
GROUP otoban
TYPE line
DATA ERENKOY_ORNEKOTOBAN_PL_polyline
STATUS OFF
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
END
LAYER
NAME ERENKOY_ORNEKCADDE_PL_polyline
GROUP otoban
TYPE line
DATA ERENKOY_ORNEKCADDE_PL_polyline
STATUS OFF
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
END
LAYER
NAME ERENKOY_ORNEKBULVAR_PL_polyline
GROUP otoban
TYPE line
DATA ERENKOY_ORNEKBULVAR_PL_polyline
STATUS OFF
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
END
LAYER
NAME ERENKOY_ORNEKKAVSAK2_PL_polyline
GROUP otoban
TYPE line
DATA ERENKOY_ORNEKKAVSAK2_PL_polyline
STATUS OFF
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
END
LAYER
NAME ERENKOY_ORNEKKAVSAK_PL_polyline
GROUP otoban
TYPE line
DATA ERENKOY_ORNEKKAVSAK_PL_polyline
STATUS OFF
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
END
LAYER
NAME ERENKOY_ORNEKDENIZ_PG_region
GROUP otoban
TYPE polygon
DATA ERENKOY_ORNEKDENIZ_PG_region
STATUS OFF
CLASSITEM 'ID'
CLASS
EXPRESSION /./
COLOR 66 34 249
END
END
LAYER
NAME 'target2'
TYPE point
DATA target2
STATUS ON
CLASS
SYMBOL 'circle'
COLOR 255 255 0
SIZE 20
LABEL
COLOR 0 0 0
END
END
END
LAYER
NAME 'target1'
TYPE point
DATA target1
STATUS ON
CLASS
SYMBOL 'circle'
COLOR 255 0 0
SIZE 4
LABEL
COLOR 0 0 0
END
END
END
END # end of map file
----- Original Message -----
From: "Frieso ter Haseborg" <ter-haseborg at sf-datentechnik.de>
To: "Murat Isik" <muratisik at megatek.com.tr>
Cc: <mapserver-users at lists.gis.umn.edu>
Sent: Monday, November 10, 2003 4:38 PM
Subject: RE: [Mapserver-users] TrueType fonts problem -- help needed
> Hi,
>
> there should be no difference between a mapfile for direct-use in MS
> and a mapfile used with MS/mapscript. IMHO you should check your php for
> the problem first (post the relevant part of the code too, if the
> problem continues).
>
> => Do you execute the drawLabelCache-method (e.g. map->drawLabelCache (
> $image ))?
>
> Don't forget the cc to the list!
>
> HTH,
> Frieso
>
> >-----Original Message-----
> >From: Murat Isik [mailto:muratisik at megatek.com.tr]
> >Sent: Monday, November 10, 2003 3:22 PM
> >To: Frieso ter Haseborg
> >Subject: Re: [Mapserver-users] TrueType fonts problem -- help needed
> >
> >
> >Thank you for your reply.
> >after my last mail, I have started to play around with labelling and
> >achieved good results with mapserver.
> >However when I copy the related layer's part from mapserver map file to
> >mapscripts mapfile, it first stopped rendering. then I added
> >the CLASSITEM
> >'ID' line and it started to produce image without labels. Can
> >you please
> >help me? I am stuck...
> >
> >original layer from mapscript mapfile:
> >LAYER
> > NAME ERENKOY_ORNEKSOKAK_PL_polyline
> > GROUP sokaklar
> > TYPE line
> > DATA ERENKOY_ORNEKSOKAK_PL_polyline
> > STATUS ON
> > CLASSITEM 'ID'
> > CLASS
> > EXPRESSION /./
> > COLOR 66 34 249
> > END
> >
> >END
> >
> >instead of the above I copied this and labelling did not work:
> >
> >LAYER
> > NAME ERENKOY_ORNEKSOKAK_PL_polyline
> > TYPE line
> > GROUP sokaklar
> > STATUS ON
> > DATA ERENKOY_ORNEKSOKAK_PL_polyline
> >
> >CLASSITEM 'ID'
> > CLASS
> > EXPRESSION /./
> > COLOR 66 34 249
> > END
> >#LABELCACHE on
> >LABELITEM 'ADI'
> > CLASS
> > NAME 'ADI'
> > COLOR 161 02 110
> > LABEL
> > TYPE truetype
> ># FORCE true
> > FONT arial
> > COLOR 0 0 0
> > ANGLE AUTO
> > BACKGROUNDCOLOR 250 250 250 #WIT
> > POSITION AUTO
> > SIZE 0
> > MINSIZE 2
> > SIZE 8
> > END
> > END
> >
> >Should I do something with the php part too?
> >
> >Have a nice day:)
> >
> >Murat Isik
> >
> >
> >
> >----- Original Message -----
> >From: "Frieso ter Haseborg" <ter-haseborg at sf-datentechnik.de>
> >To: "Murat Isik" <muratisik at megatek.com.tr>
> >Cc: <mapserver-users at lists.gis.umn.edu>
> >Sent: Monday, November 10, 2003 12:06 PM
> >Subject: RE: [Mapserver-users] TrueType fonts problem -- help needed
> >
> >
> >> Hi,
> >>
> >> try to use an absolute path in your "fonts.list".
> >>
> >> HTH,
> >>
> >> Frieso ter Haseborg
> >> - Software Development -
> >>
> >> --
> >>
> >> --------------------------------------------------
> >> S&F Datentechnik GmbH&Co.KG
> >> Reimersstr. 41b
> >> 26789 Leer, Germany
> >>
> >> -----Original Message-----
> >> From: Murat Isik [mailto:muratisik at megatek.com.tr]
> >> Sent: Monday, November 10, 2003 10:27 AM
> >> To: mapserver-users at lists.gis.umn.edu
> >> Subject: [Mapserver-users] TrueType fonts problem -- help needed
> >>
> >>
> >> Hello,
> >> I am having a problem with TrueType fonts. This is the error I get:
> >>
> >> msGetLabelSize(): TrueType Font error. Could not find/open font
> >>
> >> And this is what I do to get this error:
> >>
> >> I have these in my mapfile:
> >>
> >> NAME ERENKOY
> >> STATUS ON
> >> SIZE 600 600
> >> SHAPEPATH "data"
> >> IMAGECOLOR 255 255 255
> >> FONTSET font.list
> >>
> >> and
> >>
> >> LAYER
> >> NAME ERENKOY_ORNEKSOKAK_PL_polyline
> >> TYPE LINE
> >> GROUP sokaklar
> >> STATUS ON
> >> DATA ERENKOY_ORNEKSOKAK_PL_polyline
> >> LABELITEM "ADI"
> >> CLASS
> >> NAME "ADI"
> >> COLOR 161 02 110
> >> LABEL
> >> TYPE truetype
> >> FORCE true
> >> FONT arial
> >> COLOR 0 0 0
> >> BACKGROUNDCOLOR 250 250 250
> >> POSITION cc
> >> SIZE 8
> >> END
> >> END
> >> END
> >>
> >>
> >> This ERENKOY_ORNEKSOKAK_PL_polyline layer's dbf file includes two
> >> coloumns, ID and ADI (name). This is a street layer and I am
> >trying to
> >> get the name of the streets written next to their lines.
> >>
> >> font.list include:
> >>
> >> arial arial.ttf
> >> arial-bold arialbd.ttf
> >> arial-italic ariali.ttf
> >> arial-bold-italic arialbi.ttf
> >>
> >> I have all the related ttf files in the same directory as font.list
> >> text, mapfile and the html page calling these fonts. However
> >I get the
> >> error. May it be that my mapserver is not truetype compiled? I must
> >> admit that I installed mapserver and mapscript through rpms so I dont
> >> know the trutype situation of my mapserver 3.6. If I can get this
> >> labelling to work then I am going to use th same mapfile for
> >a mapscript
> >> page.
> >>
> >> Have a nice day.
> >>
> >> Murat Isik
> >>
> >>
> >>
> >>
> >
> >
> >
More information about the MapServer-users
mailing list