A Dart library for implementing geodesic and trigonometric calculations based on a spherical Earth model for working with points and paths such as distances, bearings and destinations
geodesy:
import 'package:geodesy/geodesy.dart';
Geodesy geodesy = Geodesy();
LatLng l = LatLng(22.308, 114.1716);
Calculate a destination point given the distance and bearing. If raduis is not specified, Earth radius will be used.
LatLng distinationPoint = geodesy.destinationPointByDistanceAndBearing(l3, 2400, 420.2);
Calcuate the midpoint bewteen teo geo points.
LatLng midpoint = geodesy.midPointBetweenTwoGeoPoints(l1, l2);
Calculate the distance in meters between two geo points. If raduis is not specified, Earth radius will be used.
num distance = geodesy.distanceBetweenTwoGeoPoints(l1, l2);
Calculate the bearing from point l1 to point l2.
num finalBearing = geodesy.finalBearingBetweenTwoGeoPoints(l1, l2);
Calculate the final bearing from point l1 to point l2.
num finalBearing = geodesy.finalBearingBetweenTwoGeoPoints(l1, l2);
Convert degrees to radians
num l1LatRadians = degreesToRadians(l1.lat);
Convert degrees to radians
num degrees = radiansToDegrees(latRadians);
Check if a given geo point is in the bouding box
bool inBoudingBox = geodesy.isGeoPointInBoudingBox(l1, l2, l3);
Calculate the geo point of intersection of two given paths
LatLng intersectionByPaths = geodesy.intersectionByPaths(l1, l2, b1, b2);
Calculate signed distance from a geo point to greate circle with start and end points
num distanceToGreatCircle = geodesy.crossTrackDistanceTo(l1, l2, l3);
Check if a given geo point is in the a polygon using even-odd rule algorithm
bool isGeoPointInPolygon = geodesy.isGeoPointInPolygon(l, poly);
Get a list of points within a distance in meters from a given point
final point = LatLng(51.0, 0);
final pointsToCheck = <LatLng>[/* points here */];
final distance = 10000;
List<LatLng> geofencedPoints = geodesy.pointsInRange(point, pointsToCheck, distance);