0
我必須將GPS座標(經度和緯度)轉換爲蘭伯特等角錐投影。該地圖是指意大利。 由於我不是這個主題的專家,我發現(谷歌搜索),最好的Java庫之一是GeoToolkit。不幸的是,我沒有找到任何示例和文檔(只有Javadoc)。 這裏的投影參數(凸出= LCC Lat_2 = 45 Lat_1 = 40 Lat_0 = 42.5 Lon_0 = 9.2 X_0 = 600000 y_0 = 2200000):GeoToolkit:從GPS轉換到Lambert Conformal Conic
PARAM_MT["Lambert_Conformal_Conic_2SP",
PARAMETER["semi_major", 6378137.0],
PARAMETER["semi_minor", 6356752.314],
PARAMETER["central_meridian", 9.2],
PARAMETER["latitude_of_origin", 42.5],
PARAMETER["false_easting", 600000.0],
PARAMETER["false_northing", 2200000.0],
PARAMETER["standard_parallel_2", 45.0],
PARAMETER["standard_parallel_1", 40.0]]
有誰知道比GeoToolkit更好的圖書館嗎?
我寫了下面的代碼轉換座標:
// 1. Get the MathTransform Factory
MathTransformFactory factory;
FactoryRegistry registry = new FactoryRegistry(
MathTransformFactory.class);
factory = registry.getServiceProvider(MathTransformFactory.class, null,
null, Hints.MATH_TRANSFORM_FACTORY);
// 2. Define source and target coord reference systems
GeographicCRS sourceCRS = DefaultGeographicCRS.WGS84;
ParameterValueGroup parameters = factory
.getDefaultParameters("Lambert_Conformal_Conic_2SP");
parameters.parameter("semi_major").setValue(WGS84_AXIS_MAJOR);
parameters.parameter("semi_minor").setValue(WGS84_AXIS_MINOR);
parameters.parameter("central_meridian").setValue(9.2);
parameters.parameter("latitude_of_origin").setValue(42.5);
parameters.parameter("standard_parallel_1").setValue(40.0);
parameters.parameter("standard_parallel_2").setValue(45.0);
parameters.parameter("false_easting").setValue(600000);
parameters.parameter("false_northing").setValue(2200000);
// 3. Create the MathTransform with the given parameters
Conversion conversion = new DefiningConversion("GPS to Lambert",
parameters);
CRSFactory crsFactory = FactoryFinder.getCRSFactory(null);
Map<String, ?> properties = Collections.singletonMap(
ProjectedCRS.NAME_KEY, "LatLon2Lambert");
ProjectedCRS targetCRS = crsFactory.createProjectedCRS(properties,
sourceCRS, conversion, DefaultCartesianCS.GENERIC_2D);
MathTransform tr = CRS.findMathTransform(sourceCRS, targetCRS);
DirectPosition sourcePt = new DefaultDirectPosition(DefaultGeographicCRS.WGS84);
sourcePt.setOrdinate(0, 45.0);
sourcePt.setOrdinate(1, 8.0);
DirectPosition targetPt = tr.transform(p.getValue(), null);
但是,這是行不通的。 我錯在哪裏? 在此先感謝。