中心点"/>
JTS: 20 InteriorPoint 内部中心点
文章目录
- 版本
- 代码
版本
org.locationtech.jts:jts-core:1.19.0
链接: github
代码
package pers.stu.algorithm;import org.locationtech.jts.algorithm.InteriorPoint;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Polygon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pers.stu.util.GeoGebraUtil;/*** 内部中心点* @author LiHan* 2023-11-13 10:11:16*/
public class InteriorPointUse {private static final Logger LOGGER = LoggerFactory.getLogger(AngleUse.class);public static void main(String[] args) {InteriorPointUse interiorPointUse = new InteriorPointUse();interiorPointUse.test00();}public void test00() {GeometryFactory geometryFactory = new GeometryFactory();Coordinate[] coordinates = new Coordinate[] {new Coordinate(3, 10), new Coordinate(12, 10),new Coordinate(12, 3), new Coordinate(3, 3),new Coordinate(3, 10)};Polygon polygon = geometryFactory.createPolygon(coordinates);LOGGER.info(GeoGebraUtilpare(polygon));Coordinate coordinate = InteriorPoint.getInteriorPoint(polygon);LOGGER.info("中心点:{}", coordinate);}
}
18:17:57.118 [main] INFO pers.stu.util.GeoGebraUtil - geometry类型:Polygon
18:17:57.120 [main] INFO pers.stu.algorithm.AngleUse - Polygon(Point({3.0,10.0}),Point({12.0,10.0}),Point({12.0,3.0}),Point({3.0,3.0}),Point({3.0,10.0}))
18:17:57.123 [main] INFO pers.stu.algorithm.AngleUse - 中心点:(7.5, 6.5, NaN)
更多推荐
JTS: 20 InteriorPoint 内部中心点
发布评论