GeoPoint2 constructor
A geographic point from lon
and lat
.
Longitude is normalized to the range [-180.0, 180.0[
using the formula
(lon + 180.0) % 360.0 - 180.0
(if outside the range) and latitude is
clamped to the range [-90.0, 90.0]
.
Implementation
const GeoPoint2({required double lon, required double lat})
: lon =
lon >= -180.0 && lon < 180.0 ? lon : (lon + 180.0) % 360.0 - 180.0,
lat = lat < -90.0 ? -90.0 : (lat > 90.0 ? 90.0 : lat);