Skip to content

Commit

Permalink
Merge pull request #22 from ayoubzulfiqar/improved
Browse files Browse the repository at this point in the history
fixed & improved
  • Loading branch information
wingkwong authored Jun 13, 2023
2 parents e400e67 + 491bdf7 commit 80d59aa
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 122 deletions.
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Dart library for implementing geodesic and trigonometric calculations based on

## Getting Started

### Add the following line in your pubspec file
### Add the following line in your `pubspec.yml` file

```dart
geodesy:
Expand All @@ -23,103 +23,103 @@ import 'package:geodesy/geodesy.dart';
### Geodesy()

```dart
Geodesy geodesy = Geodesy();
final Geodesy geodesy = Geodesy();
```

### LatLng(double latitude, double longitude)

```dart
LatLng l = LatLng(22.308, 114.1716);
final 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.
Calculate a destination point given the distance and bearing. If radius is not specified, Earth radius will be used.

```dart
LatLng distinationPoint = geodesy.destinationPointByDistanceAndBearing(l3, 2400, 420.2);
final LatLng destinationPoint = geodesy.destinationPointByDistanceAndBearing(l3, 2400, 420.2);
```

### midPointBetweenTwoGeoPoints(LatLng l1, LatLng l2)

Calcuate the midpoint bewteen teo geo points.
Calculate the midpoint between teo geo points.

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

### distanceBetweenTwoGeoPoints(LatLng l1, LatLng l2, [num radius])
### 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.
Calculate the distance in meters between two geo points. If radius is not specified, Earth radius will be used.

```dart
num distance = geodesy.distanceBetweenTwoGeoPoints(l1, l2);
final num distance = geodesy.distanceBetweenTwoGeoPoints(l1, l2);
```

### bearingBetweenTwoGeoPoints(LatLng l1, LatLng l2)

Calculate the bearing from point l1 to point l2.

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

### finalBearingBetweenTwoGeoPoints(LatLng l1, LatLng l2)

Calculate the final bearing from point l1 to point l2.

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

### degreesToRadians(num degrees)

Convert degrees to radians

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

### radiansToDegrees(num radians)

Convert degrees to radians

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

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

Check if a given geo point is in the bounding box

```dart
bool inBoundingBox = geodesy.isGeoPointInBoundingBox(l1, l2, l3);
final bool inBoundingBox = geodesy.isGeoPointInBoundingBox(l1, l2, l3);
```

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

Calculate the geo point of intersection of two given paths

```dart
LatLng intersectionByPaths = geodesy.intersectionByPaths(l1, l2, b1, b2);
final 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
Calculate signed distance from a geo point to create circle with start and end points

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

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

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

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

### pointsInRange(LatLng point, List<LatLng> pointsToCheck, num distance)
Expand All @@ -130,6 +130,5 @@ 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);
List<LatLng> geoFencedPoints = geodesy.pointsInRange(point, pointsToCheck, distance);
```

4 changes: 2 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include: package:pedantic/analysis_options.yaml
# include: package:pedantic/analysis_options.yaml
include: package:lints/core.yaml

analyzer:
strong-mode:
Expand All @@ -21,7 +22,6 @@ linter:
- lines_longer_than_80_chars
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_equal_for_default_values
- prefer_final_fields
- unnecessary_new
- prefer_is_empty
Expand Down
Loading

0 comments on commit 80d59aa

Please sign in to comment.