This Geodesy
provides a comprehensive set of methods for performing various geodetic calculations and operations. You can use these methods to calculate distances, bearings, intersections, and more based on geographical coordinates.
Call any Static Methods which is given below without using Geodesy
Instance.
Calculate a destination point given an initial point, a distance, a bearing, and an optional radius.
DistanceAndBearing.destinationPointByDistanceAndBearing(l, distance, bearing, radius);
Returns a LatLng
object representing the calculated destination point.
Calculate the geographical midpoint between two points.
GeoPoints.midPointBetweenTwoGeoPoints(l1, l2);
l1
(LatLng): The first geographical point (latitude, longitude).l2
(LatLng): The second geographical point (latitude, longitude).
Returns a LatLng
object representing the midpoint between the two input points.
Calculate the intersection point of two paths defined by points and bearings.
GeoPoints.intersectionOfTwoGeoPointsByPaths(l1, l2, b1, b2);
l1
(LatLng): The first geographical point (latitude, longitude).l2
(LatLng): The second geographical point (latitude, longitude).b1
(num): The bearing angle for the first path in degrees.b2
(num): The bearing angle for the second path in degrees.
Returns a LatLng
object representing the intersection point or null
if no intersection is found.
Calculate the distance in meters between two geographical points.
GeoPoints.distanceBetweenTwoGeoPoints(l1, l2, radius);
l1
(LatLng): The first geographical point (latitude, longitude).l2
(LatLng): The second geographical point (latitude, longitude).radius
(num, optional): The Earth's radius (default isnull
).
Returns the distance in meters between the two input points.
Calculate the bearing angle from one point to another.
BearingBetweenTwoGeoPoints.bearingBetweenTwoGeoPoints(l1, l2);
l1
(LatLng): The starting geographical point (latitude, longitude).l2
(LatLng): The target geographical point (latitude, longitude).
Returns the bearing angle in degrees from the starting point to the target point.
Calculate the final bearing angle from one point to another.
BearingBetweenTwoGeoPoints.finalBearingBetweenTwoGeoPoints(l1, l2);
l1
(LatLng): The starting geographical point (latitude, longitude).l2
(LatLng): The target geographical point (latitude, longitude).
Returns the final bearing angle in degrees from the starting point to the target point.
Calculate the signed distance from a point to a line defined by two other points.
TrackDistance.crossTrackDistanceTo(l1, start, end, radius);
l1
(LatLng): The point to calculate the distance from (latitude, longitude).start
(LatLng): The starting point of the line (latitude, longitude).end
(LatLng): The ending point of the line (latitude, longitude).radius
(num, optional): The Earth's radius (default isnull
).
Returns the signed cross-track distance in meters.
Check if a given point is within a bounding box defined by two corner points.
BoundingBox.isGeoPointInBoundingBox(l, topLeft, bottomRight);
l
(LatLng): The point to check (latitude, longitude).topLeft
(LatLng): The top-left corner of the bounding box (latitude, longitude).bottomRight
(LatLng): The bottom-right corner of the bounding box (latitude, longitude).
Returns true
if the point is within the bounding box, otherwise false
.
Check if a given point is within a polygon using the even-odd rule algorithm.
GeoPoints.isGeoPointInPolygon(l, polygon);
l
(LatLng): The point to check (latitude, longitude).polygon
(List<LatLng>
): A list of vertices defining the polygon.
Returns true
if the point is within the polygon, otherwise false
.
Get a list of points within a certain distance from a given point.
PointRange.pointInRange(point, pointsToCheck, distance);
point
(LatLng): The center point (latitude, longitude).pointsToCheck
(List<LatLng>
): List of points to check against.distance
(num): The maximum distance in meters.
Returns a list of LatLng
points within the specified distance from the center point.
Calculate the great-circle distance between two points using the Haversine formula.
GeoPoints.greatCircleDistanceBetweenTwoGeoPoints(lat1, lon1, lat2, lon2);
lat1
(num): Latitude of the first point.lon1
(num): Longitude of the first point.lat2
(num): Latitude of the second point.lon2
(num): Longitude of the second point.
Returns the great-circle distance in meters.
Get the bounding rectangle for a polygon defined by its vertices.
RectangleBounds.getRectangleBounds(polygonCoords);
polygonCoords
(List<LatLng>
): List of vertices defining the polygon.
Returns a list of LatLng
points representing the bounding rectangle's corners.
Calculate the bounding box around a point with a given distance.
BoundingBox.calculateBoundingBox(centerPoint, distanceInKm);
centerPoint
(LatLng): The center point (latitude, longitude).distanceInKm
(num): The distance in kilometers.
Returns a list of LatLng
points representing the bounding box's corners.
Find the centroid of a polygon defined by its vertices.
PolygonCentroid.findPolygonCentroid(polygons);
polygon
(List<LatLng>
): List of vertices defining the polygon.
Returns a LatLng
object representing the centroid of the polygon.
Calculate the intersection of
two polygons defined by their vertices.
PolygonIntersection.getPolygonIntersection(polygon1, polygon2);
polygon1
(List<LatLng>
): List of vertices defining the first polygon.polygon2
(List<LatLng>
): List of vertices defining the second polygon.
Returns a list of LatLng
points representing the intersection polygon.
VincentyDistance.vincentyDistance(lat1, lon1, lat2, lon2);
final area = Polygon.calculatePolygonWithHolesArea(outerPolygon, holes);
double equirectangularDistance =
EquirectangularApproximation.equirectangularDistance(firstPoint,secondPoint);
double sLCDdistance =
SphericalLawOfCosines.sphericalLawOfCosinesDistance(bGPoint, pFPoint);
LatLng destinationPoints = DestinationPoint.calculateDestinationPoint(
initialPoint, bearingDegrees, distanceKm);
LatLng midPointBetweenTwoPoints =
MidPointBetweenTwoPoints.calculateMidpoint(bgPoint1, pFPoint2);
List<LatLng> arcPoints = GreatCirclePoint.calculatePointsAlongGreatCircle(
startPoint, endPoint, numPoints);
double length = PolyLine.calculatePolyLineLength(polyLinePoints);
double polygonArea = PolygonArea.calculatePolygonArea(polygonPoints);
LatLng? intersection = GeodesicLines.calculateGeodesicLineIntersection(
start1, end1, start2, end2);