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

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

Related

How can I match up user inputs to ambiguous city names?

We have a set of tables shown below we use for our other tables to reference for location data. Some examples are:
Find all companies within X miles of X City
Create a company profile's location as X City
We solve the problem of multiple cities with similar names by matching with State as well, but now we ran into a different set of problems. We use Google's Place Autocomplete for both Geocoding and matching up a users query with our Cities. This works fairly well until Google's format deviates from ours.
Example:
St. Louis !== Saint Louis and
Ameca del Torro !== Ameca Torro
Is there a way to fuzzy match cities in our queries?
Our query to match cities now looks like:
SELECT c.id
FROM city c
INNER JOIN state s
ON s.id = c.state_id
WHERE c.name = 'Los Angeles' AND s.short_name = 'CA'
I've also considered the denormalizing city and simply storing coordinates to still accomplish the radius search. We have around 2 million rows in our company table now so a radius search would be performed on that rather than by city table with a JOIN on company. This would also mean we wouldn't be able to create custom regions (simply anyway) for cities, and add other attributes to cities in the future.
I found this answer but it is basically affirming our way of normalizing input is a good method, but not how we match to our local Table (unless Google offers a City Name export I don't know about).
The short answer is that you can use Postgres's full text search functionality, with a customized search configuration.
Since your dealing with place names, your probably want to avoid stemming, so you can use the simple configuration as a starting point. You can also add stop-words that make sense for place names (with the examples above, you can probably consider "St.", "Saint", and "del" as stop-words).
A pretty basic outline of setting up your customized is below:
Create a stopwords file and put it in your $SHAREDIR/tsearch_data Postgres directory. See https://www.postgresql.org/docs/9.1/static/textsearch-dictionaries.html#TEXTSEARCH-STOPWORDS.
Create a dictionary that uses this stopwords list (you can probably use the pg_catalog.simple as your template dictionary). See https://www.postgresql.org/docs/9.1/static/textsearch-dictionaries.html#TEXTSEARCH-SIMPLE-DICTIONARY.
Create a search configuration for place names. See https://www.postgresql.org/docs/9.1/static/textsearch-configuration.html.
Alter your search configuration to use the dictionary you created in Step 2 (cf. the link above).
Another consideration is how to consider internationalization. It seems that the issue for your second example (Ameca del Torro vs. Ameca Torro) might be a Spanish vs. English representation of the name. If that's the case, you could also consider storing both a "localized" and "universal" (e.g. English) version of the city name.
At the end, your query (using full-text search) might look like this (where the 'places' is the name of your search configuration):
SELECT cities."id"
FROM cities
INNER JOIN "state" ON "state".id = cities.state_id
WHERE
"state".short_name = 'CA'
AND TO_TSVECTOR('places', cities.name) ## TO_TSQUERY('places', 'Los & Angeles')

osm overpass query by country

I am using this Overpass query to extract all coworking amenities in Italy.
( area["ISO3166-1"="IT"];) ->.a;
node["amenity"="coworking_space"]
(area.a);
(._;>;);
out body;
If I try to do the same for France using FR as ISO3166 country code
( area["ISO3166-1"="FR"];) ->.a;
node["amenity"="coworking_space"]
(area.a);
(._;>;);
out body;
I get no results while I am sure there are nodes like that in France (i tested with a separate query using automatic bbox).
Question:
Am I getting wrong the ISO3166 country code of France?
In general, there is a better way to extract osm data from overpass by country?
Thanks,
Jacopo
You should query for the key ISO3166-1:alpha2 or ISO3166-1:alpha3 and use ISO3166-1 only as a fallback. These keys are explained in the country code wiki page.
The relation for the state of Italy has tag ISO3166-1 while the relation for the state of France doesn't. But both have the value you are looking for in the ISO3166-1:alpha2 key.

Openstreetmap Geocoding with housenumber in query

For some geocoding data i use OpenStreetMap.
My adresses are located in germany. The big problem with openstreetmap is, that i have problems to search with my housenumber. The Documentation says that the format is
Because of this my searchquery is:
5 Glogauerstraße
The result is the following:
http://nominatim.openstreetmap.org/search/?format=xml&addressdetails=1&limit=10&q=5%20Glogauerstra%C3%9Fe
This is cool, but there are a lot of results because in germany are a lot of adresses like this. so i will add that this adress must be in BERLIN with the ZIP-Code 10999.
New search-Query:
5 Glogauerstraße, Berlin 10999
Now the result is:
http://nominatim.openstreetmap.org/search/?format=xml&addressdetails=1&limit=10&q=5%20Glogauerstra%C3%9Fe,%20Berlin%2010999
This is nice! Now there is just 1 result!
But the problem is that in this result there isnt the housenumber 5 i was searched for. So the query just "delete" the information of the housenumber.
How can i solve this search query like the way i need it ? Its a big confusing why the openstreet map just delete this information ...
Correct me if I'm wrong but apparently (after searching for the address in the OSM map) OpenStreetMap does not know the housenumbers in this street.
It can correctly geocode this address to approximately accurate coordinates, it is just not accurate enough to know where the house 5 is.
You could possibly try Google Maps services, in my experience it is more accurate in most places.

Sanitizing location data

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.

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 ?