GeoMath class
Mathematical utilities for geospatial calculations.
This class provides static methods for common geographical computations including distance calculation, coordinate conversions, and bearing calculations.
All distances are in meters unless otherwise specified.
Example:
final distance = GeoMath.haversineDistance(
37.7749, -122.4194, // San Francisco
40.7128, -74.0060, // New York
);
print(distance); // ~4130000 meters
Constructors
- GeoMath()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
calculateBearing(
double lat1, double lon1, double lat2, double lon2) → double - Calculates the initial bearing (forward azimuth) from point 1 to point 2.
-
calculateDestination(
{required double lat, required double lon, required double bearing, required double distance}) → Map< String, double> - Calculates the destination point given a starting point, bearing, and distance.
-
calculateMidpoint(
double lat1, double lon1, double lat2, double lon2) → Map< String, double> - Calculates the midpoint between two points on the Earth's surface.
-
degreesToRadians(
double degrees) → double - Converts degrees to radians.
-
haversineDistance(
double lat1, double lon1, double lat2, double lon2) → double - Calculates the great-circle distance between two points using the Haversine formula.
-
normalizeDegrees(
double degrees) → double - Normalizes an angle to the range [0, 360) degrees.
-
normalizeLongitude(
double longitude) → double - Normalizes a longitude to the range [-180, 180).
-
planarDistance(
double lat1, double lon1, double lat2, double lon2) → double - Calculates the distance between two points using a simplified planar approximation (Pythagorean theorem).
-
radiansToDegrees(
double radians) → double - Converts radians to degrees.
Constants
- earthRadius → const double
- Earth's mean radius in meters.
- earthRadiusEquatorial → const double
- Earth's equatorial radius in meters.
- earthRadiusPolar → const double
- Earth's polar radius in meters.