moving an existing point

McGraw, Joanne mcgrawj at AGR.GC.CA
Thu Jun 2 11:43:21 EDT 2005


Good day all,

 

I am displaying a corporate logo in all our application maps by adding
the following layer to my map file:

 

layer

    name copyright

    status on

    transform false

    type point

    feature

        # for english version

        # --------------------------

        points 72 286.5 end #lower left - display

        #points 74 706.5 end #lower left - print

 

        # for french version

        # --------------------------

        #points 88 286.5 end #lower left - display

        #points 90 706.5 end #lower left - print

    end # feature

    class

        # english logo

        symbol "logo-e.png"

        # french logo

        #symbol "logo-f.png"

        outlinecolor 255 255 255

    end # class

end # copyright layer

 

As you can see from the commented points positions, there are four
possible x,y coordinates that this corporate logo should be displayed at
depending on what language the user is working in and whether they are
creating the map for display in our application or for printing to a
page. 

 

To handle this, I am trying to write some code to move the location of
the point but have run into a problem I cannot resolve. For the time
being, I am only concerned with whether I am printing or displaying, so
only the y position has to change (I'll worry about the x position for
the languages after I get the y working). When I try to run the
following code, a fatal error "Call to undefined function: setxy()"

 

$layer = $oMap->getLayerByName("copyright");

if (isset($layer)){

    $layer->open();

    $p = $layer->getShape(-1, 0);

    $oldX = $p->x;

    $oldY = $p->y;

    $newY = $oMap->height - (($oMap->height/2) + 3); // 3 pixels away
from the border of the map

    $p.setXY($oldX, $newY);

    $layer->close();

}
// drawMap(); reset original x,y cords for point; etc.; etc.

 

I introduced some print to file statements after the line "$p =
$layer->getShape(-1, 0);" to verify that the $layer->type did indeed
equal MS_LAYER_POINT, but I don't know how to find out if $p is actually
a PointObj (I'd be interested to know for future reference, BTW). I'm
assuming it isn't a PointObj and that is why the setxy() function (and
the x value and the y value, as it turns out) is undefined, but can't
figure out how to cast the ShapeObj returned with getShape() to a
PointObj.

 

I have looked for examples for what I am trying to do, but all examples
using setXY that I can find are operating on new points constructed with
the ms_newPointObj() rather than on an existing point selected out of a
layer. Can anyone point me in the right direction with respect to
casting the ShapeObj to a PointObj? Or, if this isn't a good approach,
can you let me know what I should be doing instead? 

 

Cheers,

jtm

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050602/8ab9b84f/attachment.html


More information about the mapserver-users mailing list