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。简而言之,JTS 处理几何,GeoTools(和其他库)旨在帮助处理地理。
http://docs.geotools.org/stable/userguide/library/referencing/calculator.html http://docs.geotools.org/stable/javadocs/org/geotools/referencing/GeodeticCalculator.html
推荐阅读
- codeigniter - 从 codeigniter URL 中删除主题文件夹名称
- python - 我在使用 pyinstaller 时遇到问题
- mysql - varchar 日期转换为 max() date() mysql
- epoch - 如何在 CAPL 中将纪元时间转换为日期
- swift - 以编程方式创建堆栈视图
- dart - 在 Web 视图中加载 URL 时显示 CircularProgressIndicator
- git - 在 intellij 提交对话框中未提示 Git 自动生成的合并提交消息
- javascript - 如何将我从 Promise 获得的数据存储回具有相同键的对象中?
- javascript - 用 colspan 制作一行 Wordpress 选项页面的第一行
- ios - 两个 Objective-C 类别共享相同的委托方法