Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This version uses latlong2 for latitude and longitude calculation #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.minimap.maxColumn": 80
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.0

* BREAKING CHANGE: This version uses latlong2 for latitude and longitude calculation. The goal is to make it compatible with flutter_map

## 2.0.1

* Update Dart DSK version up to 2.17.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In your dart/flutter project add the dependency:
```
dependencies:
...
maps_toolkit: ^2.0.1
maps_toolkit: ^3.0.0
```

A simple usage example:
Expand Down
1 change: 1 addition & 0 deletions example/maps_toolkit_example.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:latlong2/latlong.dart';
import 'package:maps_toolkit/maps_toolkit.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion lib/maps_toolkit.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Maps toolkit (port from android-maps-utils library)
library maps_toolkit;

export 'src/latlng.dart';
// export 'src/latlng_.dart';
export 'src/polygon_util.dart';
export 'src/spherical_util.dart';
4 changes: 3 additions & 1 deletion lib/src/kalman_filter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:math';

import 'latlng.dart';
// import 'latlng.dart';
import 'package:latlong2/latlong.dart';

import 'location.dart';
import 'spherical_util.dart';

Expand Down
32 changes: 0 additions & 32 deletions lib/src/latlng.dart

This file was deleted.

32 changes: 32 additions & 0 deletions lib/src/latlng_X.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// class LatLng_X {
// final double latitude;
// final double longitude;

// LatLng_(this.latitude, this.longitude);

// factory LatLng_.fromMap(Map<String, double> dataMap) =>
// LatLng_(dataMap['latitude']!, dataMap['longitude']!);

// @override
// // ignore: type_annotate_public_apis
// bool operator ==(other) {
// if (other is LatLng_) {
// return other.latitude == latitude && other.longitude == longitude;
// }

// return false;
// }

// @override
// int get hashCode =>
// _combine(_combine(0, latitude.hashCode), longitude.hashCode);

// int _combine(int hash, int value) {
// hash = 0x1fffffff & (hash + value);
// hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
// return hash ^ (hash >> 6);
// }

// @override
// String toString() => 'Lat: $latitude, Lng: $longitude';
// }
4 changes: 3 additions & 1 deletion lib/src/location.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'latlng.dart';
import 'package:latlong2/latlong.dart';

// import 'latlng_.dart';

class Location {
final LatLng latlng;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/polygon_util.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:collection';
import 'dart:math';

import 'package:latlong2/latlong.dart';
import 'package:maps_toolkit/src/spherical_util.dart';

import 'latlng.dart';
// import 'latlng_.dart';
import 'math_util.dart';

/// Port of PolyUtil from android-maps-utils (https://github.com/googlemaps/android-maps-utils)
Expand Down
4 changes: 3 additions & 1 deletion lib/src/spherical_util.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:math';

import 'latlng.dart';
import 'package:latlong2/latlong.dart';

// import 'latlng_.dart';
import 'math_util.dart';

/// Port of SphericalUtil from android-maps-utils (https://github.com/googlemaps/android-maps-utils)
Expand Down
7 changes: 4 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: maps_toolkit
description: Maps toolkit - geo-measurements utils - area of polygon, distance between point, heading and offset between points (port of SphericalUtil, PolyUtil from `android-maps-utils`).
version: 2.0.1
version: 3.0.0
homepage: https://github.com/kb0/maps_toolkit/

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: '>=2.17.0 <3.0.0'

dependencies:
dependencies:
latlong2: ^0.8.1

dev_dependencies:
lints: ^2.0.0
Expand Down
1 change: 1 addition & 0 deletions test/maps_toolkit_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:math';

import 'package:latlong2/latlong.dart';
import 'package:maps_toolkit/maps_toolkit.dart';
import 'package:maps_toolkit/src/math_util.dart';
import 'package:test/test.dart';
Expand Down
11 changes: 9 additions & 2 deletions test/polygon_util_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:latlong2/latlong.dart';
import 'package:maps_toolkit/maps_toolkit.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -111,8 +112,13 @@ void main() {
PolygonUtil.containsLocation(LatLng(1, 1), [], false), equals(false));
});

// test('containsLocation without point', () {
// expect(PolygonUtil.containsLocation(LatLng(99, 99), polygon, true),
// equals(false));
// });

test('containsLocation without point', () {
expect(PolygonUtil.containsLocation(LatLng(99, 99), polygon, true),
expect(PolygonUtil.containsLocation(LatLng(90, 90), polygon, true),
equals(false));
});

Expand Down Expand Up @@ -240,7 +246,8 @@ void main() {
makeList([-45, -180, -45, -small]),
makeList([
-45,
180 + small,
//180 + small,
180, // MAX: 180 degree
-45,
180 - small,
-45 - small,
Expand Down