I want to associate the coordinates and street name returned from the "nearest" method on the OSRM routing service with the source OSM Extract. I assume that OSRM create segments from all adjacent nodes in a way and snaps GPS coordinates to the nearest segment? Does it create segments by using geodesics between the coordinates of the nodes? I ask because I want to find the relevant section of the OSM and add some additional markup to the segment returned by OSRM.
Yes OSRM finds the nearest segment by computing the point-segment distance to the input coordinate. To make this scale we keep all segments in a R-tree.
Related
I'm making an application that is uploading data from a gps device (the collection of points of where the vehicle has traveled). I'm having an issue when the vehicle stops or moves very slowly. The gps uploads repeated coordinates, which are unnecessary data.
Is there a way to check whether two (lat,lng) coordinates fall within the same road segment?
Maybe you can check by reverse geocoding and checking the reference-id in response
https://developer.here.com/api-explorer/rest/geocoder/reverse-geocode
Or you can use Route Match Extension to try to get the correct route.
https://developer.here.com/platform-extensions/documentation/route-match/topics/overview.html
I am working with a college to develop their campus iOS app. One of the app's features is the ability to determine which of the campus bus routes are most applicable to getting to a destination (as well as a listing of when the bus arrives, etc).
If I have sets of long/lat data representing the stops of a route, what is the easiest way to determine the closest route to a long/lat destination point? I have over 10 roues to consider.
If you want to determine the closest point to a route, you can use the Distance to a Ray or Segment formula using a lat-lng as the reference point.
There is another option, if you are using a Google Map, because the Terms of Service require that the service be used in the context of a Google Map; you may want to consider the Google Maps Distance Matrix Servicedev-guide. The service allows you to submit a request with an origins property, which must be an array of google.maps.LatLng starting points and a destinations property, which must be an array of google.maps.LatLng ending points. The DistanceMatrixServiceapi-doc also allows you to define a TravelModeapi-doc, which may be one of: BICYCLING, DRIVING, or WALKING. It has the advantage over simple distance calculation, because it accounts for the natural activity of traveling from one point to another using the existing network of streets.
This is the scenario...
I have a set of lat/long data stored in a db table[id, lat, long, location]. I'm using geo-location to get a user's current physical location(lat and long). When this user accesses the app, allows his location to be shared, I want to get those coordinates that are around his current coordinates, and plot them on a Google Map.
How can this be done?
Example: I have the coordinates for hotels in a city stored in my DB table. When a user visits this city and accesses my app, I want to get from my DB and plot on map only those coordinates that are around him in a certain radius.
Note: I'm using PHP for server side stuff.
Any help is appreciated!
You describe a store locator: finding POIs within a radius around a particular point. A store locator finds POIs within a radius around a location. The details in Google's example are different (you find the centre point via browser geolocation and have a fairly small radius) but the principle is exactly the same.
Google's article: developers.google.com/maps/articles/phpsqlajax_v3
Does anyone know if Google Maps consider elevations and the actual path on earth to calculate distance between two points or it only considers geographical locations for distance measurement?
If you are referring to using google.maps.DistanceMatrixRequest then yes, it considers the actual route when calculating distance, based on the option provided in travelMode
code.google.com reference
When there is no established route (at least known to google) i'm sure (from experience) the response is the distance 'as the crow flies' between 2 lat/long locations. [experience based off making the request for a path that bisected a large lake]
Is there a way to determine if a particular address is along a route within x miles? Is there support for this in the Google maps API?
I have a database of addresses and I am trying to figure out which locations lie along a given route as determined by the Google Maps API.
You can set the getPolyline option, on the GDirectionsOptions optional parameter, to the GDirections load request. This will get you the polyline data for the route.
Once you have this data you can iterate over each point in the polyline and determine the distance to each of your own datapoints (you can use the GLatLng distanceFrom method to calculate the distance).
Once you have the shortest distance to your route for each of your data points, you can and work out, based on some tolerance, if the point lies on the route.
Edit:
Although it is fine to call the GLatLng distanceFrom method repeatedly (it is just a utility method to get the distance between two points), I realized my answer simplifies the problem. To get an accurate distance from the route, you will need to determine the distance from the polyline between the closest two points (not just the distance from each point).
Bill Chadwick has "Distance of Point to Polyline or Polygon" code at the bottom of this page, which could prove useful.