Determine if the string is a valid geographic location

I have a bunch of "locations" - some of them are accurate (gaborone, botswana), some are geocodes (40.75, -73,997), and some are absolutely useless (#siliconcape). I need to find a way to run the list and determine the city and country of each line and geocode and return zeros for invalid locations.

Is there any library / service / api / method that can be used to determine if a given string matches the actual geographic location? When accounting for typos, order errors, etc.?

+4
source share
2 answers

Probably the easiest method would be to use something like the Google geocoding API . He will take the string and try to parse it into place. You can get output like XML, JSON, CSV.

Here is an example of CSV output:

input : gaborone, botswana output: 200,4,-24.6541100,25.9087390 input : #siliconcape output: 602,0,0,0 input : 40.75,-73.997 output: 200,8,"324 W 30th St, New York, NY 10001, USA" 
+9
source

I think I found a solution - just share it here if someone else needs it:

Use the geocoding of the Google Maps API - send its addresses and get the coordinates. Details for this via PHP: http://www.phpriot.com/articles/google-maps-geocoding/

0
source

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


All Articles