validateCoordinates static method

bool validateCoordinates(
  1. double latitude,
  2. double longitude
)

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;
}