gpt4 book ai didi

java - 如何将本地EngineeringCRS中的坐标转换为WGS84?

转载 作者:行者123 更新时间:2023-12-02 04:18:17 27 4
gpt4 key购买 nike

我想使用 geotools:gt-referencing 将本地右手 3D 笛卡尔坐标系中给出的坐标转换为 3D 地理坐标。

我有(移动平台的)本地右手坐标系中传感器的位置和方向。我知道局部坐标系相对于WGS84的平移和旋转。从数学上讲,该操作相当简单,因为它可以通过赫尔默特变换来解决。我想使用 geotools 来完成这项任务。 geotools-userguide提到了一个类 DefaultEngineeringCRS ,它似乎很适合我的本地坐标系。不幸的是,我没有找到任何关于此类的使用以及如何定义其原点和方向的示例代码。

我想做这样的事情

CoordinateReferenceSystem worldFrame = DefaultGeographicCRS.WGS84_3D;
CoordinateReferenceSystem bodyFrame = DefaultEngineeringCRS.CARTESIAN_3D;
/* set transformation rules for how to transform coordinates given in bodyFrame to coordinates in worldFrame */
DirectPosition locationOfSensor = DirectPosition3D(bodyFrame, x, y, z);
MathTransform trafo = CRS.findMathTransform(worldFrame, bodyFrame, true);
trafo.transform(locationOfSensor, locationOfSensor);

最佳答案

我不确定我能否完整回答这个问题,但这可能会帮助您朝正确的方向发展:

您可以使用 MathTransformFactory来构建你的转变。还可以查询工厂的操作情况:

System.out.println("operations");
for (OperationMethod op : mtFactory.getAvailableMethods(Operation.class)) {
System.out.println(op.getName());
}

这给出了一个类似的列表:

operations
Geotools:Logarithmic
Geotools:Exponential
OGC:Affine
EPSG:Longitude rotation
EPSG:Geocentric translations (geog2D domain)
EPSG:Position Vector transformation (geog2D domain)
EPSG:Coordinate Frame Rotation (geog2D domain)
OGC:Ellipsoid_To_Geocentric
OGC:Geocentric_To_Ellipsoid
OGC:Molodenski
OGC:Abridged_Molodenski
OGC:NADCON
EPSG:NTv2
EPSG:Similarity transformation
Geotools:WarpPolynomial
Geotools:Earth gravitational model
OGC:Equidistant_Cylindrical
EPSG:Equidistant Cylindrical (Spherical)
ESRI:Plate_Carree
OGC:Mercator_1SP
OGC:Mercator_2SP
EPSG:Popular Visualisation Pseudo Mercator
OGC:Transverse_Mercator
EPSG:Transverse Mercator (South Orientated)
OGC:Oblique_Mercator
ESRI:Hotine_Oblique_Mercator_Two_Point_Center
OGC:Hotine_Oblique_Mercator
ESRI:Hotine_Oblique_Mercator_Two_Point_Natural_Origin
OGC:Albers_Conic_Equal_Area
OGC:Lambert_Conformal_Conic_1SP
OGC:Lambert_Conformal_Conic_2SP
ESRI:Lambert_Conformal_Conic
OGC:Lambert_Conformal_Conic_2SP_Belgium
OGC:Lambert_Azimuthal_Equal_Area
OGC:Orthographic
ESRI:Stereographic
OGC:Oblique_Stereographic
OGC:Polar_Stereographic
EPSG:Polar Stereographic (variant B)
ESRI:Stereographic_North_Pole
ESRI:Stereographic_South_Pole
OGC:New_Zealand_Map_Grid
OGC:Krovak
OGC:Cassini_Soldner
GeoTIFF:CT_Equidistant_Conic
OGC:Polyconic
Geotools:Robinson
ESRI:Winkel_Tripel
ESRI:Aitoff
Geotools:Eckert_IV
Geotools:Mollweide
Geotools:Wagner_IV
Geotools:Wagner_V
OGC:Gnomonic
OGC:World_Van_der_Grinten_I
Geotools:Sinusoidal
AUTO:General_Oblique
AUTO:MeteosatSG
OGC:GEOS
AUTO:Rotated_Pole
OGC:Azimuthal_Equidistant
Geotools:Cylindrical_Equal_Area
Geotools:Behrmann
Geotools:Lambert Cylindrical Equal Area (Spherical)
Geotools:Equal Earth

