Coords constructor

Coords(
  1. dynamic coords
)

Implementation

Coords(dynamic coords) {
  // Coords should parse "real" locations normally, but must tolerate synthetic/dummy
  // payloads (eg when SDK is disabled or permissions/services are unavailable).
  final Map c = _asMap(coords);

  // Required fields (real locations always provide these).  For dummy payloads, default to 0.
  latitude = _mapDouble(c, 'latitude', fallback: 0.0);
  longitude = _mapDouble(c, 'longitude', fallback: 0.0);
  accuracy = _mapDouble(c, 'accuracy', fallback: 0.0);
  altitude = _mapDouble(c, 'altitude', fallback: 0.0);

  // Optional / platform-dependent fields.
  // iOS dummy payload can omit ellipsoidal_altitude; fall back to altitude.
  ellipsoidalAltitude =
      _mapDouble(c, 'ellipsoidal_altitude', fallback: altitude);

  // GPS-only fields can be missing.  Use -1 when absent.
  heading = _mapDouble(c, 'heading', fallback: -1.0);
  headingAccuracy = _mapDouble(c, 'heading_accuracy', fallback: -1.0);
  speed = _mapDouble(c, 'speed', fallback: -1.0);
  speedAccuracy = _mapDouble(c, 'speed_accuracy', fallback: -1.0);

  // May be absent on some devices.
  altitudeAccuracy = _mapDouble(c, 'altitude_accuracy', fallback: -1.0);

  // iOS-only.
  floor = _mapInt(c, 'floor');
}