iOS Find Location (Latitude,longitude) from Zipcode - iphone

What could be the best way to get location for a given zipcode. Would it work for countries outside US/Canada .Thanks

Use the Google geolocating API (try it out on google.com/maps):
Input for a Swiss ZIP code for example:
CH-9014
or a french one:
FR-34000
or german:
de-12101
or US:
us-90210
or canada:
ca-J5Z 1A1
or china:
cn-100000
for example:
yields
{
"status": "OK",
"results": [ {
"types": [ "postal_code" ],
"formatted_address": "9014 St Gallen, Switzerland",
"address_components": [ {
"long_name": "9014",
"short_name": "9014",
"types": [ "postal_code" ]
}, {
"long_name": "St Gallen",
"short_name": "St Gallen",
"types": [ "locality", "political" ]
}, {
"long_name": "Sankt Gallen",
"short_name": "SG",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "Switzerland",
"short_name": "CH",
"types": [ "country", "political" ]
} ],
"geometry": {
"location": {
"lat": 47.4082855,
"lng": 9.3323890
},
"location_type": "APPROXIMATE",
"viewport": {
"southwest": {
"lat": 47.3991076,
"lng": 9.3180504
},
"northeast": {
"lat": 47.4199564,
"lng": 9.3543340
}
},
"bounds": {
"southwest": {
"lat": 47.3991076,
"lng": 9.3180504
},
"northeast": {
"lat": 47.4199564,
"lng": 9.3543340
}
}
}
} ]
}
So the swiss ZIP code 9014 corresponds appx. to this location:
"lat": 47.4082855,
"lng": 9.3323890
See my answer on the geolocating API here:
How to get GLatLng object from address string in advance in google maps?

GeoNames offers a number of various zipcode geocoding services, including search for the location of a given zipcode. They support a number of various countries.
You would probably be most interested in the Placename Lookup for postalcode service

Google's API comes with some fairly nasty restrictions. Better to use open sources like GeoNames per #Claus Broch's suggestion.
I'm adding this answer to also note that MapQuest has recently put up an API to OpenStreetMap data. It doesn't do (as far as I can tell) zip code searching, but location names, directions, altitude etc are all freely queryable. I recently discovered it an I plan on replacing my calls to google maps API with it as soon as I can.
http://developer.mapquest.com/web/products/open

Related

Getting speed limit based on a single coordinate using here REST API

I want to retrieve speed limit based on a single coordinate(of a road in the USA) using HERE REST API(not PDE). So, I only got the api_key(no app code). I searched and found some solutions which were deprecated and required the PDE api. If anybody knows the latest solution please let me know. Thanks. Anyway I got something which gives speed limit for two coordinates(not my case) and if I put the two coordinates same I get the wrong(very small) value for speed limit. which is given bellow:
https://router.hereapi.com/v8/routes?apiKey=APP_KEY&transportMode=car&origin=-37.956650,145.220673&destination=-37.956650,145.220673&spans=speedLimit&return=polyline
{
"routes": [
{
"id": "0a903f38-aecd-4850-a87e-0848c7583b8a",
"sections": [
{
"id": "4aa23cb0-0209-4e31-bca8-32f4cfb9f98e",
"type": "vehicle",
"departure": {
"time": "2021-02-25T12:52:34+11:00",
"place": {
"type": "place",
"location": {
"lat": -37.9566675,
"lng": 145.2206532
},
"originalLocation": {
"lat": -37.9566501,
"lng": 145.220673
}
}
},
"arrival": {
"time": "2021-02-25T12:52:34+11:00",
"place": {
"type": "place",
"location": {
"lat": -37.9566675,
"lng": 145.2206532
},
"originalLocation": {
"lat": -37.9566501,
"lng": 145.220673
}
}
},
"polyline": "BG1j2soC6iy_0IAA",
"spans": [
{
"offset": 0,
"speedLimit": 27.7777786
}
],
"transport": {
"mode": "car"
}
}
]
}
]
}
Is there any latest rest api service provided by Here that gives speed limit for a geo coordinate(not the pde one)?

can we used world update for France only server ? seems to make wrong query result

