From dd3598df54c6bd7a38c0eb1c4a4ba6dcdfc246d9 Mon Sep 17 00:00:00 2001 From: Fredrik Unger Date: Fri, 26 Oct 2012 09:01:48 +0200 Subject: [PATCH] Adding distance calculation to the Coord class Starting to refactoring the part for plotting muliple coords. --- xinclude/address.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xinclude/address.py b/xinclude/address.py index 3d60b10..fd7e000 100755 --- a/xinclude/address.py +++ b/xinclude/address.py @@ -85,6 +85,11 @@ class Coord(object): yo = int(floor((y-floor(y))*TS)) return (xo, yo) + def distance(self, point): + res = Geodesic.WGS84.Inverse(self.latitude, self.longitude, + point.latitude, point.longitude) + return res['s12'] + def png(self,zoom=15,size=(TS,TS)): filename = encode(self.latitude, self.longitude)+'.png' if path.isfile(filename): @@ -131,7 +136,6 @@ class Coord(object): gridc = grid.crop((xp-TS/2,yp-TS/2,xp+TS/2,yp+TS/2)) gridc.save(filename) - def db_xml(self): uri = etree.Element(DB+'uri',nsmap=NSMAP) ln = etree.SubElement(uri, DB+'link') -- 2.30.2