【问题标题】:Creating a wedge shape with Geotools使用 Geotools 创建楔形
【发布时间】:2018-06-01 17:58:30
【问题描述】:

我正在创建一项服务,该服务将根据提供的中心点数据创建一个形状。我正在使用我不太熟悉的地理工具,但是我越来越熟悉它。

我正在接收如下所示的数据:

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

【问题讨论】:

    标签: java gis geotools


    【解决方案1】:

    前段时间我写了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[] {}));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-24
      • 1970-01-01
      • 2014-12-11
      • 1970-01-01
      • 2018-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多