tulsawebdevs / django-multi-gtfs

Django app to import and export General Transit Feed Specification (GTFS)
http://tulsawebdevs.org/
Apache License 2.0
50 stars 32 forks source link

Compress route geometries #24

Closed araichev closed 10 years ago

araichev commented 10 years ago

In https://github.com/tulsawebdevs/django-multi-gtfs/blob/master/multigtfs/models/route.py instead of making the geometry of a route a multilinestring of the list of its trip geometries, i think it would be better to make it a multilinestring of the set of its trip geometries. The latter doesn't contain duplicates and so will result in a smaller file, which is better when displaying routes on web maps.

araichev commented 10 years ago

One way to do this is to replace https://github.com/tulsawebdevs/django-multi-gtfs/blob/master/multigtfs/models/route.py#L162 with

self.geometry = MultiLineString([shape.geometry for shape in set(Shape.objects.filter(trip__route=self))])
jwhitlock commented 10 years ago

I agree w/ minimizing duplication. I'll have to use a slightly different strategy, since some feeds don't have shapes. In this case, the trip geometry is the direct connection of the stops ('as the crow flies').