How to search Wikipedia API for pages by location type? - mediawiki

The WikiPedia API shows a way of searching for pages using properties like coordinates and a radius: https://www.mediawiki.org/wiki/Extension:GeoData
Is it possible to make that query and to also filter the the returned results by supported location types: country, satellite, state, adm1st, adm2nd, adm3rd, city, isle, mountain, river, waterbody, event, forest, glacier, airport, railwaystation, edu, pass, camera, landmark?

Related

Best practice for AKA addresses

Using geocode api to get location data and full address details from an address string. This address string might include the property name, city and state or an actual street address. Been using for years with good results. Some buildings, particularly in cities like NY, use multiple addresses. Although the maps pin is in the same location, these equivalents return different coordinates and are not equivalent. Willis Tower, Chicago IL, is the same as 233 S Wacker Dr, Chicago, IL...but not exactly.
Queries are simple...In python...
GMAPS = googlemaps.Client(key=settings.MAPS_TOKEN)
res =GMAPS.geocode(address text string with building name or street address)
with the res, I pull out city,state,county,long,lat...
Is there a technique for identifying equivalence for buildings that have one structure, but multiple possible addresses

Google Maps Autocomplete doesn't include postcodes in address search

For my current project, I have an address lookup for the user to enter an address. In its default state, its results are too ambiguous, and the lookup returns all locations even if it isn't actually an address (eg some of the locations in the list are an entire city or region).
Adding types: ['address'] to the query has solved this; Google now only responds with actual addresses instead of ambiguous regions, however this has lost us the ability to search via postcode, as these two fiddles demonstrate:
http://jsfiddle.net/yj6qvpsg/2/ will list entire cities and regions (bad), but you can still search for an address with a UK postcode (good).
http://jsfiddle.net/yj6qvpsg/1/ will only list addresses (good), but won't search UK postcodes (bad).
How do we get the best of both worlds? I tried playing around with eg, types: ['address', 'postal_code'], but had no luck...
So it turns out that it's only really in the UK that postcodes are tied to physical addresses at street level (you can literally give the house number and postcode as a complete and valid address), while in the rest of Europe a postcode represents a whole region, hence Google considers postcodes as regions throughout.
Maybe one day they'll make an exception for the UK, but in the mean time an alternative if you really need this feature is probably to look at something like: https://getaddress.io/ which might suck if like us your entire data structure is built to match Google's
This came up as the top result for this question, but is massively outdated.
So for anyone looking for a more in-depth search, set Google's Autocomplete to geocode and you can search by:
Street name
District
Town
City
Postcode
Ace!

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

Google maps geocoder state bias

I have a google maps application where users can search by Country, State, City or a street address. Users may be anywhere in the world and they may be searching for anywhere else in the world, not just within their own country.
I need the geocoder to have a bias such that if a state is entered (without the country) it geocodes to the state and not to a city with the same name. Our application prioritises countries first, then states, then cities etc... however the geocoder is not doing the same.
Eg. I want to search for "Victoria" which is a state within Australia.
http://maps.googleapis.com/maps/api/geocode/json?address=victoria shows Victoria, BC, Canada.
http://maps.googleapis.com/maps/api/geocode/json?address=victoria&region=au shows the state of Victoria in Australia however I cannot include the region as my users may be anywhere in the world so I have no way of knowing which region they are searching for.
I have looked at "administrative levels" and also "types" but I cannot find a solution which suits my needs of simply prioritising in the order country > state > city.
I ideally want something like this:
maps.googleapis.com/maps/api/geocode/json?address=victoria&components=administrative_area:WILDCARD
OR
maps.googleapis.com/maps/api/geocode/json?address=victoria&types=administrative_area_level_1
Of course neither of these solutions work but I hope they illustrate what I am trying to achieve.
Any suggestions?
Thanks,
Nicole
You can do a query without specifying the address, use
...?components=administrative_area:victoria
and then iterate over the results.address_components to pick out ones where the types include administrative_area_level_1
Update: I noticed that depending on the search term provided to administrative_area, google is using some kind of heuristics to determine the certainty of the results. If there's a clear winner, then only 1 result is shown. If the matching is similar for a group of locations, then you will get several. So when there's several results, you can pick towards a higher or lower administrative_area_level to suit your needs.

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)