Get Country and Region from Longitude and Latitude without using a webservice - location

Is there a database that I can use to convert longitude and latitude to a country and region. I do not want to use a web service because I will have lots of coordinates to convert.

I've found this website : http://www.boutell.com/zipcodes/
This link provides an archive .zip which contains a CSV file that allow us to search U.S cities by latitude/longitude. I think it will be difficult to find a similar data source for all countries around the world without using webservices.
Otherwise, have try to use a webservice in a script ? That is the only way to verify if it's feasible or not in terms of data volume and there is probably a way to parallelize these treatments if it's necessary.

Related

Is it possible to query multiple Longitude and Latitude loctions from Google APIs with multiple zip codes?

Basically I've a use-case that I need to fetch multiple longitude and latitudes on multiple zip codes. So that I can avoid multiple requests to the Google servers and can reduce costs as well as make my code more efficient.
Request for single request look like below:
https://maps.googleapis.com/maps/api/geocode/json?address=10001&sensor=false&key=<some_key>
And this works fine for the single request. But I want to know if there is some method using which multiple geolocation data can be fetched?

Firebase Location and Validation query

I am in a bit of dilemma.. in the database if have lots of posts which all have a longitude and latitude attribute.
What I am currently doing is observing the whole post group, and then doing the validation on the device. Which will become very heavy if there are more than 1000 or more posts.
if (location (latitude + longitude)).distance(currentUser.location) < 5000
Is there a way to do the validation directly on the database? And keep in mind that the currentUser.location is relative to the device, so I always would need to construct the location from the post and compare it to the current location of the user.
Any help would be much appreciated.
It's possible if you would use something like geohashes. Then you could filter your locations based on their geohash indexes. Or you can also achieve that by creating your data structure based on geohashes. But there's no need for this since there are libraries which do that.
I've created a library for geo queries, check it out.
Or there's also a good library from firebase itself.

Extracting data from bing maps to insert into custom data structures

I'm currently using the Bing Maps API to display a map of a city along with traffic data (such as incident report and traffic flow).
I need to be able to pass a complete list of street segments and intersections of a given area to an AI application to work with. However, all this data, along with the corresponding traffic data I need seems to be bound to the actual map of the API (ie. It can only be displayed and not worked with). Is there any way to extract this information and insert it into a custom made data structure? If not, is there some other map API that is capable of doing this? (although I would prefer work with Bing Maps if possible)
The traffic data can only be used within the Bing Maps controls. This data cannot be extracted from Bing Maps and stored elsewhere. Try taking a look at the HERE Traffic API's: https://developer.here.com/rest-apis/documentation/traffic

How to Use Google BigQuery with the Google Places Library?

I'm looking to use the BigQuery tool to create a table of businesses in the United States, and I want to draw the information from Google Places in order to get certain results from the XML feed to insert into my own database. I'm wondering if that would be possible, and if so, how would I go about doing so?
This might not be possible under the "Google Maps/Google Earth APIs Terms of Service".
Check it at https://developers.google.com/maps/terms

Filter by zip code, or other location based data retrieval strategies

My little site should be pooling list of items from a table using the active user's location as a filter. Think Craigslist, where you search for "dvd' but the results are not from all the DB, they are filtered by a location you select. My question has 2 levels:
should I go a-la-craigslist, and ask users to use a city level location? My problem with this is that you need to generate what seems to me a hard coded, hand made list of locations.
should I go a-la-zipCode. The idea of just asking the user to type his zipcode, and then pool all items that are in the same or in a certain distance from his zip code.
I seem to prefer the zip code way as it seems more elegant solution, but how on earth do one goes about creating a DB of all zip codes and implement the function that given zip code 12345, gets all zipcodes in 1 mile distance?
this should be fairly common "task" as many sites have a need similar to mine, so I am hoping not to re-invent the wheel here.
Getting a Zip Code database is no problem. You can try this free one:
http://zips.sourceforge.net/
Although I don't know how current it is, or you can use one of many providers. We have an annual subscription to ZipCodeDownload.com, and for maybe $100 we get monthly updates with the latest Zip Code data complete with Lat/Longs of the centroid of the zip code.
As for querying for all zips within a certain radius, you are going to need a spatial library of some sort. If you just have a table of zips with lats/longs, you will need a database-oriented mechanism. SQL Server 2008 has the capability built in, and there are open source libraries and commercial libraries that will add such capabilities to SQL Server 2005. The open source database PostgreSQL has a project, PostGIS that adds this capability to that database. It is here: http://postgis.refractions.net/
Other database platforms probably have similar projects, but those are the ones I am aware of. With one of these DB based libraries you should be able to directly query for any zip codes (or any rows of any kind that have lat/long columns) within a given radius.
If you want to go a different route you can use spatial tools with a mapping library. There are open source options here as well, such as SharpMap and many others (Google can help out) that can use the free Tiger maps for the united states as the data source. However, this route is somewhat more complicated and possibly less performant if all you need is a radius search.
Finally, you may want to look into a web service. This, as you say, is a common need, and I imagine there are any number ob web services that you can subscribe to that can provide all zip codes in a given radius from a provided zip code. A quick Google search turned up this:
http://www.zip-codes.com/free-zip-code-tools.asp#radius
But there are MANY resources to be had for the searching on this subject.
how on earth do one [...] implement the function that given zip code 12345, gets all zipcodes in 1 mile distance?
Here is a sample on how to do that:
http://www.codeproject.com/KB/cs/zipcodeutil.aspx
Just to be technical... PostGIS isn't a project of the Postgres community... it's a stand-alone project that is built on top of Postgres. If you want help or support with PostGIS, you'll want to go to it's community instead of Postgres.
You can use PostGIS. Additionally, I've used deCarta's mapping libraries. They have technology which allows you to geokey any arbitrary data type. Then you can query these spatially.
disclaimer: I work for deCarta
Wouldn't it be more efficient to just figure out which cities are within a 1 mile radius and store that information in a table? Then you don't have to do calculations in the database all the time.

Resources