type_ = place.get('properties', {}).get('geocoding', {}).get('type') if type_ == 'city': return marshal(place, geocode_admin) elif type_ in ('street', 'house'): return marshal(place, geocode_addr) elif type_ == 'poi': return marshal(place, geocode_poi) elif type_ == 'public_transport:stop_area': return marshal(place, geocode_stop_area) return place geocodejson = { "places": fields.List(GeocodejsonFeature, attribute='features'), "warnings": ListLit([fields.Nested(beta_endpoint)]), "feed_publishers": ListLit([fields.Nested(feed_publisher_bano), fields.Nested(feed_publisher_osm)]) } class GeocodeJson(AbstractAutocomplete): """ Autocomplete with an external service returning geocodejson (https://github.com/geocoders/geocodejson-spec/) """ # the geocodejson types TYPE_STOP_AREA = "public_transport:stop_area" TYPE_CITY = "city" TYPE_POI = "poi"
'min_date_time': DateTime(), 'max_date_time': DateTime() } graphical_isochrones = { "isochrones": NonNullList(NonNullNested(graphical_isochrone), attribute="graphical_isochrones"), "error": PbField(error, attribute='error'), "feed_publishers": fields.List(NonNullNested(feed_publisher)), "links": fields.List(Links()), "warnings": ListLit([fields.Nested(beta_endpoint)]), } class GraphicalIsochrone(JourneyCommon): def __init__(self): super(GraphicalIsochrone, self).__init__() parser_get = self.parsers["get"] parser_get.add_argument("min_duration", type=unsigned_integer, default=0) parser_get.add_argument("boundary_duration[]", type=unsigned_integer, action="append") @marshal_with(graphical_isochrones)
class GeocodejsonFeature(fields.Raw): def format(self, place): type_ = place.get('properties', {}).get('geocoding', {}).get('type') if type_ == 'city': return marshal(place, geocode_admin) elif type_ in ('street', 'house'): return marshal(place, geocode_addr) return place geocodejson = { "places": fields.List(GeocodejsonFeature, attribute='features'), "warnings": ListLit([fields.Nested(beta_endpoint)]), } #instance marshal places = { "places": NonNullList(NonNullNested(place)), "error": PbField(error, attribute='error'), "disruptions": fields.List(NonNullNested(disruption_marshaller), attribute="impacts"), "feed_publishers": fields.List(NonNullNested(feed_publisher)) }
return marshal(place, geocode_admin) elif type_ in ('street', 'house'): return marshal(place, geocode_addr) elif type_ == 'poi': return marshal(place, geocode_poi) elif type_ == 'public_transport:stop_area': return marshal(place, geocode_stop_area) return place geocodejson = { "places": fields.List(GeocodejsonFeature, attribute='features'), "warnings": ListLit([fields.Nested(beta_endpoint)]), "feed_publishers": ListLit([ fields.Nested(feed_publisher_bano), fields.Nested(feed_publisher_osm) ]) } class GeocodeJson(AbstractAutocomplete): """ Autocomplete with an external service returning geocodejson (https://github.com/geocoders/geocodejson-spec/) """ # the geocodejson types