[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Length of a PolyLine



Hi List,

at first I would like to thank all of you developers of dia.

I'm using dia for drawing maps where I take some raster data like a .png, put some lines and labels on it and export this as a .png again. I have an example at [1].

Now I would like to measure the length of the red PolyLine at the seaside in a defined unit. My first idea was to use pythagoras in the python console and I wrote this little script which I load with execfile("script.py"):

#!/usr/bin/env python
from math import sqrt
points = dia.active_display().diagram.layers[0].objects[1].properties['poly_points']
distance = 0
size = len(points.value)
for i in range(size):
a = points.value[i]
if i < size-1:
b = points.value[i+1]
distance += sqrt(pow(2,a.x-b.x) + pow(2,a.y-b.y))
print distance


The problem is that the tuple points.value seems not to be ordered thus points.value[42] is not always the same. So what can I do to mesasure the length of this PolyLine correct? Except parsing the .dia xml by hand :-)

best regards
           Chris Burkert

1: http://www.chrisburkert.de/index.php?node_id=96
--
http://www.chrisburkert.de/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK