0
私はEPSGの私の位置を取得します:私のAndroid GPSで4326、今私はEPSGに座標を変換する:32632。 誰かがアイデアを持っていますか?どのようにEPSGを変換する:EPSG:4326 EPSG:32632 Osmdroid
私はEPSGの私の位置を取得します:私のAndroid GPSで4326、今私はEPSGに座標を変換する:32632。 誰かがアイデアを持っていますか?どのようにEPSGを変換する:EPSG:4326 EPSG:32632 Osmdroid
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 - オラクル・18.0.jar GT-EPSG-postgresqlの-18.0.jar
、ほぼ2つの場合があります。既存の。 WKT文字列を使用して
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();
}
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]]
から
targetWKTの文字列変数は、次に、コードは:
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();
}