def isochrones( client, locations, profile='driving-car', range_type='time', intervals=None, segments=None, units=None, location_type=None, smoothing=None, attributes=None, # options=None, intersections=None, dry_run=None): """ Gets travel distance and time for a matrix of origins and destinations. :param locations: One pair of lng/lat values. :type locations: list or tuple of lng,lat values :param profile: Specifies the mode of transport to use when calculating directions. One of ["driving-car", "driving-hgv", "foot-walking", "foot-hiking", "cycling-regular", "cycling-road", "cycling-safe", "cycling-mountain", "cycling-tour", "cycling-electric",]. Default "driving-car". :type profile: string :param range_type: Set 'time' for isochrones or 'distance' for equidistants. Default 'time'. :type sources: string :param intervals: Ranges to calculate distances/durations for. This can be a list of multiple ranges, e.g. [600, 1200, 1400] or a single value list. In the latter case, you can also specify the 'segments' variable to break the single value into more isochrones. In meters or seconds. Default [60]. :type intervals: list of integer(s) :param segments: Segments isochrones or equidistants for one 'intervals' value. Only has effect if used with a single value 'intervals' parameter. In meters or seconds. Default 20. :type segments: integer :param units: Specifies the unit system to use when displaying results. One of ["m", "km", "m"]. Default "m". :type units: string :param location_type: 'start' treats the location(s) as starting point, 'destination' as goal. Default 'start'. :type location_type: string :param smoothing: Applies a level of generalisation to the isochrone polygons generated. Value between 0 and 1, whereas a value closer to 1 will result in a more generalised shape. :type smoothing: float :param attributes: 'area' returns the area of each polygon in its feature properties. 'reachfactor' returns a reachability score between 0 and 1. 'total_pop' returns population statistics from https://ghsl.jrc.ec.europa.eu/about.php. One or more of ['area', 'reachfactor', 'total_pop']. Default 'area'. :type attributes: list of string(s) :param options: not implemented right now. :type options: dict :param intersections: not implented right now. :type intersections: boolean :param dry_run: Print URL and parameters without sending the request. :param dry_run: boolean :raises ValueError: When parameter has invalid value(s). :rtype: call to Client.request() """ validator.validator(locals(), 'isochrones') params = {"locations": convert._build_coords(locations)} if profile: params["profile"] = profile if range_type: params["range_type"] = range_type if intervals: params["range"] = convert._comma_list(intervals) if segments: params["interval"] = str(segments) if units: # if units and (range_type == None or range_type == 'time'): # raise ValueError("For range_type time, units cannot be specified.") params["units"] = units if location_type: params["location_type"] = location_type if smoothing: params["smoothing"] = convert._format_float(smoothing) if attributes: params["attributes"] = convert._pipe_list(attributes) return client.request("/isochrones", params, dry_run=dry_run)
def pelias_search(client, text, focus_point=None, rect_min_x=None, rect_min_y=None, rect_max_x=None, rect_max_y=None, circle_point=None, circle_radius=None, sources=None, layers=None, country=None, size=None, dry_run=None): """ Geocoding is the process of converting addresses into geographic coordinates. This endpoint queries directly against a Pelias instance. :param text: Full-text query against search endpoint. Required. :type text: string :param focus_point: Focusses the search to be around this point and gives results within a 100 km radius higher scores. :type query: list or tuple of (Long, Lat) :param rect_min_x: Min longitude by which to constrain request geographically. :type rect_min_x: float :param rect_min_y: Min latitude by which to constrain request geographically. :type rect_min_y: float :param rect_max_x: Max longitude by which to constrain request geographically. :type rect_max_x: float :param rect_max_y: Max latitude by which to constrain request geographically. :type rect_max_y: float :param circle_point: Geographical constraint in form a circle. :type circle_point: list or tuple of (Long, Lat) :param circle_radius: Radius of circle constraint in km. Default 50. :type circle_radius: integer :param sources: The originating source of the data. One or more of ['osm', 'oa', 'wof', 'gn']. Currently only 'osm', 'wof' and 'gn' are supported. :type sources: list of strings :param layers: The administrative hierarchy level for the query. Refer to https://github.com/pelias/documentation/blob/master/search.md#filter-by-data-type for details. :type layers: list of strings :param country: Constrain query by country. Accepts a alpha-2 or alpha-3 digit ISO-3166 country code. :type country: str :param size: The amount of results returned. Default 10. :type size: integer :param dry_run: Print URL and parameters without sending the request. :param dry_run: boolean :raises ValueError: When parameter has invalid value(s). :raises TypeError: When parameter is of the wrong type. :rtype: call to Client.request() """ validator.validator(locals(), 'pelias_search') params = {'text': text} if focus_point: params['focus.point.lon'] = convert._format_float(focus_point[0]) params['focus.point.lat'] = convert._format_float(focus_point[1]) if rect_min_x: params['boundary.rect.min_lon'] = convert._format_float(rect_min_x) # if rect_min_y: params['boundary.rect.min_lat'] = convert._format_float(rect_min_y) # if rect_max_x: params['boundary.rect.max_lon'] = convert._format_float(rect_max_x) # if rect_max_y: params['boundary.rect.max_lat'] = convert._format_float(rect_max_y) # if circle_point: params['boundary.circle.lon'] = convert._format_float(circle_point[0]) # params['boundary.circle.lat'] = convert._format_float(circle_point[1]) # if circle_radius: params['boundary.circle.radius'] = circle_radius if sources: params['sources'] = convert._comma_list(sources) if layers: params['layers'] = convert._comma_list(layers) if country: params['boundary.country'] = country if size: params['size'] = size return client.request("/geocode/search", params, dry_run=dry_run)
def pelias_reverse(client, point, circle_radius=None, sources=None, layers=None, country=None, size=None, dry_run=None): """ Reverse geocoding is the process of converting geographic coordinates into a human-readable address. This endpoint queries directly against a Pelias instance. :param point: Coordinate tuple. Required. :type point: list or tuple of [Lon, Lat] :param circle_radius: Radius around point to limit query in km. Default 1. :type circle_radius: integer :param sources: The originating source of the data. One or more of ['osm', 'oa', 'wof', 'gn']. Currently only 'osm', 'wof' and 'gn' are supported. :type sources: list of strings :param layers: The administrative hierarchy level for the query. Refer to https://github.com/pelias/documentation/blob/master/search.md#filter-by-data-type for details. :type layers: list of strings :param country: Constrain query by country. Accepts a alpha-2 or alpha-3 digit ISO-3166 country codes. :type country: str :param size: The amount of results returned. Default 10. :type size: integer :param dry_run: Print URL and parameters without sending the request. :param dry_run: boolean :raises ValueError: When parameter has invalid value(s). :rtype: dict from JSON response """ validator.validator(locals(), 'pelias_reverse') params = dict() params['point.lon'] = convert._format_float(point[0]) params['point.lat'] = convert._format_float(point[1]) if circle_radius: params['boundary.circle.radius'] = str(circle_radius) if sources: params['sources'] = convert._comma_list(sources) if layers: params['layers'] = convert._comma_list(layers) if country: params['boundary.country'] = country if size: params['size'] = size return client.request("/geocode/reverse", params, dry_run=dry_run)
def pelias_autocomplete(client, text, focus_point=None, rect_min_x=None, rect_min_y=None, rect_max_x=None, rect_max_y=None, country=None, sources=None, layers=None, dry_run=None): """ Autocomplete geocoding can be used alongside /search to enable real-time feedback. It represents a type-ahead functionality, which helps to find the desired location, without to require a fully specified search term. This endpoint queries directly against a Pelias instance. For fully documentation, please see https://github.com/pelias/documentation/blob/master/autocomplete.md :param text: Full-text query against search endpoint. Required. :type text: string :param focus_point: Focusses the search to be around this point and gives results within a 100 km radius higher scores. :type query: list or tuple of (Long, Lat) :param rect_min_x: Min longitude by which to constrain request geographically. :type rect_min_x: float :param rect_min_y: Min latitude by which to constrain request geographically. :type rect_min_y: float :param rect_max_x: Max longitude by which to constrain request geographically. :type rect_max_x: float :param rect_max_y: Max latitude by which to constrain request geographically. :type rect_max_y: float :param country: Constrain query by country. Accepts a alpha-2 or alpha-3 digit ISO-3166 country codes. :type country: str :param sources: The originating source of the data. One or more of ['osm', 'oa', 'wof', 'gn']. Currently only 'osm', 'wof' and 'gn' are supported. :type sources: list of strings :param layers: The administrative hierarchy level for the query. Refer to https://github.com/pelias/documentation/blob/master/search.md#filter-by-data-type for details. :type layers: list of strings :param dry_run: Print URL and parameters without sending the request. :param dry_run: boolean :raises ValueError: When parameter has invalid value(s). :raises TypeError: When parameter is of the wrong type. :rtype: dict from JSON response """ validator.validator(locals(), 'pelias_autocomplete') params = {'text': text} if focus_point: params['focus.point.lon'] = convert._format_float(focus_point[0]) params['focus.point.lat'] = convert._format_float(focus_point[1]) if rect_min_x: params['boundary.rect.min_lon '] = convert._format_float(rect_min_x) if rect_min_y: params['boundary.rect.min_lat '] = convert._format_float(rect_min_y) if rect_max_x: params['boundary.rect.max_lon '] = convert._format_float(rect_max_x) if rect_max_y: params['boundary.rect.max_lon '] = convert._format_float(rect_max_y) if country: params['boundary.country'] = country if sources: params['sources'] = convert._comma_list(sources) if layers: params['layers'] = convert._comma_list(layers) return client.request("/geocode/autocomplete", params, dry_run=dry_run)