1

我通过我的 Android GPS 在 EPSG:4326 中获得了我的位置,现在我将其坐标转换为 EPSG:32632。有人有想法吗?

4

1 回答 1

0

使用地理工具。 http://www.geotools.org/

这是一个转换示例。

http://docs.geotools.org/stable/userguide/library/api/jts.html

首先,您必须从下载目录中删除 3 个 jar 文件,如下所示:

例如 geotools 18.0 版,

gt-epsg-hsql-18.0.jar gt-epsg-oracle-18.0.jar gt-epsg-postgresql-18.0.jar

几乎存在两种情况。1.使用CRS类的decode方法:

CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);

CoordinateReferenceSystem targetCRS = null;
CoordinateReferenceSystem sourceCRS = null;
Geometry transCoordGeometry = null;

try {
    targetCRS = CRS.decode("EPSG:32632");
    sourceCRS = CRS.decode("EPSG:4326");
} catch (FactoryException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}


MathTransform transform = null;
try {
    transform = CRS.findMathTransform(sourceCRS, targetCRS);
    transCoordGeometry = JTS.transform(orgGeometry, transform);
} catch (FactoryException | MismatchedDimensionException | TransformException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
  1. 使用 wkt 字符串。

来自http://spatialreference.org/ref/epsg/wgs-84-utm-zone-32n/prettywkt/的 targetWKT 的字符串变量

PROJCS["WGS 84 / UTM zone 32N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.01745329251994328,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    AUTHORITY["EPSG","32632"],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH]]

然后,代码是:

CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    CoordinateReferenceSystem targetCRS = null;

    CoordinateReferenceSystem sourceCRS = null;
    Geometry transCoordGeometry = null;

    try {
        targetCRS = crsFactory.createFromWKT(targetWKT); 
        sourceCRS = CRS.decode("EPSG:4326");
    } catch (FactoryException e1) {
        e1.printStackTrace();
    }


    MathTransform transform = null;
    try {
        transform = CRS.findMathTransform(sourceCRS, targetCRS);
        transCoordGeometry = JTS.transform(orgGeometry, transform);
    } catch (FactoryException | MismatchedDimensionException | TransformException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
于 2017-12-12T04:17:15.000 回答