Find bounding box and convex hull of agency coverage (as WKT) for a OneBusAway TDS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mustaine.client import HessianProxy | |
from shapely.geometry import box | |
from shapely.ops import cascaded_union | |
service = HessianProxy("http://172.16.2.32:8080/onebusaway-transit-data-federation-webapp/remoting/transit-data-service") | |
agencies = service.getAgenciesWithCoverage() | |
boxes = [] | |
for agency in agencies: | |
minx = agency.lon - (agency.lonSpan / 2) | |
miny = agency.lat - (agency.latSpan / 2) | |
maxx = agency.lon + (agency.lonSpan / 2) | |
maxy = agency.lat + (agency.latSpan / 2) | |
b = box(minx, miny, maxx, maxy) | |
boxes.append(b) | |
bbox = cascaded_union(boxes) | |
hull = bbox.convex_hull | |
print hull.wkt | |
(minx, miny, maxx, maxy) = hull.bounds | |
print "minLat: " + str(miny) | |
print "minLon: " + str(minx) | |
print "maxLat: " + str(maxy) | |
print "maxLon: " + str(maxx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment