需要一个独立的 Java 库来对经纬度数据执行空间计算

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3877792/
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 03:48:27  来源:igfitidea点击:

Need a standalone Java library for performing spatial calculations on lat/lon data

javageospatialpolygonspatialgreat-circle

提问by Jim Tough

I'm looking for a Java library that is capable of performing spatial calculations on sets of lat/lon data. Here are some of the functions that I'm looking for:

我正在寻找一个能够对经纬度数据集执行空间计算的 Java 库。以下是我正在寻找的一些功能:

  • Calculate the Great Circle distance between two points
  • Determine if a point lies within a simple closed polygon, where the polygon is defined by an ordered list of points
  • Determine if the line between point "A" and point "B" intersects a simple closed polygon, where the polygon is defined by an ordered list of points
  • Determine if point "A" is within a certain radius of point "B"
  • 计算两点之间的大圆距离
  • 确定一个点是否位于一个简单的闭合多边形内,其中多边形由点的有序列表定义
  • 确定点“A”和点“B”之间的线是否与简单的闭合多边形相交,其中多边形由点的有序列表定义
  • 确定点“A”是否在点“B”的一定半径内

What I'm NOTlooking for:

不是在寻找什么:

  • I don'twant a library that is dependent upon a database geospatial component, such as Oracle Spatial, and cannot function independently.
  • I don'twant a library whose purpose is to generate graphics/maps/etc. I am building an analysis module for an existing application and the end goal is not to create pretty pictures.
  • I don'twant a library for searching large amounts of spatial data. If it also happens to do this, that's ok, but I'm not going to use that feature.
  • 想要依赖于数据库地理空间组件(例如 Oracle Spatial)并且不能独立运行的库。
  • 想要一个旨在生成图形/地图/等的库。我正在为现有应用程序构建一个分析模块,最终目标不是创建漂亮的图片。
  • 想要一个用于搜索大量空间数据的库。如果它也碰巧这样做,那没关系,但我不会使用该功能。

The organization is planning to acquire a license for Oracle Spatial eventually (so spatial searching will be covered at that point), but for now I need to implement the analysis functions that I have mentioned above on small data sets without relying on database-supplied spatial support.

该组织计划最终获得 Oracle Spatial 的许可(因此此时将涵盖空间搜索),但现在我需要在不依赖数据库提供的空间的情况下在小数据集上实现我上面提到的分析功能支持。

采纳答案by Reed Copsey

I believe GeoToolswould satisfy your requirements. Note that it does have facilities for doing graphics/maps, but they can be left unused easily enough.

我相信GeoTools会满足您的要求。请注意,它确实具有用于制作图形/地图的设施,但它们可以很容易地闲置不用。

回答by AdrieanKhisbe

There is a new library Spatial4Jthat seems to fullfill your needs, it supports various spaces and shapes

有一个新的库Spatial4J似乎可以满足您的需求,它支持各种空间和形状

Spatial4j is a general purpose spatial / geospatial ASL licensed open-source Java library (...)

Spatial4j 是一个通用空间/地理空间 ASL 许可的开源 Java 库 (...)

I haven't used it so far but the READMEis complete, and repositery is rather popular, and it's available on maven repositeryI was looking for such spatial library when I end up both on the repo and on this question.

到目前为止我还没有使用过它,但是它README是完整的,并且存储库相当受欢迎,并且它可以在 maven 存储库上找到,当我最终在存储库和这个问题上都在寻找这样的空间库时。

回答by Ilya Yevlampiev

Simplelatlng gives more simple API for this:

Simplelatlng 为此提供了更简单的 API:

https://code.google.com/p/simplelatlng/wiki/GettingStarted

https://code.google.com/p/simplelatlng/wiki/GettingStarted

回答by Jay R.

In spite of your desire to avoid a library that is used to draw maps, I'd recommend OpenMap. The com.bbn.openmap.geopackage of that library does most if not all of the things you are asking for.

尽管您希望避免使用用于绘制地图的库,但我还是建议使用OpenMap。该库的com.bbn.openmap.geo可以满足您的大部分需求。

回答by Rogelio

I've used STRtree java class to index by lat lng data and distance queries https://locationtech.github.io/jts/javadoc/org/locationtech/jts/index/strtree/STRtree.html

我已经使用 STRtree java 类通过 lat lng 数据和距离查询进行索引 https://locationtech.github.io/jts/javadoc/org/locationtech/jts/index/strtree/STRtree.html