class WzCoordinateConvertItem {
  /// Output longitude (key: `lon` in the document)
  final double lon;

  /// Output latitude (key: `lat` in the document)
  final double lat;

  WzCoordinateConvertItem({required this.lon, required this.lat});

  factory WzCoordinateConvertItem.fromJson(Map<String, dynamic> json) {
    final lonV = json['lon'] ?? json['longitude'];
    final latV = json['lat'] ?? json['latitude'];

    final lon = lonV is num ? lonV.toDouble() : double.tryParse(lonV.toString()) ?? 0;
    final lat = latV is num ? latV.toDouble() : double.tryParse(latV.toString()) ?? 0;

    return WzCoordinateConvertItem(lon: lon, lat: lat);
  }

  Map<String, dynamic> toJson() => {
        'lon': lon,
        'lat': lat,
      };
}

/// Endpoint returns a JSON array:
/// `[ { "lon": ..., "lat": ... }, ... ]`
typedef WzCoordinateConvertResponse = List<WzCoordinateConvertItem>;

