Sanitizing location data - facebook

I have a database of city names, but the problem is that it is not sanitized. For example, if Bangalore, India is a city then I might have the following locations in my database:
Bangalore
Bangalore, India
Bangulore, India (misspelled)
Bangalore,top city, India
Bangalore, metropolitan, india
Now I would like to sanitize this data so that the only entry that remains after the sanitation is "Bangalore, India".
I could use the data that LinkedIn or Facebook has, but I don't know if this is possible or not? Another approach could be to have a master list of city names and sanitize based on that, but this seems like a costly approach. Ideally, I'm looking for a service that would return the best matched city from a correct data set, when I'm passing any city name (correct or incorrect) as input. Any pointers would be appreciated.

Related

For `America`, why doesn't OpenStreetmap return the country `USA` at all? How to add such an alias to the Nominatim server?

As per title,
I do not understand why searching for America does not return the country USA at all, even up to the top 50 results.
What can I do to change this (I think we should return the country USA at least within the top 30 results)? Is there some alias I can add to the database?
Openstreetmap API: https://www.openstreetmap.org/search?query=america
Nominatim search API: https://nominatim.openstreetmap.org/search?q=america&format=jsonv2&addressdetails=1&namedetails=1&dedupe=1&extratags=1&limit=50
This is because so far no one thought about "America" as an alternative name for the United States of America in English. E.g. you got the colloquial name "Amerika" added for some languages as a place name or alternative name, but so far not "America".
So if you do think that "America" is used in English as an alternative for the USA, you might add the alt_name:en=America tag to this relation:
https://www.openstreetmap.org/relation/148838

REST API structure for multiple countries

I'm designing a REST API where you can search for data in different countries, but since you can search for the same thing, at the same time, in different countries (max 4), am I unsure of the best/correct way to do it.
This would work to start with to get data (I'm using cars as an example):
/api/uk,us,nl/car/123
That request could return different ids for the different countries (uk=1,us=2,nl=3), so what do I do when data is requested for those 3 countries?
For a nice structure I could get the data one at the time:
/api/uk/car/1
/api/us/car/2
/api/nl/car/3
But that is not very efficient since it hits the backend 3 times.
I could do this:
/api/car/?uk=1&us=2&nl=3
But that doesn't work very well if I want to add to that path:
/api/uk/car/1/owner
Because that would then turn into:
/api/car/owner/?uk=1&us=2&nl=3
Which doesn't look good.
Anyone got suggestions on how to structure this in a good way?
I answered a similar question before, so I will stick to that idea:
You have a set of elements -cars- and you want to filter it in some way. My advice is add any filter as a field. If the field is not present, then choose one country based on the locale of the client:
mydomain.com/api/v1/car?countries=uk,us,nl
This field should dissapear when you look for a specific car or its owner
mydomain.com/api/v1/car/1/owner
because the country is not needed (unless the car ID 1 is reused for each country)
Update:
I really did not expect the id of the car can be shared by several cars, an ID should be unique (like a primary key in a database). Then, it makes sense to keep the country parameter with the owner's search:
mydomain.com/api/v1/car/1/owner?countries=uk,us
This should return a list of people who own a car with the id 1... but for me this makes little sense as a functionality, in this search I'll only allow one country:
mydomain.com/api/v1/car/1/owner?country=uk

Find data near to user location with split data in Xcode

I'm trying to figure out how i can find data (from JSON) near to the users location on iPhone.
My input consists out of 2 parts, so in order to get to the city and address, I have to get an ID from the province where the user is located.
Province (with ID to go to all Json data of the province)
Data
(Every piece of data has a name, city, address, ...)
Is it possible to find the province where the user is located. Then pass its ID to search the list of data for near to the user located events by reversing all the addresses and cities into coordinates,...?
I'm pretty new to location based programming! Any help is appreciated!
Thank you very much!
The first thing you'll want to do is add CoreLocation to your app. This tutorial shows you how to do that. This will give you the latitude and longitude of your current location.
The next thing you'll want to do is reverse geocode your coordinates. One common API for this is the Google Geocoding API. That will give you your province name.

Guess location from city

I am developing a site where users can find/post - well, let's say - "things". These "things" have name, description, etc.. and the most important information about them is their location. The location consists of the city (country, sometimes state) and the street.
There is no separate input for country and state, because I want it to be filled automatically, I would like to give a list for the city, where the country and the state is given (for example the user types new, then he gets New York, NY, and other guesses.
My question is, that how could I do this most efficiently? (The site can be used from all over the world)
Thanks
You should use a service such as Geobytes API. It will provide you a way to autocomplete the city name, and then get its country, region, latitude/longitude, currency, etc.
You can perform up to 50,000 requests a day, which is enough for many cases.
Does it answer your question ?

Is there a chance that street and zipcode data wasn't enough to populate full address

I have a form where I ask the user to input their mailing address. Would there be any issues with asking only street address and zipcode and omitting city and state?
User zipcode in conjunction with zipcode database would result in having full address of the user. Would that be reliable considering that zipcode database is accurate?
Marcin,
There is not a one to one relationship between city and zipcode. A city can have multiple zipcodes. A zipcode can cross city lines.
Brian
I wouldn't do that.
A ZIP code can contain two different towns, each with a "#123 Main Street" address.
A ZIP code may cross state lines, which means you don't have enough information for shipping/tax details.
You'll have a very hard time dealing with any customers who live outside of the USA.