Skip to content

Latest commit

 

History

History
274 lines (176 loc) · 7.86 KB

METHODS.md

File metadata and controls

274 lines (176 loc) · 7.86 KB

Static Methods

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.

Methods

Destination Point By Distance And Bearing

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.

Mid Point Between Two GeoPoints

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.

Intersection By Paths

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.

Distance Between Two GeoPoints

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 is null).

Returns the distance in meters between the two input points.

Bearing Between Two GeoPoints

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.

Final BearingBetween Two GeoPoints

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.

Cross Track Distance To

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 is null).

Returns the signed cross-track distance in meters.

Is GeoPoint In BoundingBox

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.

Is GeoPoint In Polygon

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.

Points In Range

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.

Great Circle Distance Between Two GeoPoints

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 Rectangle Bounds

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 BoundingBox

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 Polygon Centroid

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.

Get Polygon Intersection

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.

Vincenty formula for Geodesic Distance Calculation

VincentyDistance.vincentyDistance(lat1, lon1, lat2, lon2);

Calculate Area of Polygon with Hole

final area = Polygon.calculatePolygonWithHolesArea(outerPolygon, holes);

Equirectangular approximation Calculation

double equirectangularDistance = 
  EquirectangularApproximation.equirectangularDistance(firstPoint,secondPoint);

Spherical Law Of Cosines Distance

double sLCDdistance =
  SphericalLawOfCosines.sphericalLawOfCosinesDistance(bGPoint, pFPoint);

Geodetic Point Manipulation - Rhumb Line Destination Formula

LatLng destinationPoints = DestinationPoint.calculateDestinationPoint(
  initialPoint, bearingDegrees, distanceKm);

Geodetic Point Manipulation - Midpoint between two points

LatLng midPointBetweenTwoPoints =
  MidPointBetweenTwoPoints.calculateMidpoint(bgPoint1, pFPoint2);

Geodetic Point Manipulation - Calculate Point Along Great Circle

List<LatLng> arcPoints = GreatCirclePoint.calculatePointsAlongGreatCircle(
  startPoint, endPoint, numPoints);

PolyLine Length by multiple Points

double length = PolyLine.calculatePolyLineLength(polyLinePoints);

Polygon Area Calculation using Shoelace formula

 double polygonArea = PolygonArea.calculatePolygonArea(polygonPoints);

Intersection points of two geodesic lines

  LatLng? intersection = GeodesicLines.calculateGeodesicLineIntersection(
      start1, end1, start2, end2);