Building Transitions from the Google Maps API

Problem:

I am trying to flip the geocode to lat / long at the nearest street intersection using the Google Maps API V3. In addition, at the moment this should not be super accurate - since I'm just trying to anonymize the address, and not indicate directions.

I saw that the geocoding result data contains the Address Type Type in the Intersection section, but this does not seem to be compatible at all in the return results - and most often it is not empty.

I also looked at SO a bit for a better way to create this ban, getting it directly from Google, and the closest I saw: How to find the nearest intersection through the Google Maps API? which really does not solve my problem. In light of this, I came up with my own solution and would like to receive some opinions, optimization, constructive criticism or other options.

My preliminary decision:

After playing with the API, I decided to give the following algorithm for the shot (for context only, it is written in C # in a console application):

  • I accept the address and resolve it to lat / long.

  • Then I add or subtract a certain amount of lats or a long time coordinate - in the order of the city block (the distance, which is adjusted for latitude) and get the walking directions between points. I do this for all four directions - so the first modification will be to keep the latitude the same, but subtract some longitude. Then the next modification will be to preserve latitude and add some longitude, etc.

  • After receiving the instructions, I analyze the results and check the start and end address. If they are different, I pull out the street names and consider them as “intersection” (although sometimes this leads to parallel streets - again, just trying to get a stadium).

  • If I do not find two different streets, I expand the distance to the final destination and repeat the process.

So far this has worked quite well, but obviously this is an expensive process, both in terms of time and using my dedicated query limit. In addition, I checked the API terms of service, and while I am including their disclaimer and showing the results on a Google map, I think I'm fine.

My questions for the community:

  • How to increase the efficiency of the algorithm? In particular, the number of times I call the API (implementation code is not a problem)

  • Is there any other way to do this using the Google Maps API? In the SO question discussed above , the decision was related to a loop over building numbers. I don’t know exactly what this means - so any clarification would be great.

  • As mentioned above, I do not think this violates the terms of service - but am I mistaken?

  • Is there any other web interface to use that can satisfy my needs better? Perhaps Bing or some other provider?

Thanks so much for any help.

UPDATE: I ran into the limit of my request for the day, so today I can’t check any offers against Google, but I am also still open to use another API. Thanks.

+6
source share
1 answer

An old question, but since the original poster stated that they are open to solutions other than Google, Geonames has a web API for this for the United States. See GeoNames WebServices Overview and http://www.geonames.org/maps/us-reverse-geocoder.html#findNearestIntersection

+1
source

Source: https://habr.com/ru/post/895776/


All Articles