How to get city by latitude and longtitude? - latitude-longitude

I need to get city name by latitude and longtitude. (Use xcode)
There is google with itself's api geocode, but it don't want to return nearest city (i need only nearest city) and it returns cyrilic names of places. How to solve my problem?

You could use the Geonames.org webservice for "Find nearby populated place / reverse geocoding" (scroll a bit down), see this example.

Related

Enforce MapBox Geocoding API to return only results with a zipcode

I'm working with MapBox Geocoding API to have suggestions of addresses in the location search feature of my website.
The following is a sample call:
https://api.mapbox.com/geocoding/v5/mapbox.places/Zur.json?country=ch&limit=5&proximity=8.765.432&language=en-GB&access_token=***
My goal is to enforce the api to return only results that include a zipcode.
For example if I input "Zur" (limiting the search to Swiss) I get the following:
- Zürich, Zürich, Switzerland
- Zürich, Switzerland
- Zürich Airport, Flughafenstrasse, Kloten, Zürich 8302, Switzerland
- Zurich, Buchs, Zürich 8107, Switzerland
The expected results should be without the first two lines, as they don't have a zipcode.
I tried implementing myself the removal of results without the zipcode on client side (just after I got an answer from the api), but it is a suboptimal solution (for example it doesn't ensure to have enough results).
I was not able to find such feature in MapBox. Is there a better solution out of there?
Just add ?types=address
See all list of types:
https://docs.mapbox.com/api/search/geocoding/#data-types

Issue with google geocode API : Getting "partial_match" in response

I am using google Geocode API to get the lat long of particular address.
when I am searching for "364 S Side Square, Carlinville, IL 62626, USA" in google search or google maps it gives the accurate pin point on google search result or maps result.
but same time when i am searching the same address using Geocode API using below request call, it gives "partial_match" : true
http://maps.googleapis.com/maps/api/geocode/json?address=364 S Side Square, Carlinville, IL 62626, USA&sensor=false
any one knows why it gives "partial_match" : true in response ?
what changes i have to do in the API request so that i won't get "partial_match" ?
To understand the nature of the partial match flag for the '364 S Side Square, Carlinville, IL 62626, USA' let's have a look at this address in geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D364%2520S%2520Side%2520Square%252C%2520Carlinville%252C%2520IL%252062626%252C%2520USA
Indeed, the search string and formatted address in the result are exactly the same, however, we have to pay attention to other values like location_type and place_id
As you can see the location type is RANGE_INTERPOLATED and the place ID has a long value Ei0zNjQgUyBTaWRlIFNxdWFyZSwgQ2FybGludmlsbGUsIElMIDYyNjI2LCBVU0E. This means Google doesn't have an exact address feature in their database and tries to interpolate where this address might be located. In case if address exists in the Google database, you will see a location type ROOFTOP and a shorter place ID (something similar to ChIJrTLr-GyuEmsRBfy61i59si0).
Resuming aforementioned, the partial match flag in your example indicates that exact street address feature doesn't exist in the Google database.
This also can be confirmed by the following sentence in the documentation:
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request.
https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses
You also have an option to report a missing address to Google following the help center:
https://support.google.com/maps/answer/6320846
I hope my answer addresses your doubt!
partial_match indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address.
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. Partial matches may also be returned when a request matches two or more locations in the same locality. For example, "21 Henr St, Bristol, UK" will return a partial match for both Henry Street and Henrietta Street. Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address. Suggestions triggered in this way will also be marked as a partial match.
try place_id which is unique identifier

How can I query Wikidata API to get details of all the Korean films?

If possible, i want to return the results in Json or XML format. Is there any ways to do so? Earlier I did it using freebase.com but it is now deprecated. Please help.
This query would look a lot like the one to get the list of all films on Wikidata but adding another filter:
instead of http://wdq.wmflabs.org/api?q=claim[31:11424] (return all the entities marked as instances of film), you would do
http://wdq.wmflabs.org/api?q=claimCLAIM[31:11424] AND CLAIM[495:884] (return all the entities marked as instances of film and South Korea (Q884) as country of origin (P495))
http://wdq.wmflabs.org/api?q=claimCLAIM[31:11424] AND CLAIM[495:423] (the same for North Korea (Q423))
Then to parse the results and get the entities data, it would be the same as for the list of all the films
Remarques:
you will probably need to encode those URLs to get something that looks like: http://wdq.wmflabs.org/api?q=CLAIM%5B31%3A11424%5D%20AND%20CLAIM%5B495%3A884%5D
here is the full API documentation. Notice that this is an experimental API, which might be replaced in the coming year
The overview on Wikipedia may be more complete than Wikidata, as you've noticed yourself also. However, I could only find overviews per year, such as on https://en.wikipedia.org/wiki/List_of_South_Korean_films_of_2015.
To get a list of titles from that page, you would first retreive the raw wikicode of the page: https://en.wikipedia.org/w/index.php?action=raw&title=List_of_South_Korean_films_of_2015, and then run a regular expression such as /\{lang\|[^\|]+\|([^\}]+)/g on the code.
This returns a list of 149 titles.

Google Maps API Geocode Postal Code and set Country code?

I'm using this API call to Google Maps to get the latitude and longitude of a postal code
http://maps.googleapis.com/maps/api/geocode/json?address=2340&sensor=false
The postal code is in Australia. This API call returns locations all around the world with partial matching postal codes in the address.
Is there a parameter I can use to set the country to Australia?
Thanks
The correct way to do this is not via region biasing but rather using component filtering:
https://maps.google.com/maps/api/geocode/json
?components=country:AU|postal_code:2340
&sensor=false
Some demonstrations:
2340
93274
Please note that if you use the components parameter, you don't need to specify the address parameter.
The documentation says that Region Biasing is based on CcTLDs, which would make Australia au (haven't tried it myself).
Although it also states this:
Note that biasing only prefers results for a specific domain; if more relevant results exist outside of this domain, they may be included.

FourSquare API is giving lots of result but not the result I expect

I am using FourSquare api for searching a particular business
https://api.foursquare.com/v2/users/search?name=Spa Gregories&oauth_token=ACCESS_TOKEN
it is giving lots of result but not the result i expect. that is
Spa Gregories
2710 Via De La Valle, Ste B-270
San Diego, California 92014
when i use https://foursquare.com/search?q=Spa+Gregories&near=san+diago then i got the exact result. So is their any way to find the business according the location. I have only name and city location to use for Search. I have also checked for the venues option but it asks for longitude and latitude.
thnks
Seems you're hitting the user search endpoint instead of the venue search.
Looks like this is the one you want:
https://developer.foursquare.com/docs/venues/search.html