Is there a numeric road identifier in google maps? - google-maps

I'm looking for a way to identify roads or streets on google maps.
I don't need the road name, just an identifier for a road. And I don't really care if GPS coordinate is really on the road as long as the results are consistent.
I need this in order to determine if two GPS coordinates are on the same road.
Now I know I can compare the road name between the two coordinates using geocoder but In some cases the road name is null, and I actually don't care about the name itself.
Is there any road ID that I can get using a geocoder ?

What do you mean by the 'same road'?
A road can have many different names and designations at the same time and over its length.
Consider Route 66 do you want to be considered to be on the same road if you are on the same road if your two locations are on route 66 near Los Angeles and Chicago or is it a series of different roads as wends its way through the cities en-route?
Should a road have a different id if has an arbitrary name change as it goes round a bend or crosses from one town to the next?

Related

Different placeID gives the same address information

Below two placeID's gives the same address.
1. EicyMDEgU291dGggTG93cnkgU3RyZWV0LCBTbXlybmEsIFROLCBVU0EiMRIvChQKEgm7_A4lPAxkiBEptR2cpqTb1xDJASoUChIJT4MxvQIMZIgRENDVZ6XiGTc
2. ChIJBbYyJDwMZIgR1TtBueaig5w
PlaceID1 was returned when the address searched using the autocomplete was " 201 South Lowry Street" and PlaceID2 was returned when the address searched using the autocomplete was " Goodwill Industries of Middle Tennessee 201 South Lowry Street".
Even though the above addresses are different, the place details API gives the same address information.
https://maps.googleapis.com/maps/api/place/details/json?place_id=EicyMDEgU291dGggTG93cnkgU3RyZWV0LCBTbXlybmEsIFROLCBVU0EiMRIvChQKEgm7_A4lPAxkiBEptR2cpqTb1xDJASoUChIJT4MxvQIMZIgRENDVZ6XiGTc&key=API_KEY
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJBbYyJDwMZIgR1TtBueaig5w&key=API_KEY
Question :
1. Why is the same address which is of the street returned for two different placeID's?
2. The location returned by places Details API is correct but the address is of the street.
Below are few more examples where I observed same scenarios. Could you please brief on the below mentioned examples also?
PlaceID : ChIJZ2fZgcNVZIgRRY-uzGW9IBc and ChIJi15Hp8RVZIgRojWuKm_aG3M returned the same address as "2008 Memorial Boulevard Springfield Tennessee United States 37172", but the straight line distance between the two places is approximately 154 meters.
PlaceID : EiBBbm5leCBBdmVudWUsIE5hc2h2aWxsZSwgVE4sIFVTQSIuKiwKFAoSCd8ldk-TYWSIEZbufa-nQvmSEhQKEgk9kOsTMuxkiBGg2umh0Lk_fQ and ChIJ9ynrOIthZIgR-_7_cmwzeXo returned the same address as "3736, Annex Avenue Nashville Tennessee 37209" , but the straight line distance between the two places is approximately 6.92 meters.
PlaceID : ChIJTZvXpuJ7ZIgR8GqA7eDu5oY and ChIJ3ZUKweJ7ZIgRBjj8OqdMm5E returned the same address as "1777, Galleria Boulevard Franklin Tennessee 37067 " , but the straight line distance between the two places is approximately 12.24 meters.
PlaceID : EicyMDEgU291dGggTG93cnkgU3RyZWV0LCBTbXlybmEsIFROLCBVU0EiMRIvChQKEgm7_A4lPAxkiBEptR2cpqTb1xDJASoUChIJT4MxvQIMZIgRENDVZ6XiGTc and ChIJBbYyJDwMZIgR1TtBueaig5w returned the same address as "201 S Lowry St, Smyrna, TN 37167, United States " , but the straight line distance between the two places is approximately 97 meters.
Please note that it's possible for each place or feature to have similar addresses. This is why the Places API used Place IDs instead to uniquely identify the place/feature. As per this doc:
Place IDs uniquely identify a place in the Google Places database and
on Google Maps.
Below is my investigation on the addresses you have mentioned:
The place ID, ChIJZ2fZgcNVZIgRRY-uzGW9IBc, is of type, premise. As per the Address Types doc here:
Premise indicates a named location, usually a building or collection
of buildings with a common name.
If you think that a collection of building should not have the same address as the Place ID, ChIJi15Hp8RVZIgRojWuKm_aG3M, then I suggest that you report this Maps Data issue. (I'll put some more details on how to report Maps Data issues below)
The address returned for EiBBbm5leCBBdmV...iBGg2umh0Lk_fQ is an address of a route (Annex Ave, Nashville, TN 37209, USA), which is not the same as the the second Place ID's (ChIJ9ynrOIthZIgR-_7_cmwzeXo) address (3734 Annex Ave, Nashville, TN 37209, USA).
For the Item #3, what I can see is that the place ChIJTZvXpuJ7ZIgR8GqA7eDu5oY is a street_address while the other feature (ChIJ3ZUKweJ7ZIgRBjj8OqdMm5E) is a point_of_interest. These two features does not seem to be related so I believe that this is another Maps Data issue which can also be reported.
The feature, EicyMDEgU29...ENDVZ6XiGTc, on the other hand appears to be an inferred street address from a range of addresses. While the place, ChIJBbYyJDwMZIgR1TtBueaig5w, is the actual point_of_interest that's on that same street address. Note that the point of interest may close or move to a new location, but, the street address most likely won't change.
For Maps Data issues, this can be reported using the "Report a
Problem" or "Send feedback" link on the bottom right corner on
maps.google.com or in the Google Maps for Mobile Application. To learn
more, please see this guide. But for Maps Data that are added
using Google My Business, this can be modified directly by the
business owners themselves on their Google My Business account.
I hope this helps!

Determine/create a geofence/bounding box on the fly

I have a MySQL table of lat/lon (think of a school campus or shopping mall).
Each location (school/mall) can have dozens of GPS positions stored in the table. All locations are captured using a mobile app and these locations can represent everything from entrances to specific rooms (conference) to easily identifiable locations such as elevators.
A user submits a request (i.e. janitor cleanup on isle 6) and I need to make sure the request (cleanup) being submitted is within the geofence established by finding the 4 points furthest away from each other for that location.
Currently we're using a Haversine search but we want to convert this to a fenced in system. What we can't do is build a separate geofence table.
I've googled around and not found anything (I'm probably not using the correct terms). How do I build that query?
At the first level of approximation, you can scan for a bounding box.
Say you have a loc table with loc_id, lat, lng columns.
And say your candidate point has the position #ptLat, #ptLng.
Compute the bounding boxes for each location. This works fine with latitude and longitude unless you're within a few degrees of the north or south pole or near 180° longitude.
SELECT loc_id, MAX(lat) north, MAX(lng) east, MIN(lat) south, MIN(lng) west
FROM loc
GROUP BY loc_id
This is fast if you have an index on (loc_id, lat, lng). It's also fast because you can avoid all the trig functions in the Great Circle calculation.
Once you have the bounding box, you can decide whether your candidate point is inside it.
Then you can do
SELECT loc_id
FROM (
SELECT loc_id, MAX(lat) north, MAX(lng) east, MIN(lat) south, MIN(lng) west
FROM loc
GROUP BY loc_id
) box
JOIN ( SELECT #ptLat ptLat, #ptLon, ptLon ) pt
ON ptLat <= north
AND ptLat >= south
AND ptLon <= east
AHD ptLon >= west
This gets you a result set with the loc_id values matching your candidate point.
If your lat,lng data is messy--if it has lots of outlier points--this won't work very well. It's sensitive to errors. For example, if a location in Iceland has lots of points right near it, but one point in Greenland miscoded, the bounding box will be absurdly large.
If it isn't accurate enough for you, you should research convex hull algorithms. But that will take you outside pure SQL, most likely.

Regions of England in Google Maps API

I have a list of latitude/longitude which point to some cities in England.
For each of these coordinates I want to get the region they belong to.
By region, I mean one of these: https://en.wikipedia.org/wiki/Regions_of_England
For instance: For coordinates (53.38112, -1.47008), ie. Sheffield, I need to find Yorkshire and the Humber.
To achieve this, I tried to use Google Reverse Geocoding API:
https://maps.googleapis.com/maps/api/geocode/json?latlng=53.38112,-1.47008&key=
Google then tells me that:
country is United Kingdom
administrative_area_level_1 is England, which is a State (or kind of)
administrative_area_level_2 is South Yorkshire, which is a County
administrative_area_level_3 is Sheffield District, which is a District
So Google returns me the correct State, County and District. However, Region is missing.
Is there any way to obtain it?
Looking at the documentation I don't think the Google API returns such information.
An alternative way to get round this would be to build a list of which counties belong in which of the 9 regions and then look up the region based on the county name. Obviously, this would be a bit of work on your part putting all the county names into a list.
While this doesn't directly answer your query, you could use a set of polygons which trace the regions and a point in polygon algorithm (this example is in PHP but the algorithm exists in many languages) which would allow you to check which of the regions any latitude and longitude is in

Getting distance between multiple cities

I'm looking for an easy way to find out the distances in miles (as the crow flies) between multiple cities.
Example (New York):
New York, NY - Tampa, FL
New York, NY - Las Vegas, NV
New York, NY - Moscow, Russia
etc
I have over 20 cities that I need to determine the distance between... That's a lot of looking up to do manually (not just between the main city and other cities but between every city and every city)...
Any ideas?
Once you get the latitude/longitude from the Google Maps API geocoder, you can use the Geometry library to calculate the distances between them.
http://code.google.com/apis/maps/documentation/javascript/geocoding.html
http://code.google.com/apis/maps/documentation/javascript/geometry.html#Distance
The Google Maps API might help you get the Latitude and Longitude of each, then you could use an algorithm (like http://www.movable-type.co.uk/scripts/latlong.html) to calculate the distances.

How to map google Geocoding API results to simple City, Region, Country

I have some markers on a map and when the user click them I use the google geocoder to get the address information. The issue is the format that Google returns this data. I want to display the address in a consistent format such as
Vancouver, British Columbia, Canada
Seattle, Washington, United States
Sydney, New South Wales, Australia
does any one know a simple way to parse this data so I end up with some nice simple json like
{"city":"Vancouver", "region":"British Columbia", "country":"Canada"}
Thanks.
Oh man, the days when I thought political geography was this simple were sweeter days. If Google could return data like this, they surely would. Instead you get a mess of locality, sublocality, administrative_area_level_*, country, etc.
To illustrate this, consider the following:
http://maps.googleapis.com/maps/api/geocode/json?address=11215&sensor=false
http://maps.googleapis.com/maps/api/geocode/json?address=10010&sensor=false
For Manhattan, you're in okay shape. You get the borough (Manhattan), the city (New York), the county (New York), and the state (New York). For Brooklyn, things aren't so clean. You get the borough (Brooklyn), the county (Kings), and the state (New York).
Now if you go a little ways out onto Long Island, you get more fun:
http://maps.googleapis.com/maps/api/geocode/json?address=40.723464,%20-73.716282&sensor=false
In this case you get the village (Floral Park), the town (Hempstead), the county (Nassau), and the state (New York), but everything is kind of muddled up.
This is the variation within 20 miles in one state. If you move out of that, you can count on even less. In the UK, what most of what we'd want to see as London, will be some smaller borough of Greater London.
Google provides a deep and rich taxonomy to deal with this variation, but you will still need to apply your own rules to make sense of it (often at the state by state and country by country level)