如何转换EPSG:4326至EPSG:32632 Osmdroid

时间:2017-05-15 13:55:32

标签: gps osmdroid epsg

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

1 个答案:

答案 0 :(得分:0)

使用geotools。 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类的解码方法:

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]]
  1. 使用wkt字符串。
  2. 来自
    的targetWKT的字符串变量 http://spatialreference.org/ref/epsg/wgs-84-utm-zone-32n/prettywkt/

    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();
        }
    

    然后,代码是:

    {{1}}