需要使用 JTS 库围绕坐标创建圆

need to create circle around coordinate using JTS library

我正在尝试使用从某些 git 集线器回购中获得的以下方法围绕特定坐标创建圆圈。

public static Geometry createCircle(Coordinate coordinate, double radius)
{
  GeometricShapeFactory shape = new GeometricShapeFactory(geomFactory);
  shape.setCentre(coordinate);
  shape.setSize(2 * radius);
  shape.setNumPoints(32);
  return shape.createCircle();
}

我想以英里为单位传递半径,但看起来它采用了其他单位,并且当我将 5 作为半径时,创建的圆很大。有人可以解释一下如何在上面的示例中使用以英里为单位的半径参数吗?

JTS 是 geometry/topology 库。因此,它使用几何体所在的任何单位。

假设您使用的点是经度、纬度对,那么单位是度 longitude/latitude。在赤道,度数约为 110 公里/69 英里。

作为一个非常快速的解决方法,您可以将半径设置为 5/69 之类的值。作为一个完整的解决方案,您可以将 GeoTools(一个 Java 地理空间库)GeodeticCalculator class [1] 应用到您建议的代码以获得更准确的圆。

该解决方案在两极附近会出现一些问题,但那是另一个问题...

[1] http://docs.geotools.org/stable/userguide/library/referencing/calculator.html