maps_toolkit
3.1.0Maps toolkit - geo-measurements utils - area of polygon, distance between point, heading and offset between points (port of SphericalUtil, PolyUtil from `android-maps-utils`).
Readme
maps_toolkit
Pub Package Build Status Coverage Status GitHub Issues GitHub Forks GitHub Stars GitHub License
A library for area, distance, heading measurements (spherical_util.dart if port from android-maps-utils).
Getting Started
In your dart/flutter project add the dependency:
dependencies:
...
maps_toolkit: ^3.0.0
A simple usage example:
import 'package:maps_toolkit/maps_toolkit.dart';
main() {
val distanceBetweenPoints = SphericalUtil.computeDistanceBetween(
LatLng(51.5073509, -0.1277583),
LatLng(48.856614, 2.3522219)
);
final p1 = LatLng(45.153474463955796, 39.33852195739747);
final p2 = LatLng(45.153474463955796, 39.33972358703614);
final p3 = LatLng(45.15252112936569, 39.33972358703614);
final p4 = LatLng(45.1525022138355, 39.3385460972786);
val areaInSquareMeters = SphericalUtil.computeArea([p1, p2, p3, p4, p1]);
}
Usage with Google Maps package (specify a prefix for an import):
import 'package:maps_toolkit/maps_toolkit.dart' as mp;
import 'package:google_maps/google_maps.dart';
import 'package:test/test.dart';
void main() {
final pointFromToolkit = mp.LatLng(90, 0);
final pointFromGoogleMap = LatLng(90, 0);
mp.SphericalUtil.computeAngleBetween(pointFromToolkit, pointFromToolkit);
}
List of functions
-
SphericalUtil.computeArea- calculate the area of a closed path on Earth. -
SphericalUtil.computeDistanceBetween- calculate the distance between two points, in meters. -
SphericalUtil.computeHeading- calculate the heading from one point to another point. -
SphericalUtil.computeLength- calculate the length of the given path, in meters, on Earth. -
SphericalUtil.computeOffset- calculate the point resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north). -
SphericalUtil.computeOffsetOrigin- calculate the location of origin when provided with a point destination, meters travelled and original heading. -
SphericalUtil.computeSignedArea- calculate the signed area of a closed path on Earth. -
SphericalUtil.interpolate- calculate the point which lies the given fraction of the way between the origin and the destination. -
PolygonUtil.containsLocation- computes whether the given point lies inside the specified polygon. -
PolygonUtil.isLocationOnEdge- computes whether the given point lies on or near the edge of a polygon, within a specified tolerance in meters. -
PolygonUtil.isLocationOnPath- computes whether the given point lies on or near a polyline, within a specified tolerance in meters. -
PolygonUtil.locationIndexOnPath- computes whether (and where) a given point lies on or near a polyline, within a specified tolerance. -
PolygonUtil.locationIndexOnEdgeOrPath- computes whether (and where) a given point lies on or near a polyline, within a specified tolerance. -
PolygonUtil.simplify- simplifies the given poly (polyline or polygon) using the Douglas-Peucker decimation algorithm. -
PolygonUtil.isClosedPolygon- returns true if the provided list of points is a closed polygon. -
PolygonUtil.distanceToLine- computes the distance on the sphere between the point p and the line segment start to end. -
PolygonUtil.decode- decodes an encoded path string into a sequence of LatLngs. -
PolygonUtil.encode- encodes a sequence of LatLngs into an encoded path string.
Features and bugs
Please file feature requests and bugs at the issue tracker.
Changelog
3.1.0
- Switch default earth radius from mean radius (WGS-84 ellipsoid) into equatorial radius (WGS-84 ellipsoid),
for compatibility it's possible to setup mean radius
Earth.radius = Earth.meanRadius
3.0.0
- Update Dart DSK version to 3.0.0+
- Fix PolygonUtil.decode on JavaScript (https://github.com/Dammyololade/flutter_polyline_points/issues/40#issuecomment-751765055)
2.0.1
- Update Dart DSK version up to 2.17.0
- Add LatLng.toString, Location.toString
2.0.0
- BREAKING CHANGE: This version requires Dart SDK 2.12.0 or later (null safety).
1.1.0+2
- fix PolygonUtils.simplify
1.1.0+1
- fix PolygonUtils import
1.1.0
- add PolygonUtils (port from android-maps-utils)
1.0.1+3
- fix issues with deps (move pedantic into dev_dependencies)
1.0.1+2
- fix lint issues
1.0.1+1
- Fix typos
1.0.1
- Documentation update
1.0.0
- Initial version
- Add SphericalUtil (port from android-maps-utils)
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add maps_toolkitpubspec.yaml
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: 3.1.0
homepage: https://github.com/kb0/maps_toolkit/
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
dev_dependencies:
test: any
lints: any
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 1.0.0 | On demand | Download | 309f6601…1d5524 |
| 1.0.1 | On demand | Download | b9521a2c…b0e9c6 |
| 1.0.1+1 | On demand | Download | 3a1b2f99…1b8cbb |
| 1.0.1+2 | On demand | Download | 17236d0d…8fdbbf |
| 1.0.1+3 | On demand | Download | 5cacf7a9…0e9a06 |
| 1.1.0 | On demand | Download | 88687eb2…4936cf |
| 1.1.0+1 | On demand | Download | 0f183149…fca2e1 |
| 1.1.0+2 | On demand | Download | 802a2082…038bb4 |
| 2.0.0 | On demand | Download | df57d905…8dbb76 |
| 2.0.1 | On demand | Download | 7771cd4d…8c5b3d |
| 3.0.0 | On demand | Download | 277877f9…0e3e2f |
| 3.1.0 | Cached · Upstream SHA-256 matched | Download | ea5915a8…68ec28 |
Dependencies
No direct dependencies declared.