简体   繁体   English

如何枚举JTS中的Geometry中的顶点?

[英]How to enumerate vertices in Geometry in JTS?

Java Topology Suite has Geometry class, which has getNumPoints() method. Java拓扑套件具有Geometry类,该类具有getNumPoints()方法。 According to documentation, it counts all vertices in all constituent geometries. 根据文档,它计算所有组成几何中的所有顶点。

How to enumerate all these points? 如何列举所有这些要点? They can be obtained by getCoordinates() method, but this looks not optimal, since (1) is not iterative and (2) requires to convert each coordinate tuple into Point by GeomertFactory . 可以通过getCoordinates()方法获得它们,但这看起来不是最佳的,因为(1)不是迭代的,并且(2)需要通过GeomertFactory将每个坐标元组转换为Point

As you probably have some proper geometry type like LineString or Polygon, use that (cast your Geometry to it), then you can use getPointN(index) . 由于您可能有一些合适的几何类型,如LineString或Polygon,请使用该类型(将您的Geometry投射到其中),然后可以使用getPointN(index)

Coordinates are not Points by the way. 坐标不是点。 Coordinate is not a geometry in JTS, just a class to hold numeric values. 坐标不是JTS中的几何图形,而只是一个用于保存数值的类。 Points are actual geometries. 点是实际的几何形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM