[Mapserver-users] mapscript 3.7 $layer->draw() problems

Vincent Schut schut at sarvision.com
Wed Jul 2 12:26:07 EDT 2003


Bart,

according to the php_mapscript classes guide, you will have to add some 
arguments to rectangle->draw():

int draw(mapObj map, layerObj layer, imageObj img, 
            int class_index, string text)
        Draws the individual rectangle using layer.  The class_index is used
        to classify the rectangle based on the classes defined for the layer.
        The text string is used to annotate the rectangle.
        Returns MS_SUCCESS/MS_FAILURE.

In your case this would become something like
$rectangle->draw( $wvimap, $wvilayer, $wviimg, 0, '' );
I guess you will have to experiment a bit with this. I have never used it, 
actually. Don't forget to save the image *after* this rectangle drawing, 
instead of before.

Cheers,
Vincent.

On Wednesday 02 July 2003 17:39, Bart van Heijningen wrote:
> Hi all,
>
>
>
> I use Mapserver 4 with php mapscript
>
>
>
> Here's the thing,
>
> I am trying to draw newRectObj() on a map.
>
> The size and position are generated from mysql
>
> However I think I am missing something.
>
>
>
> What am I doing wrong here. I have been struggling with this for a few days
> now, help would be higly appreciated.
>
>
>
> Thanks,
>
> Bart
>
>
>
> // the map
>
> $wvimap = ms_newMapObj("rdm3.map");
>
> $wvimap->selectOutputFormat('png24');
>
>
>
> $wviimg = $wvimap->draw();
>
> $imageobject = $wviimg->saveImage(test);
>
>
>
> //  get correct layer
>
> $wvilayer = $wvimap->getLayerByName("$bleble");
>
> //$layerhandle = $wvilayer->open('$shpFname',1);
>
> // Zoek in deze layer de eerste class
>
> $classObj = $wvilayer->getClass(0);
>
> echo "classobject = $classObj<br>\n";
>
> $wvilayer->set("name", "$bleble");
>
> $wvilayer->set (status,MS_ON);
>
> $wvilayer->set (type,MS_POLYGON);
>
> $wvilayer->set (classitem,$classObj);
>
> $wvilayer->set (labelitem,"WVI");
>
> $wvilayer->set (data,"$shpFname");
>
> $wvilayer->draw($wvimap,$classObj);
>
>
>
> // Declaration of the rectangle object
>
>
>
> $rectangle = ms_newRectObj();
>
>
>
> // Here I calculate the values of the rectangle
>
>
>
>
>
> $rectangle->set("minx",($hshift+($measurements)*($rd_x)));
>
> $rectangle->set("miny",(($vshift+($measurements)*($rd_y))));
>
> $rectangle->set("maxx",(($hshift+(($measurements)*($rd_x)+($barwidth)))));
>
> $rectangle->set("maxy",(($measurements)*($rd_y) +
> (($maxbarheight/$maxvalue)*($measurements))+($barminheight)));
>
>
>
> echo "minx = $rectangle->minx<BR>\n";
>
> echo "miny = $rectangle->miny<BR>\n";
>
> echo "maxx = $rectangle->maxx<BR>\n";
>
> echo "maxy = $rectangle->maxy<BR>\n";
>
>
>
> // the following draw Mapserver does not like.
>
> I cannot find any good examples how the draw for this rectobject should be
> used.
>
>
>
> $rectangle->draw();
>
>
>
> the mapfile layer I want to use for displaying the rectObJect
>
>
>
> LAYER
>
>   NAME "Ce-141"
>
>   TYPE polygon
>
>   STATUS ON
>
>   CLASS
>
>     NAME "Ce-141"
>
>     COLOR 253 132 115
>
>     BACKGROUNDCOLOR 253 132 115
>
>     SYMBOL 'circle'
>
>     LABEL
>
>       TYPE TRUETYPE
>
>       ANTIALIAS FALSE
>
>       FONT arial
>
>       COLOR 0 0 0
>
>       BACKGROUNDCOLOR 254 254 254
>
>       SIZE 6
>
> #      ANGLE 45
>
>       POSITION uc
>
> #      buffer 2
>
>     END
>
>   END
>
> END

-- 
______________________________________
Vincent Schut
Sarvision B.V.
Wageningen, The Netherlands
www.sarvision.com



More information about the mapserver-users mailing list