From 1e8329739cab41417a51b58f079d00d002982d06 Mon Sep 17 00:00:00 2001 From: arman Date: Mon, 20 Jun 2022 09:04:39 +0200 Subject: [PATCH] Added missing alt1, alt2 in BBox constructor, BBox put in README (#100) * Added coordEach translation * Added bBox translation * Added center translation * Added decode points from polyline * Update read me * Remove and exclude .idea from git indexing * Convert double to Position * Use existing coord each implementation * Return bBox points in the correct order * Add bbox unit test * Change libraries namespaces * Code refactor * Add doc blocs and some more missing functions * Add encode polyline feature * Add tests for both encode and decode polylines * Add bbox tests * Add helper functions * Convert array to Bbox * Remove redundant helper functions * Add documentation * implementation * tests init, documentation, addition of types and debug * implemented, docs * test initiation * added it to /lib, updated readme, can close 97 * renamed the test file * comments resolved * typo * unused lib removed * merge bbox-polygon * missing center_test.dart * imported bbox_polygon to center_test * test error fixes * added alt 1,2 to Bbox * added bbox to readme * Fix typos * bbox constructure changed to standard * bbox optional positional param. set accordingly * Documentation on limitation of optional prms. Bbox * Update geojson.dart * fix order of BBox default constructor in test * update doc comment * fix previously missed null exceptions Co-authored-by: Dennis Mwea Co-authored-by: Lukas Himsel --- README.md | 6 +++--- lib/src/geojson.dart | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 256190f..86badee 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,10 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the ### Measurement - [ ] along - [ ] area -- [ ] bbox -- [x] [bboxPolygon] (https://github.com/dartclub/turf_dart/blob/main/lib/bbox_polygon.dart) +- [x] [bbox](https://github.com/dartclub/turf_dart/blob/main/lib/bbox.dart) +- [x] [bboxPolygon](https://github.com/dartclub/turf_dart/blob/main/lib/bbox_polygon.dart) - [x] [bearing](https://github.com/dartclub/turf_dart/blob/main/lib/bearing.dart) -- [ ] [center](https://github.com/Dennis-Mwea/turf_dart/blob/main/lib/src/center.dart) +- [x] [center](https://github.com/Dennis-Mwea/turf_dart/blob/main/lib/src/center.dart) - [ ] centerOfMass - [ ] centroid - [x] [destination](https://github.com/dartclub/turf_dart/blob/main/lib/destination.dart) diff --git a/lib/src/geojson.dart b/lib/src/geojson.dart index caf02cc..75f2e3b 100644 --- a/lib/src/geojson.dart +++ b/lib/src/geojson.dart @@ -278,13 +278,26 @@ class Position extends CoordinateType { /// Please make sure, you arrange your parameters like this: /// Longitude 1, Latitude 1, Altitude 1 (optional), Longitude 2, Latitude 2, Altitude 2 (optional) /// You can either specify 4 or 6 parameters +/// If you are using the default constructor with two dimensional positions (lng + lat only), please use the constructor like this: +/// `BBox(lng1, lat1, lng2, lat2);` class BBox extends CoordinateType { BBox( + /// longitude 1 num lng1, + + /// latitude 1 num lat1, + + /// longitude 2 for 2 dim. positions; altitude 1 for 3 dim. positions num alt1, + + /// latitude 2 for 2 dim. positions; longitude 2 for 3 dim. positions num lng2, [ + + /// latitude 2 for 3 dim. positions num? lat2, + + /// altitude 2 for 3 dim. positions num? alt2, ]) : super([ lng1, @@ -335,14 +348,18 @@ class BBox extends CoordinateType { BBox copyWith({ num? lng1, num? lat1, - num? lng2, + num? alt1, num? lat2, + num? lng2, + num? alt2, }) => - BBox( - lng1 ?? this.lng1, - lat1 ?? this.lat1, - lng2 ?? this.lng2, - lat2 ?? this.lat2, + BBox.named( + lng1: lng1 ?? this.lng1, + lat1: lat1 ?? this.lat1, + alt1: alt1 ?? this.alt1, + lng2: lng2 ?? this.lng2, + lat2: lat2 ?? this.lat2, + alt2: alt2 ?? this.alt2, ); @override