Rotating a symbol/layer drawn with PointObj
Kasey Kirkham
kasey at INEXO.COM
Wed Jun 29 18:29:25 PDT 2005
Hello,
Long, long ago, I posted to this forum asking for guidance on drawing a
point layer(
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0403/msg00562.html
). Thanks to the help of the folks on this list, I was able to get the
application working. First off, I created a layer for each symbol I wanted
to use(in the mapfile, see below). The php app which uses the mapfile will
create a new PointObj for each coordinate returned by a query, look up the
name of the symbol layer associated with the gps source, then call
PointObj->draw with the layer as an argument(see my equally inscrutable code
fragment below). This works nicely for drawing dots on the map, however
there is now a new twist. I would like to use triangular symbols in my
layer, rotated relative to the point which follows. For instance, if the
first coordinate was (1,1), and the second was (5,1), I would like to rotate
the first symbol to the right by 90 degrees so that it is "pointing" at the
second symbol. I think labels support this with the "angle" attribute, but
I didn't find anything in the documentation indicating that points/symbols
could be rotated in the same way. Any ideas?
A million thanks!
Kasey
# mapfile fragment:
# LAYER object
LAYER
NAME "point_mapping-red"
TYPE POINT
STATUS ON
# CLASS object
CLASS
NAME "points_red"
SYMBOL "gps_coordinate-red"
COLOR 255 0 0
# LABEL object
LABEL
POSITION CC
SIZE TINY
MINDISTANCE 400
MINFEATURESIZE 5
COLOR 255 255 255
PARTIALS FALSE
END
END
END
// php fragment:
// retrieve associative array of gps coordinates
$point_array = $currObjUnit->get_gps_coordinates();
// loop through array
foreach($point_array as $arPoints) {
// get a new point object
$pointObj_coord1 = ms_newPointObj();
// set the X and Y coords
$pointObj_coord1->setXY($arPoints["longitude"],
$arPoints["latitude"]);
// $map is returned by ms_newMapObj()
// $currObjUnit->get_unit_symbol retrieves the LAYER NAME attribute
for the layer indicated in the unit config(ie "point_mapping-red" in this
case)
$layerObj_imageSymbol =
$map->getLayerByName($currObjUnit->get_unit_symbol());
$class_index = 0;
// draw the point
// $map is a MapObj, $image is the image object returned by
$map->draw
$pointObj_coord1->draw($map, $layerObj_imageSymbol, $image,
$class_index, '');
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050629/73659df1/attachment.htm>
More information about the MapServer-users
mailing list