• CHANGELOG.md
• Example
• Installing
• Versions
• 80

# geodesy #

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

## Getting Started #

``````geodesy:
``````

### Include the widget in your dart file #

``````import 'package:geodesy/geodesy.dart';
``````

## Usage #

### Geodesy() #

``````Geodesy geodesy = Geodesy();
``````

### LatLng(double latitude, double longitude) #

``````LatLng l = LatLng(22.308, 114.1716);
``````

## Methods #

### destinationPointByDistanceAndBearing(LatLng l, num distance, num bearing, num radius) #

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, null);
``````

### midPointBetweenTwoGeoPoints(LatLng l1, LatLng l2) #

Calcuate the midpoint bewteen teo geo points.

``````LatLng midpoint = geodesy.midPointBetweenTwoGeoPoints(l1, l2);
``````

### distanceBetweenTwoGeoPoints(LatLng l1, LatLng l2, num radius) #

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, null);
``````

### bearingBetweenTwoGeoPoints(LatLng l1, LatLng l2) #

Calculate the bearing from point l1 to point l2.

``````num finalBearing = geodesy.finalBearingBetweenTwoGeoPoints(l1, l2);
``````

### finalBearingBetweenTwoGeoPoints(LatLng l1, LatLng l2) #

Calculate the final bearing from point l1 to point l2.

``````num finalBearing = geodesy.finalBearingBetweenTwoGeoPoints(l1, l2);
``````

``````num l1LatRadians = degreesToRadians(l1.lat);
``````

``````num degrees = radiansToDegrees(latRadians);
``````

### isGeoPointInBoudingBox(LatLng l, LatLng topLeft, LatLng bottomRight) #

Check if a given geo point is in the bouding box

``````bool inBoudingBox = geodesy.isGeoPointInBoudingBox(l1, l2, l3);
``````

### intersectionByPaths(LatLng l1, LatLng l2, num b1, num b2) #

Calculate the geo point of intersection of two given paths

``````LatLng intersectionByPaths = geodesy.intersectionByPaths(l1, l2, b1, b2);
``````

### crossTrackDistanceTo(LatLng l1, LatLng start, LatLng end, num radius) #

Calculate signed distance from a geo point to greate circle with start and end points

``````num distanceToGreatCircle = geodesy.crossTrackDistanceTo(l1, l2, l3, null);
``````

### isGeoPointInPolygon(LatLng l, List<LatLng> polygon)

Check if a given geo point is in the a polygon using even-odd rule algorithm

``````bool isGeoPointInPolygon = geodesy.isGeoPointInPolygon(l, poly);
``````

# CHANGELOG #

## 0.3.0 #

• Deprecated LatLng

## 0.1.1 #

• Reformatted with Dart Style

## 0.1.0 #

• Initial version, created by wingkwong

example/main.dart

``````import '../lib/geodesy.dart';

main() async {
Geodesy geodesy = Geodesy();
LatLng l1 = LatLng(50.06638889, 5.71472222);
LatLng l2 = LatLng(58.64388889, 3.07000000);

num distance = geodesy.distanceBetweenTwoGeoPoints(l1, l2, null);
print("[distanceBetweenTwoGeoPoints] Distance: " + distance.toString());

LatLng l3 = LatLng(51.4778, -0.0015);
LatLng distinationPoint =
geodesy.destinationPointByDistanceAndBearing(l3, 7794.0, 300.7, null);
print("[destinationPointByDistanceAndBearing] Lat: " +
distinationPoint.latitude.toString());
print("[destinationPointByDistanceAndBearing] Lng: " +
distinationPoint.longitude.toString());

LatLng l4 = LatLng(52.205, 0.119);
LatLng l5 = LatLng(48.857, 2.351);
num bearing = geodesy.bearingBetweenTwoGeoPoints(l4, l5);
print("[bearingBetweenTwoGeoPoints] Bearing: " + bearing.toString());

num finalBearing = geodesy.finalBearingBetweenTwoGeoPoints(l4, l5);
print("[finalBearingBetweenTwoGeoPoints] Bearing:" + finalBearing.toString());

LatLng midpoint = geodesy.midPointBetweenTwoGeoPoints(l4, l5);
print("[midPointBetweenTwoGeoPoints] Midpoint Lat: " +
midpoint.latitude.toString());
print("[midPointBetweenTwoGeoPoints] Midpoint Lng: " +
midpoint.longitude.toString());

bool inBoudingBox = geodesy.isGeoPointInBoudingBox(l3, l5, l4);
print("[isGeoPointInBoudingBox]: " + inBoudingBox.toString());

num b1 = 108.547;
num b2 = 32.435;
LatLng intersectionByPaths = geodesy.intersectionByPaths(l4, l5, b1, b2);
print(
"[intersectionByPaths] Lat: " + intersectionByPaths.latitude.toString());
print(
"[intersectionByPaths] Lng: " + intersectionByPaths.longitude.toString());

LatLng l6 = LatLng(50.587, 1.231);
num distanceToGreatCircle = geodesy.crossTrackDistanceTo(l4, l5, l6, null);
print("[crossTrackDistanceTo] :" + distanceToGreatCircle.toString());

List<LatLng> poly = [
LatLng(1.0, 1.0),
LatLng(1.0, 2.0),
LatLng(2.0, 2.0),
LatLng(2.0, 1.0)
];
LatLng l7 = LatLng(1.5, 1.5);
bool isGeoPointInPolygon = geodesy.isGeoPointInPolygon(l7, poly);
print("[isGeoPointInPolygon] :" + isGeoPointInPolygon.toString());
}
``````

## Use this package as a library

### 1. Depend on it

``````
dependencies:
geodesy: ^0.3.0

``````

### 2. Install it

You can install packages from the command line:

with pub:

``````
\$ pub get

``````

with Flutter:

``````
\$ flutter packages get

``````

Alternatively, your editor might support `pub get` or `flutter packages get`. Check the docs for your editor to learn more.

### 3. Import it

Now in your Dart code, you can use:

``````
import 'package:geodesy/geodesy.dart';
``````
0.3.0 Feb 7, 2019
0.2.0 Feb 5, 2019
0.1.1 Feb 5, 2019
0.1.0 Jan 19, 2019
 Popularity: Describes how popular the package is relative to other packages. [more] 61 Health: Code health derived from static analysis. [more] 100 Maintenance: Reflects how tidy and up-to-date the package is. [more] 100 Overall: Weighted score of the above. [more] 80

We analyzed this package on Apr 25, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

• Dart: 2.2.0
• pana: 0.12.14

#### Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library `package:geodesy/geodesy.dart`.

#### Health suggestions

Format `lib/geodesy.dart`.

Run `dartfmt` to format `lib/geodesy.dart`.

#### Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
latlong ^0.6.1 0.6.1
Transitive dependencies
ansicolor 1.0.2
console_log_handler 1.1.6
intl 0.15.8
logging 0.11.3+2
path 1.6.2
validate 1.7.0