点燃JTS WGS84

时间:2018-08-29 16:31:48

标签: 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'

谢谢

1 个答案:

答案 0 :(得分:0)

如果要查找以米为单位的距离,则可以使用GeoTools库GeodeticCalculator。简而言之,JTS处理几何,而GeoTools(和其他库)旨在帮助地理。

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

相关问题