Java 使用Geotools创建楔形体
我很乐意创建一个服务,它将根据中心点提供的数据创建一个形状。我正在使用geotools,虽然我不是很有经验,但是我对它越来越熟悉了 我收到的数据如下所示:Java 使用Geotools创建楔形体,java,gis,geotools,Java,Gis,Geotools,我很乐意创建一个服务,它将根据中心点提供的数据创建一个形状。我正在使用geotools,虽然我不是很有经验,但是我对它越来越熟悉了 我收到的数据如下所示: { "shape": { "latitude": 43.87, "longitude": -103.45, "parameters": [ 0.0, 120.0, 1000.0 ], "shapeString": "WEDGE (-103.45,4
{
"shape": {
"latitude": 43.87,
"longitude": -103.45,
"parameters": [
0.0,
120.0,
1000.0
],
"shapeString": "WEDGE (-103.45,43.87) AZIMUTH:0.0 ANGLE:120.0 RADIUS:1000.0"
}
}
我假设有一种方法可以在geotools中创建这个形状,但我对它太不熟悉了,所以一直没能做到。我已经看到了创建多边形的能力,但是看起来我必须有几组lat,lon来创建那种类型的形状。我不久前写了一篇文章来解决类似的问题
基本上,诀窍是使用大地测量计算器
计算楔体弯曲部分的坐标,并将起点和终点连接到起点
ArrayList<Coordinate> coords = new ArrayList<>();
// start at the tower
coords.add(point.getCoordinate());
// next the edge of the wedge
int nSteps = 10;
// assume width of 10 degrees
double width = 10.0;
double dStep = width/nSteps;
for (int i = -nSteps; i < nSteps; i++) {
CALC.setStartingGeographicPoint(point.getX(), point.getY());
CALC.setDirection((azimuth +(i*dStep)), radius);
Point2D p = CALC.getDestinationGeographicPoint();
coords.add(new Coordinate(p.getX(), p.getY()));
}
// end at the tower
coords.add(point.getCoordinate());
poly = GF.createPolygon(coords.toArray(new Coordinate[] {}));
ArrayList coords=new ArrayList();
//从塔楼开始
添加(point.getCoordinate());
//接下来是楔形物的边缘
int nSteps=10;
//假设宽度为10度
双倍宽度=10.0;
双dStep=宽度/NSTEP;
对于(int i=-nSteps;i