使用 Geotools 创建楔形

Creating a wedge shape with Geotools

我正忙于创建一个服务,该服务将根据提供的中心点数据创建一个形状。我正在使用我不太熟悉的 geotools,但是我对它越来越熟悉了。

我收到的数据如下所示:

{
    "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 中创建这个形状,但我对它太不熟悉了,所以我没能做到。我已经看到了创建多边形的能力,但是看起来我必须有几组经纬度才能创建这种类型的形状。

我前段时间写了一篇program来解决类似的问题

基本上,诀窍是使用 GeodeticCalculator 计算出楔形曲线部分的坐标,并将起点和终点连接到起点。

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[] {}));