点燃 JTS WGS84

Ignite JTS WGS84

我一直在尝试在 Apache Ignite 中使用与 GPS 坐标相关的 JTS。 到目前为止,我不确定它们如何或是否可以相互作用。例如,如果我计算两个几何之间的距离,我将得到一个平面距离,但我如何将它转换回地球表面的距离?

这里是我使用的一些代码供参考,虽然我不确定转换是否正确,但这不是问题的根源:

Coordinate coord1 = convertToRect(resultCoord.y, resultCoord.x, 0.0);
Coordinate coord2 = convertToRect(latitude, longitude, 0.0);
double dist = new GeometryFactory().createPoint(coord1).distance(new GeometryFactory().createPoint(coord2));

...

private Coordinate convertToRect(Double lat, Double lon, Double alt) {
    MathTransform ecefTransform =  org.geotools.referencing.CRS.findMathTransform(DefaultGeographicCRS.WGS84_3D, DefaultGeocentricCRS.CARTESIAN);           

    GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
    Point p = geometryFactory.createPoint(new Coordinate(lat, lon, alt));

    Geometry tp = JTS.transform(p, ecefTransform);
    return tp.getCoordinate();
}

所以也许 JTS 不是用来在地球上执行地理定位的?否则你知道我在哪里可以找到这种用法的参考资料吗?

参考使用的库:

compile 'org.opengis:geoapi:3.0.1'
compile 'org.geotools:gt-api:2.7.5'
compile 'org.geotools:gt-shapefile:2.7.5'
compile group: 'org.apache.ignite', name: 'ignite-geospatial', version: '2.5.2'

谢谢

如果您正在寻找以米为单位的距离,您可以使用 GeoTools 库 GeodeticCalculator。作为 shorthand,JTS 处理几何图形,而 GeoTools(和其他库)旨在帮助处理地理问题。

http://docs.geotools.org/stable/userguide/library/referencing/calculator.html http://docs.geotools.org/stable/javadocs/org/geotools/referencing/GeodeticCalculator.html