geodeticToEcf function

Map<String, dynamic> geodeticToEcf(
  1. Map<String, dynamic> geodetic
)

Implementation

Map<String, dynamic> geodeticToEcf(Map<String, dynamic> geodetic) {
  final longitude = geodetic['longitude'];
  final latitude = geodetic['latitude'];
  final height = geodetic['height'];

  final a = 6378.137;
  final b = 6356.7523142;
  final f = (a - b) / a;
  final e2 = ((2 * f) - (f * f));
  final normal = a / Math.sqrt(1 - (e2 * (Math.sin(latitude) * Math.sin(latitude))));

  final x = (normal + height) * Math.cos(latitude) * Math.cos(longitude);
  final y = (normal + height) * Math.cos(latitude) * Math.sin(longitude);
  final z = ((normal * (1 - e2)) + height) * Math.sin(latitude);

  return {
    'x': x,
    'y': y,
    'z': z,
  };
}