Rotating a symbol/layer drawn with PointObj

Peter Freimuth pf at MAPMEDIA.DE
Thu Jun 30 06:49:34 EDT 2005


Kasey Kirkham schrieb:

> 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, '');    
>     }
>  

Dear Kasey,
we have implemented this function for rotating symbols by an angle 
attribute a while ago but the code is still not included in the current 
code base. I will send the regarding code next week to Steve Lime (main 
developer team). Maybe it can be integrated in the next mapserver 
release. Sorry for the delay!
Peter

-- 
Mit freundlichem Gruß

Peter Freimuth
MapMedia
Kartographie und raumbezogene Informationssysteme

Heilbronner Straße 10
D-10711 Berlin Charlottenburg

fon:  +49.(0)30.89 06 82 70
fax:  +49.(0)30.89 06 82 73
mail: pf at mapmedia.de
net:  www.mapmedia.de
pgp:  on demand
_________________________________________________



More information about the mapserver-users mailing list