我尝试使用库将 epsg:3116(gcm_magna) 转换为 epsg:4326(纬度和经度),但输出不准确。有人可以解释我或纠正我吗?
var destProjection = Projection.get('EPSG:4326')!; // WGS84 (EPSG:4326)
// Definir las coordenadas en EPSG:3116
var point = Point(x: 846358.4308, y: 1639765.33);
// Convertir las coordenadas de EPSG:3116 a EPSG:4326
var transformedPoint = srcProjection.transform(destProjection, point);
print('Latitud: ${transformedPoint.y}, Longitud: ${transformedPoint.x}');```
my inputs were: (x: 846358.4308, y: 1639765.33) and the expected outputs are Lat: 10.377944565887024, Long: -75.48036335262766. But I have Lat: 14.809695868343415, Long: -71.7825948906633
更新我做到了。我遇到的问题是,我使用的是 lib proj4dart 的过去版本,因此我将其更新到最新版本并更改代码形式:
flutter 依赖项:
dependencies:
proj4dart: ^2.1.0
代码已更改:
import 'package:proj4dart/proj4dart.dart';
void main() {
var pointSrc = Point(x: 846358.4308, y: 1639765.33);
var projSrc = Projection.add(
'EPSG:3116',
'+proj=tmerc +lat_0=4.59620041666667 +lon_0=-74.0775079166667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs',
);
var projDst = Projection.get('EPSG:4326')!;
var pointForward = projSrc.transform(projDst, pointSrc);
print(pointForward.toArray()); // Output: [-75.48036335262819, 10.37794456588702]
}
非常感谢https://github.com/maRci002,他帮助我解决了问题,并且是 lib proj4dart 的所有者。