On my local overpass api server with only french data on which is applied hourly planet diff, some of the query responses are wrong.
It's not doing it for each query : but something like once every 200 requests , sometime more ...
for example :
[timeout:360][out:json];way(48.359900103518235,5.708088852670471,48.360439696481784,5.708900947329539)[highway];out ;
return 3 ways :
{
"version": 0.6,
"generator": "Overpass API 0.7.54.13 ff15392f",
"osm3s": {
"timestamp_osm_base": "2019-09-23T15:00:00Z",
},
"elements": [
{
"type": "way",
"id": 53290349,
"nodes": [...],
"tags": {
"highway": "secondary",
"maxspeed": "100",
"ref": "L 385"
}
},
{
"type": "way",
"id": 238493649,
"nodes": [...],
"tags": {
"highway": "residential",
"name": "Rue du Stand",
"ref": "C 3",
"source": "..."
}
},
{
"type": "way",
"id": 597978369,
"nodes": [...],
"tags": {
"highway": "service"
}
}
]
}
First one is in Germany, far East ...
My question :
On an overpass api server, is there a way to apply diff only for defined area ? it is not documented ( neither here : https://wiki.openstreetmap.org/wiki/Overpass_API/Installation
or here : https://wiki.openstreetmap.org/wiki/User:Breki/Overpass_API_Installation#Configuring_Diffs )
if not, how to get rid of those wrong results ?
Thanks,
Two questions, so two answer :
i found that there is French diff file existing : http://download.openstreetmap.fr/replication/europe/france/minute/ so i will restart my server with those diffs.
The best way to get rid of those wrong result is to have a consistant server : no world diff for just France Data.

Algolia Places API: How to get the street of a place?

We are evaluation algolia places API and want to use it to find the address of sights. As an example, we want to find "Reichstagsgebäude, Berlin" which works and we get the correct response:
{
"query": "Reichstag, Berlin",
"suggestion": {
"name": "Reichstagsgebäude",
"administrative": "Berlin",
"city": "Berlin",
"country": "Deutschland",
"countryCode": "de",
"type": "address",
"latlng": {
"lat": 52.5186,
"lng": 13.3761
},
"postcode": "10557",
"highlight": {
"name": "Reichstagsgebäude",
"city": "<em>Berlin</em>",
"administrative": "<em>Berlin</em>",
"country": "Deutschland"
},
"value": "Reichstagsgebäude, Berlin, Berlin, Deutschland"
}
}
But how to get the real address of the Building with the Street name and Street Number included, which should be "Platz der Republik 1"
Currently, Algolia Places has street-level precision. We currently only have data for house-level precision (i.e., street name and street number) for France. This is an area we are actively looking to improve, but the data is still in process.

overpass-api ways query include coordinates

I'm trying to query Hotels in a specific area. Unfortunately I need to query nodes and ways, because some Hotels are only stored as way and some as nodes.
http://overpass.osm.rambler.ru/cgi/interpreter?data=%28way[tourism~hotel]%28around:5000,50.10707,8.76040%29%29;out;
The result of a way-query doesn't contain any coordinates, only lots of node-refs:
<nd ref="1438833423"/>
Is there a way also to include the coordinates of the nodes in the output or do have to start lots of additional queries for each node?
Tom
Yes, there are several ways to also get geometries for non-node features via the Overpass API. The easiest is probably to use the center output mode (replace out; with out center;): http://overpass-turbo.eu/s/4O4. Other options would be to fetch the node references in a recursion step: http://overpass-turbo.eu/s/4O5 or using the full geometry output mode.
PS: Don't forget that a hotel can also be mapped as a (multipolygon) relation in OSM, not just as a node or way.
Necromancing.
And to actually answer the question:
[out:json];
way(29858799);
out ids geom;
Which will give you the geometries for each point in the selected way.
{
"version": 0.6,
"generator": "Overpass API",
"osm3s": {
"timestamp_osm_base": "2017-10-06T13:59:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "way",
"id": 29858799,
"bounds": {
"minlat": 47.3604067,
"minlon": 8.5342631,
"maxlat": 47.3612503,
"maxlon": 8.5352457
},
"geometry": [
{ "lat": 47.3612503, "lon": 8.5351944 },
{ "lat": 47.3612252, "lon": 8.5342631 },
{ "lat": 47.3610145, "lon": 8.5342755 },
{ "lat": 47.3610212, "lon": 8.5345227 },
{ "lat": 47.3606405, "lon": 8.5345451 },
{ "lat": 47.3606350, "lon": 8.5343411 },
{ "lat": 47.3604067, "lon": 8.5343545 },
{ "lat": 47.3604120, "lon": 8.5345623 },
{ "lat": 47.3604308, "lon": 8.5352457 },
{ "lat": 47.3606508, "lon": 8.5352328 },
{ "lat": 47.3606413, "lon": 8.5348784 },
{ "lat": 47.3610383, "lon": 8.5348551 },
{ "lat": 47.3610477, "lon": 8.5352063 },
{ "lat": 47.3612503, "lon": 8.5351944 }
]
}
]
}
https://overpass-turbo.eu/
All the options for out are listed here:
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Print_.28out.29

Can I retrieve house number on mapbox reverse geocoder?

Currently when I would like to retrieve address for coordinates I make following request as an example:
GET http://api.tiles.mapbox.com/v3/examples.map-zr0njcqy/geocode/-114.0701,51.0495.json
I get address information up to the street level but NO house number. Is there way to retrieve it as well? I think it's such an obvious need and cannot think of any problems extracting this date when you already extracted the rest.
{
"attribution": {
"mapbox-places": "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox © OpenStreetMap</a> <a class='mapbox-improve-map' href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a>"
},
"query": [
-114.0701,
51.0495
],
"results": [
[
{
"id": "street.31973701",
"lat": 51.0476559,
"lon": -114.0703042,
"name": "3 St SW",
"type": "street"
},
{
"bounds": [
-114.36183200000002,
50.84361600000001,
-113.87432100000002,
51.217528999999985
],
"id": "mapbox-places.10008775",
"lat": 51.03095,
"lon": -114.108491,
"name": "Calgary",
"type": "city"
},
{
"bounds": [
-120.00138351899996,
48.99667665000002,
-110.004763853,
60.00042158400004
],
"id": "province.2553712403",
"lat": 54.872006,
"lon": -115.003552,
"name": "Alberta",
"type": "province"
},
{
"bounds": [
-141.00275000000013,
40.043430830999895,
-47.69751888999983,
86.45371111000011
],
"id": "country.1833980151",
"lat": 76.304456,
"lon": -105.801333,
"name": "Canada",
"type": "country"
}
]
]
}
#rbrundritt is correct.
Most mapping applications (Google, Bing, etc) merely interpolate the location when given a street address. They are aware of the starting and ending address on a given block and then make an educated guess as to where the address you are search for is located on that block based on that. They don't actually store the outlines and the addresses of each property.