wgs84togcj02 static method

Coords wgs84togcj02(
  1. Coords coords
)

Implementation

static Coords wgs84togcj02(Coords coords) {
  if (isOutOfChina(coords)) return coords;
  double dlat =
      _transformLat(Coords(coords.latitude - 35.0, coords.longitude - 105.0));
  double dlng =
      _transformLng(Coords(coords.latitude - 35.0, coords.longitude - 105.0));
  final double radlat = coords.latitude / 180.0 * pi;
  double magic = sin(radlat);
  magic = 1 - _ee * magic * magic;
  final double sqrtmagic = sqrt(magic);
  dlat = (dlat * 180.0) / ((_a * (1 - _ee)) / (magic * sqrtmagic) * pi);
  dlng = (dlng * 180.0) / (_a / sqrtmagic * cos(radlat) * pi);
  final double mglat = coords.latitude + dlat;
  final double mglng = coords.longitude + dlng;
  return Coords(mglat, mglng);
}