How to check if a point/address lies on a route? - google-maps

If I have a set of routes between various locations, and I have the lat/long co-ordinates for a point on the map, is it possible to find out if the point lies on any of the routes in my set? Basically if i get a GPS fix on a location, I want to find out if that location lies on any of my pre-determined routes.

This can be a complex computation. You should do this gradually and just check it roughly first. E.g. for every route, keep track of max-lat, max-long, min-lat and min-long. Then you can do a quick check if the point is within the max-min square. If that check is true - your point may be on your route, and you need to do more checks.

Related

Is it possible to extract coordinates from a static map picture?

I was wondering if it were possible to extract coordinates from a static map picture like this:
Is it possible to extract the coordinates of the routes? The only idea I can come up with, other than manually getting them by hand, is by overlaying the map and extracting the exact coordinates that way.
The process that you are looking for is called georeferencing in a GIS context.
In order to determine the latitude/longitude coordinates of a point (or series of points in a line), you need to first establish coordinates of other known points. These are reference points of known locations (such as a distinctive coastline, or a city). Applying these to the raster image that you have, you can then overlay it on a map in a GIS application and then query other unknown locations on the image (such as the routes) to establish their latitude/longitude.
You could attempt this in a graphics program by looking at the x/y coordinates of the route pixels and compare to a known reference point pixel; however, the math on that is going to be tedious and you also wouldn't account for the map projection. Both of those are taken care of by georeferencing.
I would note that you should consider the results you get, even in a well-referenced GIS, to be approximate. The map deals with a very large spatial area, and the routes cover long distances. But since it dates from 2012 it was presumably made in a GIS application and so at least the source data is likely to be accurate :)
Additional resources:
Help Page for ArcGIS (both overview and instructions)
Help Page for QGIS (tutorial)

Given a list of GPS positions, how do I display route using Google Maps API

I have lists of between 100 and 10000 GPS location from vehicles driving around during some timespan.
I want to display that on a Google Map, using their API (with the Business licence if that matters).
As I see it, there are 3 options, all with problems:
1) Draw a polyline between all positions. Some positions are not that accurate so it looks like the route hits some buildings next to the road. I know that all positions are on a road. Also, it cuts some corners, and it doesn't look professional.
2) Display just the GPS positions in the map. This is not good either since the GPS positions are off the road (which they shouldn't be).
3) Draw the route using Maps API. This limits us to using 23 waypoints between the start and end positions. The route looks excellent and it follows the road (GPS positions next to the road are moved to the road automatically). But especially for longer time spans, this option means that the route displayed is incorrect (Google guesses the route taken between the waypoints - so from the 10000 GPS positions it only uses 23). And we can't display a clearly incorrect route.
Does anyone have a good/better way to show a driven route on Google Maps that follows the road but takes into account all/many given GPS positions?
Could you not chain the route using the maps API? It's not something I've done before so this answer could be a little vague but would it not be possible to segment your list of coordinates into chunks of 23 fire the requests and then display the resultant routes on the map?
I'm not overly sure on the return format so it may be necessary to mess with the output in order to give the illusion of the route, also you will likely not need to use every coordinate (perhaps exclude those that are within a small distance of each other for example being stuck at lights), otherwise the requests may take a long time.
We've actually moving away from option 3. The reason is that when the positions get moved to the nearest road, that is not always correct (like if you're driving on a parking lot), so since that doesn't always give the correct route, then we'll not take that path.
So I don't know if it's possible to chain several routes in the same map.

check whether a point lies in a route - Google maps

I need to highlight relevant locations in a google map when a user requests for a route.
I have found a few steps to implement. But got stuck at one point.
Let's assume that we have a collection of large number of points (a few thousands). We need to find out which of them lie in a (dynamic) route.
Step1: First filter out the points based on the route. That means, find the max-lat, min-lat, max-lon, min-lon of the route and apply this filter out to our group. So that we can figure out a lesser number of eligible candidates.
Step2: We can still filter out the unnecessary points using a utility library called RouteBoxer. (http://google-maps-utility-library-v3.googlecode.com/svn/tags/routeboxer/1.0/examples/routeboxer-v3.html)
Step3: After above 2 steps, we have reduced the number of points to a few hundred from a few thousand. And these points would be somewhere around that route, though not exactly on it. This is where I face the challenge. How to check whether these points lie in that route? I dont think getting all the points a route and check the distance is a good solution (yeah, it will work. but..) as the route can be of any distance. Is there any way to check the minimum distance between a point and a route?
RouteBoxer will give you a list of polygons or LatLngBounds (if if gives polygons you can get LatLngBounds fron it anyway). You can cycle through each of your points and check if that point lies on any of those bounds using the contains method of LatLngBounds class.
Yes, there is dijkstra or kruskal algorithm.

Same address Google Maps - any ideas how to facilitate?

So I am trying to think of a way to facilitate two things. It may end up being a two step process in the end but I was looking for input.
The first thing I need to do is accommodate locations with the same address. The two scenarios that come to mind are businesses that share a location and apartment buildings.
The second thing I need to accommodate is a business/nonprofit with no headquarters, just a town. Right now I just map them to the town center, but if multiple businesses have no headquarters I run into the first problem.
So I did some Googling and found a solution that involved having a list of locations alongside the map so you can click on them and the info window will pop up. This isn't a solution for me though.
What I was thinking of was using the location to map the first point. For the second and points after that moving the marker over .05 degrees or something marginal so that the marker shows up. The inherent problem with that is that what happens if 12 Main Street turns into 13 Main Street?
So any thoughts on what I could do?
Thanks
Levi
There's an extension by Martin Pearman called ClusterMarker that detects any groups of two or more markers whose icons visually intersect when displayed. Each group of intersecting markers is then replaced with a single cluster marker that looks different. The cluster marker, when clicked, simply centres and zooms the map in on the markers whose icons previously intersected.
A more advanced approach to this problem might be SQL - same address = same coordinates...
GROUP BY or HAVING COUNT > 1 ... would let you create multi-record coordinates.
In fact - before you can cluster client-side, you need to send out the data first, which means transferring much more than required in this case, which results in higher loading times and higher RAM utilization client-side ...plus all the useless JS processing of the clusterer.
Client-side clustering is only recommend when the coordinates are close to each other, but not when they are absolutely identical.
Think about it...

How to decide the current point reach on google map?

How to decide the current point reach on google map?
I have a list of points (pickup points) of a route that I want to show in my google map with polyline.
Now i have to get the current location of bus after every 30 second, so now how we can assume that our current location is reach on our pickup up point location. because they may be differ in some point in lat & long. I want to send sms for the peoples whose pickup point is next pick up point. so need to find out that the current pickup point reach.
Also there is some scenario when bus not goes on predefined route? How can we do this type of functionality?
err, i dont really understand your entire question, but i think what your asking for is how to know when an object (bus) moving on a route has reached a destination.
I would do it this way. I would define a certain tolerance, maybe 10 meters. If the distance between the destination and my current location is less than 10 meters, that would mean i have reached.
About the bus moving without a route. I reckon you could "tether" the bus to the nearest known node. The bus "tether" would pass from node to node depending on which node is closest to the bus.