validateCoordinates static method
Validates geographic coordinates.
latitude is the latitude coordinate.
longitude is the longitude coordinate.
Returns true if the coordinates are valid.
Throws MessageException if the coordinates are invalid.
Implementation
static bool validateCoordinates(double latitude, double longitude) {
if (latitude < -90 || latitude > 90) {
throw MessageException.invalidContent(
'Latitude must be between -90 and 90 degrees.',
);
}
if (longitude < -180 || longitude > 180) {
throw MessageException.invalidContent(
'Longitude must be between -180 and 180 degrees.',
);
}
return true;
}