[mapserver-users] drawing acetate shapes with PHP/Mapscript

Daniel Morissette morissette at dmsolutions.ca
Fri Apr 26 12:20:47 EDT 2002


Puneet,

I think you're close.  You'll at least need to add "TRANSFORM FALSE" in
your layer definition since your shape is defined in pixel coordinates,
and add a call to $shpObj->add($lineObj) before calling draw(),
otherwise you are drawing a empty shape.

Daniel



Puneet Kishor wrote:
> 
> once a map is drawn, I'd like to add a triangle, a circle, or a square, or
> whatever... (but, let's take the example of a triangle for now) on top of
> everything.
> 
> the way I understand it, I would have to --
> 
> 1. have an "acetate" layer with 'STATUS off' in my map file like so...
> 
> LAYER
>   NAME "acetate"
>   TYPE polygon
>   STATUS off
>   CLASS
>     OUTLINECOLOR 255 0 0                        # red outline
>     COLOR 0 255 0                               # green fill
>   END
> END
> 
> 2. and use Mapscript like so...
> 
> $layerObj = $mapObj->getlayerbyname("acetate"); // new layerObj
> $classObj = $layerObj->getClass(0);             // classObj
> $imgObj = $mapObj->draw();                      // imgObj
> $shpObj = ms_newShapeObj(MS_SHAPE_LINE);        // new shpObj
> 
> $pointObj1 = ms_newPointObj();                  // point1
> $pointObj1->setXY(300, 300);
> 
> $pointObj2 = ms_newPointObj();                  // point2
> $pointObj2->setXY(450, 600);
> 
> $pointObj3 = ms_newPointObj();                  // point3
> $pointObj3->setXY(600, 300);
> 
> $pointObj4 = ms_newPointObj();                  // point4
> $pointObj4->setXY(300, 300);
> 
> $lineObj = ms_newLineObj();                     // new line
> $lineObj->add($pointObj1);
> $lineObj->add($pointObj2);
> $lineObj->add($pointObj3);
> $lineObj->add($pointObj4);
> $shpObj->draw($mapObj, $layerObj, $imgObj, 0, "foo")
> 
> $layerObj->set("status", 1);                    // turn on the layer
> 
> ==============
> 
> am I right or am I way off?
> 
> Tia,
> 
> pk/



More information about the mapserver-users mailing list