[Mapserver-users] PHP Mapscript writing rectangles with ms_newRectObj(); on the fly
Bart van Heijningen
bart at atsence.nl
Wed Jul 2 14:41:05 PDT 2003
Hi all,
Before I get out of here I would like to leave a question here , hoping that
one of you guys can help me out.
I use Mapserver4 on RH 8.0 PHP mapscript.
>From a mysql table I want to generate a bar chart which I want to display as
a layer on a map. The location is x,y from the dbase as well.
Sof far I am stuck with drawing the rectangle bar chart.
I want to use
The thing I try to do is define the amount of bars to display on the given
location and then draw the inidvidual bars defined by their value and define
a colour for the bars.
$wvilayer = $wvimap->getLayerByName("$unit");
$rectObj = ms_newRectObj();
How should I now proceed? I have tried a dozen things but I think I am
overlooking something.
Here's what I have:
Get the layer that refers to the location data where I want to print a bar
chart.
$wvilayer = $wvimap->getLayerByName("$unit");
// Get the first class of the layer
$classObj = $wvilayer->getClass(0);
//get location data from mysql
$pointObj->setXY($rd_x,$rd_y);
$line = ms_newLineObj();
$line ->add($pointObj);
$shp = ms_newShapeObj(MS_SHAPE_POINT);
$shp->add($line);
//$shp->{text} = $measurements;
//$shp->{index} = ($count2);
if($wvilayer->addFeature($shp) == -1){
echo "addFeature failed";
}
$pointObj = ms_newPointObj();
$rectObj = ms_newRectObj();
//$rectObj->setextent($rd_x, $rd_y,
// ($rd_x + $hshift) ,
($rd_y*$measurements));
$pointObj->setXY($rd_x,$rd_y);
$line = ms_newLineObj();
$line ->add($pointObj);
$shp = ms_newShapeObj(MS_SHAPE_POINT);
$shp->add($line);
//$shp->{text} = $measurements;
//$shp->{index} = ($count2);
if($wvilayer->addFeature($shp) == -1){
echo "addFeature failed";
}
// Here the minx miny maxx and maxy and measure value of the bars in
// the chart are calculated
// These points are calculated correctly
$rectObj->set("minx",(($rd_x)-($hshift)));
$rectObj->set("miny",(($rd_y)+($vshift)));
$rectObj->set("maxx",(($rd_x)-($hshift)+($barwidth)));
$rectObj->set("maxy",((($rd_y)+($vshift)+($measurements))));
echo "count2 = $count2 <br>\n";
echo "meetwaarde count 2 = $point_lookup[$count2] <br>\n";
//$count2++;
$rectObj->draw( $wvimap, $wvilayer, $wviimg, 0, $measurements );
Here it goes wrong the layer is not drawn on the map.
++++++++++
++++++++++ map file ++++++++++++++++++++++
LAYER
NAME "Ba-140"
TYPE polygon
POSTLABELCACHE TRUE
STATUS OFF
CLASS
NAME "Ba-140"
COLOR 208 28 2
BACKGROUNDCOLOR 208 28 2
SYMBOL 'circle'
LABEL
TYPE TRUETYPE
ANTIALIAS FALSE
PARTIALS FALSE
POSITION AUTO
FONT fritqat
COLOR 0 0 0
BACKGROUNDCOLOR 254 254 254
SIZE 6
POSITION uc
END
END
END
More information about the MapServer-users
mailing list