def simplify(self, coords, tolerance=0.0001): ''' Simplify the raw polyline ''' raw = LineString(coords) # don't store raw, too heavy self.simple = raw.simplify(tolerance) return self.simple
def simplify(self, coords, tolerance=0.0001): ''' Simplify the raw polyline ''' raw = LineString(coords) # don't store raw, too heavy self.simple = raw.simplify(tolerance) return self.simple
def analyse_route(self, route_id): route = self.routes[route_id] shape = self.gtfs.shapes[route_id] pnts = [(x[1], x[0]) for x in shape['points']] line = LineString(pnts, srid=WGS84_SRID) print line line.transform(TARGET_SRID) #for trip_id in route.keys(): print line.length for trip_id in ('21032013201700', ): print trip_id pnts = [(s[1], s[0]) for s in route[trip_id]['points']] sample_line = LineString(pnts, srid=WGS84_SRID) sample_line.transform(TARGET_SRID) sample_line = sample_line.simplify(4) sample_line.transform(WGS84_SRID) for s in route[trip_id]['points']: pnt = Point(s[1], s[0], srid=WGS84_SRID) pnt.transform(TARGET_SRID) dist = line.project(pnt) print "%s %f" % (s, dist) print route.keys()