Class: GoogleMapsPlatform::RoadsApiController
- Inherits:
-
BaseController
- Object
- BaseController
- GoogleMapsPlatform::RoadsApiController
- Defined in:
- lib/google_maps_platform/controllers/roads_api_controller.rb
Overview
RoadsApiController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#nearest_roads(points) ⇒ ApiResponse
This service returns individual road segments for a given set of GPS coordinates.
-
#snap_to_roads(path, interpolate: nil) ⇒ ApiResponse
This service returns the best-fit road geometry for a given set of GPS coordinates.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from GoogleMapsPlatform::BaseController
Instance Method Details
#nearest_roads(points) ⇒ ApiResponse
This service returns individual road segments for a given set of GPS coordinates. This services takes up to 100 GPS points and returns the closest road segments for each point. The points passed do not need to be part of a continuous path. snapped. The points parameter accepts a list of latitude/longitude pairs. Separate latitude and longitude values with commas. Separate coordinates with the pipe character: “|”. For example: ‘points=60.170880,24.942795|60.170879,24.942796|60.170877,24.942796`.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/google_maps_platform/controllers/roads_api_controller.rb', line 62 def nearest_roads(points) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/v1/nearestRoads', Server::DEFAULT) .query_param(new_parameter(points, key: 'points') .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(NearestRoadsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', '400 BAD REQUEST', NearestRoadsErrorResponseException)) .execute end |
#snap_to_roads(path, interpolate: nil) ⇒ ApiResponse
This service returns the best-fit road geometry for a given set of GPS coordinates. This service takes up to 100 GPS points collected along a route, and returns a similar set of data with the points snapped to the most likely roads the vehicle was traveling along. Optionally, you can request that the points be interpolated, resulting in a path that smoothly follows the geometry of the road. The path parameter accepts a list of latitude/longitude pairs. Latitude and longitude values should be separated by commas. Coordinates should be separated by the pipe character: “|”. For example: ‘path=60.170880,24.942795|60.170879,24.942796|60.170877,24.942796`. <div class=“note”>Note: The snapping algorithm works best for points that are not too far apart. If you observe odd snapping behavior, try creating paths that have points closer together. To ensure the best snap-to-road quality, you should aim to provide paths on which consecutive pairs of points are within 300m of each other. This will also help in handling any isolated, long jumps between consecutive points caused by GPS signal loss, or noise.</div> interpolate a path to include all points forming the full road-geometry. When true, additional interpolated points will also be returned, resulting in a path that smoothly follows the geometry of the road, even around corners and through tunnels. Interpolated paths will most likely contain more points than the original path. Defaults to false.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/google_maps_platform/controllers/roads_api_controller.rb', line 34 def snap_to_roads(path, interpolate: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/v1/snaptoroads', Server::DEFAULT) .query_param(new_parameter(path, key: 'path') .is_required(true)) .query_param(new_parameter(interpolate, key: 'interpolate')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SnapToRoadsResponse.method(:from_hash)) .is_api_response(true)) .execute end |