Nearest geopoint that is on road - osmdroid

I get a geopoint from my database as a response to query.
I need to know the best way to find the nearest point on a road for the recieved geopoint.
Tried to create a table with all geopoints on road, manually, but it is taking too much effort.
Is it possible to get all the points on roads in a city using some queries?
Are there services to get the nearest point on road/nearest road, points on a road?

"Are there services to get the nearest point on road/nearest road, points on a road?"
Yes: routing services. They are particularly good to provide, from any point on the map, the closest point on the closest road.
You can experiment with the OSRM web interface for instance.
When using osmdroid, you can very easily access to routing services by using OSMBonusPack.

Related

Zip-Centroid geo-coding: is there a zip+4 centroid

There is geo-coding by zip-code centroid, but is there a zip+4 centroid which would be more granular yet not quite street-address granularity?
Yes, there is. I work at SmartyStreets, where we validate and geocode street addresses. ZIP+4 is approximately block-level, which sounds like what you're looking for. There are some services that offer this type of geocoding, including ours, LiveAddress.
If you don't need super-precise geocoding (like you would if you were, say, going to skydive onto your buddy's rooftop), then ZIP+4 is most likely going to be the most affordable option, as well. Rooftop-level precision data has to be gathered manually (by companies like Google, etc.) and so it is very expensive.
So yes, it is possible to geocode by ZIP+4 centroid, and it would usually get you within about a street block of your target.

Anybody know a good way to do offline reverse geocoding?

I need to do offline reverse geocoding, meant to run as cron-jobs. Reverse coder should give city, state for millions of 'records'.
What services exist ( paid or free ) that can do 'it'?
I've looked at http://www.geonames.org/, but that's not exactly what I need.
Get a table coordinates of all cities (and which state the city is in). For any coordinate, pick the closest city. For efficient use, encode the table as an R-tree.
For links on R-tree etc, see Reverse Geocoding Without Web Access
Get cities table from geonames, see Given the lat/long coordinates, how can we find out the city/country?
This question is quite old, but I have found another solution besides the popular R-Tree-based solution.
Treap the map as an image, you could run-length-encode the map into a (sorted) list of (x, y1, y2, loc) tuples with the desired resolution. To find the location of a point (a, b), simply find the row where x = a and y1 <= b <= y2.
This solution is efficient as the map has a fixed resolution. Compare to the R-Tree-based solution, It has the advantage of not introducing new libs into existing systems. The data can be efficiently queried by a regular SQL DB as long as (x, y1) is indexed, or queried by running binary searches on a static file.
There is a website (https://reverse-geocoding.com/) that offers such database and free demos on how this works. Disclosure: I'm working on this site.

Google Places vs. Qype vs. others

at the moment I am working on a regional evaluation system.
I actually want to e.g. find out how regions are composed, let us say given
a lat long coordinate and a radius. Hereby I would really like to be able to separate by type and it is also necessary for the data to be up to date.
So which API based services do you recommend, if the following factors are important:
support for lat/long coordinates with search radius
differentiation by type of location
up to date information
As far as I know Google places and qype.com offer APIs which should be able to do so.
Is there a better option or which of the both do you recommend and why?
As far as I found out only Qype and Google Places offer the APIs.
Google offers 1000 requests per day for free while Qype only offers 200,
but one could apply for multiple keys in Qype which enables you to do more requests a day.
With Qype it is possible to check the full amount of commercial establishments in range (bounding box or radius), while google places has a restriction to 60 places per request.
That is the reason why I decided to use Qype.
About whether or not the information is up to date I did not make an evaluation,
but Qype shows reasonable results when applied to Munich.

Geocoding Accuracy

I'm brand new to geocoding and have a relatively large dataset of addresses 100,000+. When I geocode them using MapMarker Professional I get about 10% that I'm not able to geocode with a high level of precision (I get mostly S2 precision values back which mean that it was able to match to a Primary Postal Code centroid, centerpoint of the Primary Postal Code boundary). Each of the addresses has already been standardized so they should be valid (I have taken a random sample and run them through the USPS Zip Code Lookup process to verify this). My question is, should I be able to geocode addresses with a higher degree of accuracy than what I'm seeing or am I expecting too much of the products currently on the market? I've tried geocoding using google and yahoo's services without any better luck. All of the services appear to be able to give me the postal code centroid, but none of them appear to have enough information to be able to give me distinct coordinates for houses in at least 98% of the addresses I send to it.
Thanks for any guidance you can provide,
Jeremy
Geocoding is an imprecise process. The addresses you are geocoding that don't have good precision are likely in rural areas, where it is not uncommon for addresses to be off by up to a mile.
They only know where addresses are by taking the number at the start and end of a street segment, and dividing from there.

Get nearby hospitals or fire stations based on your location?

Is it possible to calculate nearby hospitals or police or fire stations based on your location using geocoding? For instance: If I'm from place Chennai, India. Using Geocoding I need to get the list of all hospitals or police or fire stations nearby Chennai.
If you have a list of the latitude and longitude of those hospitals and fire and police stations (as well as your own latitude and longitude), then sure it is possible. The calculation of the distance between two points on a sphere (like Earth) is called the Haversine formula. You'd have to iterate over each one, calculating how far you were from it. To speed things up, you might want to implement a geospatial index like the ones in MongoDB, SQL Server, Oracle, SOLR, etc.
You can get nearby hospitals, police or fire stations etc based on your location by only using Google Places API though this API is paid so you need to have a billing account to use this API.