2 # vi: set softtabstop=4 shiftwidth=4 tabstop=8 expandtab:
8 from LatLongTools
import *
10 def analyze(stoplist
):
11 home
= [stop
for stop
in stoplist
12 if isinstance(stop
, BusStopMashup
.HomeLocation
)][0]
14 westiest
= min(stop
.location
.longitude
for stop
in stoplist
)
15 eastiest
= max(stop
.location
.longitude
for stop
in stoplist
)
16 northiest
= min(stop
.location
.latitude
for stop
in stoplist
)
17 southiest
= max(stop
.location
.latitude
for stop
in stoplist
)
19 print "\twest-east distance: %f" % (eastiest
- westiest
)
20 print "\twest-east distance: %f km" % longdist(home
.location
.latitude
,
22 print "\tnorth-south distance: %f" % (southiest
- northiest
)
23 print "\tnorth-south distance: %f km" % latdist(southiest
, northiest
)
27 dist
= locdist(stop
.location
, home
.location
)
31 print "\tMax dist from home: %f km" % maxdist
33 print "\tDegree dist from home: %f N, %f S, %f W, %f E" % (
34 home
.location
.latitude
- northiest
,
35 southiest
- home
.location
.latitude
,
36 home
.location
.longitude
- westiest
,
37 eastiest
- home
.location
.longitude
)
39 if __name__
== '__main__':
40 filename
= "grabs/stoplocations.pickle"
42 datapoints
= pickle
.load(open(filename
, "r"))
44 c
= BusStopMashup
.Client()
46 for k
in ('41 antares', 'heron & data centre', 'kent & albert',
47 'carling & preston', 'bank & florence'):
48 datapoints
[k
] = list(c
.findStops(k
))
50 f
= open(filename
, "w")
51 pickle
.dump(datapoints
, f
)
55 analyze(datapoints
[k
])