14

I need a commercial-friendly (Apache Licence, LGPL, Mozilla Public License etc) R-tree implementation in Java, in order to substitute the geonames Web Service for timezones, as suggested in the question "Determine timezone from latitude/longitude without using web services like Geonames.org". I have found some around, but I was wondering if someone has evaluated or used them in practice.

River
  • 8,585
  • 14
  • 54
  • 67
Markos Fragkakis
  • 7,499
  • 18
  • 65
  • 103
  • 1
    Can you elaborate on what is acceptably "commercial-friendly?" – trashgod Sep 15 '11 at 18:37
  • 2
    Java Topology Suite (JTS) from Vivid Solutions with LGPL license contains an R-Tree implementation. I have successfully used JTS in my applications but not the JTS R-Tree implementation. See http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/index/strtree/STRtree.html – Simon C Sep 15 '11 at 20:42
  • 2
    Not directly an R-tree implementation, but recent versions of Apache Lucene have support for efficient geospatial searches. See for example http://www.ibm.com/developerworks/opensource/library/j-spatial/ for more details. – Jukka Zitting Nov 30 '11 at 21:36
  • 1
    Please add these comments as answers so they can be voted on and marked as 'answer'. – parasietje Jan 25 '12 at 10:07

3 Answers3

14
Felipe
  • 16,649
  • 11
  • 68
  • 92
WindRider
  • 11,958
  • 6
  • 50
  • 57
2

First of all let me point out that if You'll look up the nearest city from the given coordinates, it might not be in the same time zone! What you really need, in my opinion, is an information about it administrative affiliation - minimum would be a country, but in some cases it should be even more than that, i.e. state. That information can be retrieved with Google Maps API and then correlated to some more detailed TZ information.

there is a free alternative to GeoNames - EarthTools. There are some limitations to the service itself (number of requests, etc.), but still it's good, tested and working just fine for me.

Second of all - there is a free alternative to GeoNames - EarthTools. There are some limitations to the service itself (number of requests, etc.), but still it's good, tested and working just fine for me.

Third of all - if You would care about importing the data into DB, most of the current DB implementations provide geo spatial indexes that you can use. If You need that information embedded in Your application, you can use H2Database (embeded Java DB) with H2Spatial addition - although I've tried it and I can not recommend it fully. Neo4j have a great spatial index implementation

Additionally You can use Solr for GeoSpatial searches. It's nice, it's quick and it's easy to implement. I'm actually in the middle of the process of migrating my DB searches to Solr...

Last, but not least, below you'll find some of the ones I've tested a while back:

  • JSI - LGPL
  • GeoTools - LGPL, an overkill, will give You far more than what you need... but it's great!

Possibly few more there, but the ones I've tested so far...

Łukasz Rżanek
  • 5,786
  • 27
  • 37
  • Thanks for the answer. I found EarthTools when I was researching, but what deterred me was that "Usage of these services is *currently* free of charge". This was a show stopper for me, as I needed to know that the solution will remain free indefinitely. – Markos Fragkakis Feb 15 '12 at 20:46
  • I would go with Solr or GeoTools then - both are just great. – Łukasz Rżanek Feb 15 '12 at 21:21
0

RTree simple Java class created by me: https://github.com/hadmir/rtree/blob/master/RTree.java

All objects are stored inside two int[] arrays, so it is really easy to persist (to file). Also, fact that adding new rects doesn't create any objects means that you can insert millions of rectangles into RTree and JVM will not burn in flames. This is useful for geo projects, where object counts are usually enormous.

Only 2D rectangles are stored (so, for complex object you need to find bounding rectangle). Query returns all rects (IDs of rects) intersecting or overlapping with "query rectangle".

mirza
  • 1
  • 1