Snap To Road API

Snap To Road API, snaps given GPS points to the road network in the most plausible way. Please note the request might result multiple sub-traces. Large jumps in the timestamps (> 60s) or improbable transitions lead to trace splits if a complete matching could not be found. The algorithm might not be able to match all points. Outliers are removed if they cannot be matched successfully

URL

http://apis.mapmyindia.com/advancedmaps/v1/<lic_key>/snapToRoad?<request parameters>

Method

GET

Request Parameters

The parameters are colour coded based on their requirements. The “Brown” one’s are mandatory, and the “black” one’s are optional

a. Mandatory Parameters:

  1. lic_key: Allocated REST API license key.
  2. pts: Coordinate is pair of comma separated longitude & latitude value, First coordinate will be consider as start point; a last coordinate will be as end points and between are via points (optional); like {longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...]. At present maximum number of points are limited to 100 in a single request.

b. Optional Parameters:

  1. timestamps: Timestamps for the input locations in seconds since UNIX epoch. Timestamps need to be monotonically increasing. Values must be integer {timestamp};{timestamp};{timestamp} ...
  2. geometries: This parameter used to change the route geometry format/density (influences overview and per step). Default value is (polyline) with 5 digit precision; polyline6 for 6digit precision; geojson for geometries as geojson. Please note that “timestamps” parameter is mandatory for enabling geometries.
  3. radiuses: Standard deviation of GPS precision used for map matching. If available use GPS accuracy in meters. Default value is 5m. Values must be integer {radius};{ radius };{ radius } ...

Response Type

JSON: response will served as json

Response Codes {as HTTP response code}

  1. 200: To denote a successful API call.
  2. 204: DB Connection error.
  3. 400: Bad Request, User made an error while creating a valid request.
  4. 401: Unauthorized, Developer’s key is not allowed to send a request
  5. 403: Forbidden, Developer’s key has hit its daily/hourly limit or IP or domain not white-listed
  6. 404: HTTP not found
  7. 412: Precondition Failed, i.e. Mandatory parameter is missing
  8. 500: Internal Server Error, the request caused an error in our systems.
  9. 503: Service Unavailable, during our maintenance break or server downtimes.

Response Parameters

  1. responseCode: Response codes mentioned in above list
  2. version: API versioning details
  3. result: contains responses for input coordinates
    • snappedPoints: Array of Waypoint objects representing all points of the trace in order. If the trace point was omitted by map matching because it is an outlier, the entry will be null. Each Waypoint object has the following additional properties.
      • waypoint_index: Index of the waypoint inside the matched route.
      • location: Location of Matched point (Longitude, Latitude)
  4. matching: An array of Route objects that assemble the trace.
    • s: returns the whole geometry of the route as per given parameter ‘geometries’ default is encoded ‘polyline’ with 5 digit accuracy for positional coordinates.

Sample URL

https://apis.mapmyindia.com/advancedmaps/v1/<lic_key>/snapToRoad?pts=78.40573,17.37317;78.40958,17.37314;78.4 1845,17.37449;78.409992,17.37328;78.420460,17.377443;78.421350,17.380200×tamps=1527056019;1527056020;1 527056021;1527056022;1527056023;1527056024

Sample Response data

Output:

  {
 "responseCode": 200,  
  "version": "161.16",
   "results": { 
    "snappedPoints": [
"waypoint_index": 0,
"location": [ 
78.405729, 
17.373168   
   ] 
},      
{ 
  "waypoint_index": 1,                
  "location": [                     
  78.40958,                     
  17.373151                 
  ]             
  },             
  null,             
  null,             
  {                 
  "waypoint_index": 2,
  "location": [                     
  78.420424,                     
  17.377454                
  ]            
  },             
  {                
      "waypoint_index": 3,                
     "location": [                    
     78.421362,                     
    17.380197                 
       ]             
      }         
     ],         
       "matchings": [            
      {                
         "geometry": "ie`iByrp}MN{HKeMXmOKuGa@gIiAqFeCyHmBuDsBmB_CuAuGeBeP{D"            
           }         
         ]     
       } 
     }