或者通过投影:

System.out.println("projections");
for (OperationMethod op : mtFactory.getAvailableMethods(Projection.class)) {
System.out.println(op.getName());
}

这给出了

projections
OGC:Equidistant_Cylindrical
EPSG:Equidistant Cylindrical (Spherical)
ESRI:Plate_Carree
OGC:Mercator_1SP
OGC:Mercator_2SP
EPSG:Popular Visualisation Pseudo Mercator
OGC:Transverse_Mercator
EPSG:Transverse Mercator (South Orientated)
OGC:Oblique_Mercator
ESRI:Hotine_Oblique_Mercator_Two_Point_Center
OGC:Hotine_Oblique_Mercator
ESRI:Hotine_Oblique_Mercator_Two_Point_Natural_Origin
OGC:Albers_Conic_Equal_Area
OGC:Lambert_Conformal_Conic_1SP
OGC:Lambert_Conformal_Conic_2SP
ESRI:Lambert_Conformal_Conic
OGC:Lambert_Conformal_Conic_2SP_Belgium
OGC:Lambert_Azimuthal_Equal_Area
OGC:Orthographic
ESRI:Stereographic
OGC:Oblique_Stereographic
OGC:Polar_Stereographic
EPSG:Polar Stereographic (variant B)
ESRI:Stereographic_North_Pole
ESRI:Stereographic_South_Pole
OGC:New_Zealand_Map_Grid
OGC:Krovak
OGC:Cassini_Soldner
GeoTIFF:CT_Equidistant_Conic
OGC:Polyconic
Geotools:Robinson
ESRI:Winkel_Tripel
ESRI:Aitoff
Geotools:Eckert_IV
Geotools:Mollweide
Geotools:Wagner_IV
Geotools:Wagner_V
OGC:Gnomonic
OGC:World_Van_der_Grinten_I
Geotools:Sinusoidal
AUTO:General_Oblique
AUTO:MeteosatSG
OGC:GEOS
AUTO:Rotated_Pole
OGC:Azimuthal_Equidistant
Geotools:Cylindrical_Equal_Area
Geotools:Behrmann
Geotools:Lambert Cylindrical Equal Area (Spherical)
Geotools:Equal Earth

然后,您可以使用以下方法确定操作或投影所需的参数:

mtFactory.getDefaultParameters("EPSG:Coordinate Frame Rotation (geog2D domain)")

给出:

Coordinate Frame Rotation (geog2D domain) : dx  = 0.0
dy = 0.0
dz = 0.0
ex = 0.0
ey = 0.0
ez = 0.0
ppm = 0.0

此时您应该能够定义新的投影:

try {

ParameterValueGroup parameters = mtFactory.getDefaultParameters("EPSG:Coordinate Frame Rotation (geog2D domain)");
parameters.parameter("dx").setValue(1.0);
parameters.parameter("dy").setValue(-1.0);
parameters.parameter("dz").setValue(0.0);
parameters.parameter("ex").setValue(1.0);
parameters.parameter("ey").setValue(-1.0);
parameters.parameter("ez").setValue(0.0);
Conversion conversion = new DefiningConversion("Frame Rot", parameters);

GeographicCRS worldFrame = org.geotools.referencing.crs.DefaultGeographicCRS.WGS84;
CartesianCS bodyFrame = org.geotools.referencing.cs.DefaultCartesianCS.GENERIC_2D;
Map<String, ?> properties = Collections.singletonMap("name", "My Proj");
projCRS = crsFactory.createProjectedCRS(properties, worldFrame, conversion, bodyFrame);
} catch (FactoryException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

但是我在这里发现尺寸不匹配,但是如果您对转换有更好的了解,您可能会做得更好。

关于java - 如何将本地EngineeringCRS中的坐标转换为WGS84?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56652038/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com