Rotating Symbols

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Mon May 29 12:15:17 EDT 2006


Stuart,

You might want to consider using a PostGIS layer because you and 
dynamically define the SQL for the layer and that will allow you to 
dynamically define the attributes or how they are computed. I use a mix 
of shapefile data for static layers and PostGIS for dynamic layers and 
it works great.

-Steve W.

Stuart Eve wrote:
> Blaise,
> 
> Is it possible - do you think - to create these fields on the fly? I 
> don;t really want to have to require people to create a 'fake' point 
> shapefile - just to use these symbols - I would prefer somehow to make a 
> new point layer from the old one (whose source isn't always a shapefile) 
> - and then perhaps dynamically add those values to it. The Mapscript API 
> says that the 'values' array is read-only? is it possible to add new 
> fields to the attribute table - especially if I have created the layer 
> using ms_newLayerObj?
> 
> If not then I will definitely use your suggestion - and perhaps submit a 
> bug report asking why the 'angle' property isn;t available - even tho in 
> the API it says it should be!
> 
> Stu
> 
> Blaise wrote:
>> Stu
>> I've got symbols rotated :
>> mapserver 4.8.3,
>> point shapefile:"rotlabel", dbf with 2 fields : "ID" and "rotation"
>> field rotation is numeric, 3 digits, no decimal (0->359)
>> Layer definition in mapfile :
>> LAYER
>>   NAME rotlabel
>>   TYPE POINT
>>   STATUS ON
>>   DATA rotlabel
>>   CLASS
>>     NAME "rotlabel"
>>     STYLE
>>       SYMBOL 'triangle'
>>       ANGLEITEM "rotation"
>>       SIZE 15
>>       COLOR 255 0 255
>>     END
>>   END
>> END
>> Triangle definition in symbol file (symbols.sym) :
>> Symbol
>> Name 'triangle'
>> Type VECTOR
>> Filled TRUE
>> Points
>> 0 1
>> .5 0
>> 1 1
>> 0 1
>> END
>> END
>> No on-the-fly label drawing, just basic layer display. When updating 
>> data in the "rotation" field of the dbf, triangles are rotating...
>> One strange thing is with angle 90 and 180 : triangles don't display. 
>> 89, 91, 179, 181 are ok, but not 90 and 180. 270 is ok as well.
>> You should easily custom the triangle symbol into whatever you want 
>> (arrow or else).
>> Better check that your symbol is displayed for any angle (0->359). 
>> There must be some kind of bug somewhere. Maybe you'll help 
>> discovering it.
>> I hope this is what you were looking for.
>> Regards
>> Blaise
>>
>>
>> Le Samedi 27 Mai 2006 17:47, Stuart Eve a écrit :
>>  
>>> Blaise
>>>
>>> I am working with shapefiles - but am going to need to do this with all
>>> different types of layers (trying to abstract it out). I have just added
>>> the 'angle' field to the dbf to try it out and I am still getting the
>>> same error.
>>>
>>> It seems that the styleObj thinks it doesn't have the member of 'angle'
>>> (or actualy 'angleitem') even though in my mapfile (which I
>>> automatically output by using $map->save) it has written it like this:
>>>
>>>  STYLE
>>>         ANGLE 360
>>>         COLOR 0 0 0
>>>         SIZE 8
>>>         SYMBOL "rot_tri"
>>>   END
>>>
>>> I am now trying to go through the process of automatically creating the
>>> rotated symbol on the fly (but the logic of it makes my head hurt!).
>>>
>>> Thanks for your help so far!
>>>
>>> Stu
>>>
>>> Blaise wrote:
>>>    
>>>> Hi Stu
>>>> What kind of layer do you use for your symbols, point or annotation ? I
>>>> assume it's a shapefile (*.shp, *.shx, *.dbf) isn't it ? I don't 
>>>> remember
>>>> exactly how annotation layers work but it must be the same as point. 
>>>> With
>>>> point layers, you have to have an "angle" field (numeric, 3 digits
>>>> without decimal, I believe, not sure) in your dbf file, or maybe better
>>>> "ANGLE" to be able to set the angle. Do you have this field in the dbf
>>>> and if not can you try adding it ?
>>>> And do you have the right angle instructions in the layer section of 
>>>> your
>>>> mapfile ? If not sure, post your mapfile layer section.
>>>> Bravo for the work so far.
>>>> Blaise
>>>>
>>>> Le Samedi 27 Mai 2006 16:58, Stuart Eve a écrit :
>>>>      
>>>>> Hi Blaise
>>>>>
>>>>> I have managed to get quite a long way down the road of extracting
>>>>> points and placing them, etc.- and I think its all going to work -
>>>>> however I have just been stumped by what seems to be to be a bug.
>>>>>
>>>>> I have managed to set up classes for each of the points that I wish to
>>>>> draw - and now want to set their styles so that the symbol (a VECTOR)
>>>>> symbol is rotated to the angle (which I have got from my geometry
>>>>> function). However, whenever I try to access styleObj->set("angle",45)
>>>>> it says that 'angle' doesn't exist in that object. However, I can dump
>>>>> out the mapfile and it is there set as 360.
>>>>>
>>>>> Any ideas whats going on?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Stu
>>>>>
>>>>> Blaise wrote:
>>>>>        
>>>>>> Stu
>>>>>> I don't know what output you want exactly, but yes, using mapscript,
>>>>>> you can easily put an arrow on each segment of a polyline with a loop
>>>>>> something like :
>>>>>> for each polyline
>>>>>>  for each segment of polyline
>>>>>>   get start and stop point of segment
>>>>>>   calculate middle point of segment and angle
>>>>>>   create new annotation arrow
>>>>>>
>>>>>> The geometry calculation is pretty straight forward, it's basic 2d
>>>>>> geometry. Ask more if you need help on the mapscript functions and/or
>>>>>> the geometry calculation.
>>>>>> But maybe someone else on this list has got a better/different idea.
>>>>>> Regards
>>>>>> Blaise
>>>>>>
>>>>>> Le Vendredi 26 Mai 2006 16:41, vous avez écrit :
>>>>>>          
>>>>>>> Blaise
>>>>>>>
>>>>>>> Thanks for the reply. I presume that we could automatically create a
>>>>>>> bunch of points along the line using mapscript or something - but 
>>>>>>> then
>>>>>>> how would we make sure that it was always at right angles to the 
>>>>>>> line?
>>>>>>> I guess we would have to do some fancy geometry to figure out what
>>>>>>> angle that section of line was... sounds hard!
>>>>>>>
>>>>>>> Mind you it may be the only way - thanks for your help!
>>>>>>>
>>>>>>> Stu
>>>>>>>
>>>>>>> Blaise wrote:
>>>>>>>            
>>>>>>>> Le Vendredi 26 Mai 2006 16:23, Stuart Eve a écrit :
>>>>>>>>              
>>>>>>>>> Dear All,
>>>>>>>>>
>>>>>>>>> We have been trying to get symbols to rotate along a line in
>>>>>>>>> mapserver (4.8.3). Basically we want to get a small triangle
>>>>>>>>> pointing either 45 degrees or 270 degrees to a line.
>>>>>>>>>
>>>>>>>>> We firstly tried using PIXMAPs - but I don;t think its possible to
>>>>>>>>> rotate these at all (is that true?) plus they do not seem to 
>>>>>>>>> follow
>>>>>>>>> the line and always just point 'up'.
>>>>>>>>>
>>>>>>>>> So we then tried using some truetype symbols - these follow the 
>>>>>>>>> line
>>>>>>>>> - but seem to be rather erratic as to which way they point. We are
>>>>>>>>> using a small triangle from the webdings.ttf set - and 
>>>>>>>>> sometimes it
>>>>>>>>> will point up and sometimes it will point down (but even if its on
>>>>>>>>> the same section of the line).
>>>>>>>>>
>>>>>>>>> Does anyone have any pointers?
>>>>>>>>>
>>>>>>>>> Thanks in advance
>>>>>>>>>
>>>>>>>>> Stu
>>>>>>>>>                 
>>>>>>>> Hi Stu
>>>>>>>> Well, not sure about that, but sometimes it's hard to have the
>>>>>>>> symbols exactly where you want. Perhaps you could create a special
>>>>>>>> layer (point or annotation) to deal with your triangles. It should
>>>>>>>> then be easier to manipulate. Of course it's extra data, extra 
>>>>>>>> code,
>>>>>>>> extra mapfile parsing and so on but you'll have your symbols where
>>>>>>>> you want and well rotated. Regards
>>>>>>>> Blaise
>>>>>>>>               
>>
>>
>>
>>   
> 
> 



More information about the mapserver-users mailing list