Geometry library for Java [closed]

2020-05-14 07:25发布

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

标签: java geometry
5条回答
小情绪 Triste *
2楼-- · 2020-05-14 07:46

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

As far as commercial options, you have ESRI's Java JNI version of their ArcObjects library which has a very robust Geometry Library. The interface on ESRI's library is called 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.

查看更多
男人必须洒脱
3楼-- · 2020-05-14 07:51

JTS - Java Topology Suite - is the best.

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

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

查看更多
够拽才男人
4楼-- · 2020-05-14 07:59

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

In particular check out the java.awt.geom.Area class, which allows you to perform intersection operations between two 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

One suggestion: You could look into the PathIterator class, 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.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2020-05-14 08:05

For non-GIS purposes I may suggest javaGeom library. 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.

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

查看更多
趁早两清
6楼-- · 2020-05-14 08:08

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/

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

查看更多
登录 后发表回答