I am trying to solve the problem of "Find point of interest near you" in java. i.e. I have a number of lat,lots of points of interst. And I want to find the ones within say 800 meters. Assuming I know my current lat and log.
My problem is this application has to be stand alone. So I cannot rely on a spatial database query to find the results e.g. using mysql I have found this to be useful: http://xebee.xebia.in/2010/10/28/working-with-geolocations/
Currently I cannot find an in memeory db that supports spatital queries. I was going to resort to using an R-Tree something like http://jsi.sourceforge.net/
But I know that won't be as correct giving the fact it uses a rectange rather than a ciricular search.
Any have any recommendations?
A spatial database — also known as a “geospatial database” — is built to capture and store the points, lines, and areas of cartographic information that we refer to as spatial data.
Spatial database mainly contain representation of simple geometric objects such as 3D objects, topological coverage, linear networks and TINs(Triangulated irregular networks). There are mainly three types of spatial queries as given below. Nearness queries: It request objects that present near a specified location.
In-memory databases are purpose-built databases that rely primarily on memory for data storage, in contrast to databases that store data on disk or SSDs. In-memory data stores are designed to enable minimal response times by eliminating the need to access disks.
There is an In-Memory Database named Altibase which supports Spatial features. It observes OGC specification. You may make use of it.
Actually the jsi library (http://jsi.sourceforge.net) is pretty much perfect for this problem. It was written to support this exact scenario.
When searching for nearby rectangles (or points) you can supply a maximum distance, and it will return the results in order of increasing distance.
It doesn't support the query "return every point within radius of 800m", but in practice you'll want a limit. So the jsi library does support the more useful "return the nearest 50 points within a radius of 800m".
If you really do want every point within a radius, you can increase the number of points to a large number and run a nearestN query, or do an intersection query and filter by distance in your own code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With