Java 几何库

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

Geometry library for Java

javageometry

提问by nanda

Is there any geometry library available for Java? I'm looking for solution to get an intersection point(s) between two geometry objects.

是否有任何可用于 Java 的几何库?我正在寻找解决方案来获得两个几何对象之间的交点。

采纳答案by rburhum

JTSis your best free open source option. The method you are looking for in JTS is here

JTS是您最好的免费开源选择。您在 JTS 中寻找的方法在这里

As far as commercial options, you have ESRI's Java JNI versionof their ArcObjects library which has a very robust Geometry Library. The interface on ESRI's library is called ITopologicalOperator

至于商业选项,你有ESRI 的 Java JNI 版本的 ArcObjects 库,它有一个非常强大的几何库。ESRI 库上的接口称为ITopologicalOperator

If all you are trying to do is Geometric operations, JTS is your best option - it is an excellent library which has many ports to different languages. If, on the other hand, you are looking for an entire GIS system that does complex symbology, supports GIS workflows and multiuser editing, printing, etc etc, then I would start looking at the ESRI libraries.

如果您要做的只是几何运算,JTS 是您的最佳选择 - 它是一个出色的库,具有许多不同语言的端口。另一方面,如果您正在寻找具有复杂符号系统、支持 GIS 工作流和多用户编辑、打印等的整个 GIS 系统,那么我将开始查看 ESRI 库。

回答by Adamski

The package you should look at it java.awt.geom, which is part of the JDK.

你应该看看它的包java.awt.geom,它是JDK的一部分。

In particular check out the java.awt.geom.Areaclass, which allows you to perform intersection operations between two Shapes.

特别是查看java.awt.geom.Area类,它允许您在两个Shapes之间执行交集操作。

EDIT

编辑

Finding the intersection points is non-trivial as far as I know, as you need to apply a different algorithm depending on the shapes you're analysing. For example, the algorithm for the intersection between two circles is given here, whereas the algorithm for calculating the intrsection between two Bezier curves is completely different (here).

据我所知,找到交点并非易事,因为您需要根据要分析的形状应用不同的算法。比如这里给出两个圆相交的算法,而计算两条贝塞尔曲线交点的算法就完全不同了(这里)。

EDIT 2

编辑 2

One suggestion: You could look into the PathIteratorclass, which returns a description of a shape's path as a sequence of segments. In particular check out FlatteningPathIterator, which will collapse any curves into multiple straight lines. Once your path has been reduced to straight lines, calculating the intersection points will be simple ... although obviously this is an approximation in cases where your shape contains curves.

一个建议:您可以查看PathIterator该类,该类将形状路径的描述作为段序列返回。特别是 check out FlatteningPathIterator,它会将任何曲线折叠成多条直线。一旦您的路径减少为直线,计算交点将很简单……尽管在您的形状包含曲线的情况下,这显然是一个近似值。

回答by codekaizen

JTS - Java Topology Suite - is the best.

JTS - Java 拓扑套件 - 是最好的。

http://www.vividsolutions.com/jts/jtshome.htm

http://www.vividsolutions.com/jts/jtshome.htm

It is free, fast, robust, and can handle degenerate intersections.

它是免费的、快速的、健壮的,并且可以处理退化的交叉点。

回答by Kendric Beachey

I found that JTS has changed hands, or changed home sites, or something. A newer version can be found here: http://maven.geotoolkit.org/com/vividsolutions/jts/1.10/

我发现 JTS 已经易手,或者更改了主页,或者其他什么。可以在此处找到更新的版本:http: //maven.geotoolkit.org/com/vividsolutions/jts/1.10/

Edit: This might be its new home page: http://tsusiatsoftware.net/jts/main.html

编辑:这可能是它的新主页:http: //tsusiatsoftware.net/jts/main.html

回答by WindRider

For non-GIS purposes I may suggest javaGeomlibrary. It uses the Euclidean abstraction of geometry which most of the people know from school. There's no recent activity on this project, but I find it well structured and easy to use. They say it supports boolean operations, but never tested how well they work. There is a pretty feature-rich testing application named Euclid, which is developed from the same author. You can try to use it, but only if you are sure it's gonna work for you.

对于非 GIS 目的,我可能会建议使用javaGeom库。它使用了大多数人从学校就知道的几何学的欧几里得抽象。这个项目最近没有活动,但我发现它结构良好且易于使用。他们说它支持布尔运算,但从未测试过它们的工作情况。有一个名为 Euclid 的功能非常丰富的测试应用程序,它是由同一作者开发的。您可以尝试使用它,但前提是您确定它对您有用。

http://sourceforge.net/projects/geom-java/

http://sourceforge.net/projects/geom-java/