Java 商业友好的 R 树实现?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7435645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 19:57:35  来源:igfitidea点击:

Java commercial-friendly R-tree implementation?

javaindexingr-tree

提问by Markos Fragkakis

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

我需要一个商业友好的(Apache 许可证、LGPL、Mozilla 公共许可证等)Java 中的R-tree实现,以便将geonamesWeb 服务替换为时区,如问题“在不使用网络的情况下根据纬度/经度确定时区”中的建议Geonames.org 等服务”。我在周围找到了一些,但我想知道是否有人在实践中评估或使用过它们。

回答by WindRider

回答by ?ukasz R?anek

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.

首先让我指出,如果您从给定的坐标中查找最近的城市,它可能不在同一时区!在我看来,您真正需要的是有关它的行政隶属关系的信息 - 最低限度是一个国家,但在某些情况下,它甚至应该不止于此,即州。可以使用 Google Maps API 检索该信息,然后将其与一些更详细的 TZ 信息相关联。

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.

有一个免费的 GeoNames 替代方案 - EarthTools。服务本身有一些限制(请求数量等),但它仍然很好,经过测试并且对我来说工作得很好。

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.

其次 - 有一个免费的 GeoNames 替代品 - EarthTools。服务本身有一些限制(请求数量等),但它仍然很好,经过测试并且对我来说工作得很好。

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 H2Spatialaddition - although I've tried it and I can not recommend it fully. Neo4j have a great spatial index implementation

第三 - 如果您关心将数据导入 DB,当前的大多数 DB 实现都提供了您可以使用的地理空间索引。如果您需要在您的应用程序中嵌入该信息,您可以使用带有H2Spatial添加的H2Database(嵌入式 Java DB)- 尽管我已经尝试过,但我不能完全推荐它。Neo4j 有很好的空间索引实现

Additionally You can use Solrfor 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...

此外,您可以使用Solr进行地理空间搜索。这很好,速度很快,而且很容易实现。我实际上正在将我的数据库搜索迁移到 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!
  • JSI-LGPL
  • GeoTools- LGPL,一个矫枉过正的,会给你远远超过你需要的......但它很棒!

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

可能还有几个,但到目前为止我测试过的那些......

回答by mirza

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

我创建的 RTree 简单 Java 类: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.

所有对象都存储在两个 int[] 数组中,因此持久化(到文件)非常容易。此外,添加新矩形不会创建任何对象的事实意味着您可以将数百万个矩形插入 RTree 并且 JVM 不会在火焰中燃烧。这对于地理项目很有用,其中对象数量通常很大。

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".

仅存储 2D 矩形(因此,对于复杂对象,您需要找到边界矩形)。查询返回与“查询矩形”相交或重叠的所有矩形(矩形的 ID)。