Skip to content

Commit

Permalink
Prepare for release 0.0.7 (#119)
Browse files Browse the repository at this point in the history
* initial null-safety implementation

* attributes non-nullable + tests, fix meta tests

* make altitude for Position and BBox nullable

* update action deps, build runner

* delete conflicting outputs, dart test on PR action

* Strongly type and refactor geomEach meta function

This commit also renames Geometry to GeometryObject

* simplify geomEach

* Add coverage reporting to pull requests tests

* Allow PR coverage comment to fail

This allows PRs from forks to still run the tests successfully

* Refactor coverage reporting into its own job

The coverage job is allowed to continue on error, letting the entire
workflow 'pass' if we hit issues running or reporting coverage

* Move coverage reporting into separate workflow

* geomEach: nullable fields #36

* fix types in tests

* Update to latest romeovs/lcov-reporter-action

This should resolve an issue where the 'comment code coverage on PR'
action fails after being merged into main. See
romeovs/lcov-reporter-action#16

* raise version for release 0.0.3

* [meta] add implementation and test for featureEach and propEach (#24)

* Assemble different types, refactor GeoJSON serialization, general improvements (#43)

* #19, #20, #21, refactor

* convert GeoJSONObjectType to enum, rename

* rm overridden bboxes

* Implement vector operations #23

* statically type 'round' helper func, fix unit test

* gen coverage

* fix typo

* geojson unit tests, type fixes

* fix deserialization with GeoJSONObjectType, implement hashCode

* initial unit tests for new constructors

* integration tests

* fix path

* test bbox on other geojson types

* update enum tests

* required params for new constructors, unit tests

* license notices

* bump version for release

* Add basic benchmarking framework (#51)

* Add pub version badge

* [meta] add coordeach implementation (#50)

* [meta] add coordeach implementation

* [benchmark] add coordeach benchmark using test fixtures

* Add implementation for getCoord & getCoords // invariant package (#53)

* initial getCoord & getCoords implementation

* WIP test coords/coord

* test gitpod flutter config

* ports invariants package (#62)

* dart pub get added

* wip, type problem

* fixed return error of the test

* Gitpod config

* new test cases, changed comments

* standardized the comments

* wrapped List in brackets

* some minor typo edit

* added highlight in documentation

* formatted conflicting files

* deleted the gitpod files

Co-authored-by: Arman Torkzaban <armantorkzaban@Armans-MacBook-Pro.local>

Co-authored-by: arman <armantorkzaban@icloud.com>
Co-authored-by: arman <armantorkzaban@users.noreply.github.com>
Co-authored-by: Arman Torkzaban <armantorkzaban@Armans-MacBook-Pro.local>

* Add flattenEach function and tests (#48)

* Add flattenEach function and tests

* Refactor flattenEach slightly

* Refactor meta -- breaking of iterations tests

* Explicitly do not support nested GeometryCollections

* Update documentation links

* Use more specific type checks in flattenEach test

* rm duplicate fcMixed

* remove geometryCollection clause

* warning for nested GeometryCollection

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* refactor coordEach with geomEach, change type in geomEach callback (#68)

* [meta] add coordeach implementation

* Rework coordEach implementation to match setup more from geomEach

* cleanup

* optimize for geometry collection

* refactor coordEach with geomEach, change type in geomEach callback

Co-authored-by: Tobrun Van Nuland <tobrun.van.nuland@gmail.com>

* Port coordAll function and test, also: refactor coordEach callback  (#64)

* beginning

* wip coordAll

* coordAll test, WIP

* changes CoordEachCallback's signature

* typecast removed, test corrected

* changes before merging

* refactor for Position in CoordEachCallback

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Update README.md

* Feature reducers (#49)

* Temporarily type geomEach callback to GeometryType

* Add geomReduce function and tests

* propReduce function

* WIP - featureReduce()

* WIP

* added examples and documentations

* flattenReduce WIP

* WIP

* coordReduce

* documentation

* add static types

* merge readme

* prepare new merge

* generic types for all reducer functions

* TurfJS compatible solution with type checks

* add cloning

* fixed types passed to callbacks, propReduce test

* flattenReduce and featureReduce test

* coordReduce

* minor type conv. num to int

Co-authored-by: Arman Torkzaban <armantorkzaban@icloud.com>
Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Port cluster functions and tests (#69)

* port functions

* getCluster documentation

* WIP documentation

* Did the documentation

* wrote tests

* benchmarks - in process

* moved benchmarks to separate file

* exported clusters.dart

Co-authored-by: armantorkzaban <armantorkzaban@icloud.com>

* Port meta segment functions & lineSegment (#70)

* initial commit to segment file

* beginning

* lineSegment()

* lineSegment

* refactor

* lineSegment tests

* polygon test

* wip segmentEach

* rewrite segmentEach witohut coordEach

* fix flattenEachCallback

* combine units

* tests for segmentEach

* segmentEach id check tests

* segmentReduce impltd.

* updated README

* Documentation

* benchmark init

Co-authored-by: Arman Torkzaban <armantorkzaban@icloud.com>

* split up meta into separate files (#72)

* Meta functions extension methods (#73)

* initial setup

* fix export, add all *each functions

* implement 'other' functions

* implement *reduce functions

* fix tests

* rm geojson param for reducers

* Update functions and packages in README.md (#67)

* WIP - updating README.md

* missing new functions & packages

* helpers function aint needed anymore - constructor

* Links added and unnecessary funtioncs deleted

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Raise version to 0.0.5

* Documentation (#75)

* in process - early analysis of the work

* linked the meta functions in readme

* CONTRIBUTING.md

* links to the sources

* edited typos

* documentation work

* closes #77, closes #16

* proofread

* improves pub.dev score, closes #79, #78, #75

* Added deleted model, complemented contributing.md

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* raise to version 0.0.6

* Improve pub score & raise to version 0.0.6+2 (#82)

* add examples, fix segment * callbacks

* raise version to 0.0.6+2

* Improve pub score (rename example file, raise to 0.0.6+3) (#84)

* add examples, fix segment * callbacks

* raise version to 0.0.6+2

* Rename example file, raise to 0.0.6+3

* Implement `nearestPointOn(Multi)Line` and `internal` intersects helper (Attempt 2) (#87)

* Implement `nearestPointOn(Multi)Line` (#86)

Co-authored-by: Levente Morva <levente95@gmail.com>

* localIndex and index

* add documentation

* Fix `globalIndex` behaviour

Co-authored-by: Levente Morva <levente95@gmail.com>

* fix test, according to new globalIndex behaviour

* add intersection test

Co-authored-by: Levente Morva <levente95@gmail.com>

* Port explode function and test (#93)

* initial version without tests

* closes #93

* updated readme for explode

* fixed formatting

Co-authored-by: armantorkzaban <armantorkzaban@icloud.com>

* Merge bbox-polygon and bbox, center, polyline decode (#99)

* 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

Co-authored-by: Dennis Mwea <mweadennis2@gmail.com>
Co-authored-by: Lukas Himsel <lukas@himsel.me>

* 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 <mweadennis2@gmail.com>
Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Implement rhumbBearing function and test (#109)

* initial commit, stolen from @armantorkzaban

* fix formatting

* cleanup comments

* Ports lineToPolygon, polygonToLine, and their tests (#104)

* line_to_polygon ported

* test init of lineToPolygon

* debugging the test on line to polygon

* line_to_polygon_test done

* polygonToLine init

* check for features' tyope in FeatureCollections

* file name change

* test and impl. done for polygonToLine

* refactor autocomplete, lineStringToPolygon

* comments resolved

* type added

* implementation and test and type setting

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Adds proper documentation to feature-conversion Part I (#115)

* line_to_polygon ported

* test init of lineToPolygon

* debugging the test on line to polygon

* line_to_polygon_test done

* polygonToLine init

* check for features' tyope in FeatureCollections

* file name change

* test and impl. done for polygonToLine

* refactor autocomplete, lineStringToPolygon

* comments resolved

* type added

* implementation and test and type setting

* corrected documentation

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Update impl status of feature conversion package

* Ports truncate package and its test (#111)

* implemented

* test init

* moving on with the test

* test finished.

* comments resolved

* add truncate reference

* Ports clean_coords and its test (#112)

* init

* implemented

* test init - imported

* test, moving on

* implemented points in comments

* resolving comments

* test done

* readme updated, js removed

* fix turf_equality dep, replace forEach with for

* update types

* trying to fix mutation

* refactor, fix tests

* another variance

* simplified, cleaned comments

* seems like it works!

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* Debugs GeometryCollection condition in truncate (#121)

* implemented

* test init

* moving on with the test

* test finished.

* comments resolved

* updated readme.md

* changed from forEach to for and used the element

* changed forEach to a for loop

* variable name changed - resolving a comment

* rid of redundant case for GeometryCollection, test

Co-authored-by: Lukas Himsel <lukas@himsel.me>

* close #116 - add src path to README

* update changelog, bump version for release

Co-authored-by: Brad Parham <baparham@gmail.com>
Co-authored-by: Tobrun <tobrun.van.nuland@gmail.com>
Co-authored-by: arman <armantorkzaban@icloud.com>
Co-authored-by: arman <armantorkzaban@users.noreply.github.com>
Co-authored-by: Arman Torkzaban <armantorkzaban@Armans-MacBook-Pro.local>
Co-authored-by: Levente Morva <levente95@gmail.com>
Co-authored-by: Dennis Mwea <mweadennis2@gmail.com>
  • Loading branch information
8 people committed Jul 11, 2022
1 parent cfeebad commit a9b8df7
Show file tree
Hide file tree
Showing 174 changed files with 7,031 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ build/
# Directory created by dartdoc
doc/api/

coverage/
coverage/

.idea/

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
## 0.0.7

- Implements `nearestPointOn(Multi)Line` [#87](https://github.com/dartclub/turf_dart/pull/87)
- Implements `explode` function [#93](https://github.com/dartclub/turf_dart/pull/93)
- Implements `bbox-polygon` and `bbox`, `center`, polyline functions [#99](https://github.com/dartclub/turf_dart/pull/99)
- Updates the `BBox`-class constructor [#100](https://github.com/dartclub/turf_dart/pull/100)
- Implements `rhumbBearing` function [#109](https://github.com/dartclub/turf_dart/pull/109)
- Implements `lineToPolygon` and `polygonToLine` functions [#104](https://github.com/dartclub/turf_dart/pull/104)
- Implements `truncate` function [#111](https://github.com/dartclub/turf_dart/pull/111)
- Implements `cleanCoord` function [#112](https://github.com/dartclub/turf_dart/pull/112)
- Some documentation & README improvements

## 0.0.6+3

- Rename examples file

## 0.0.6+2

- Added code examples
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,32 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
### Measurement
- [ ] along
- [ ] area
- [ ] bbox
- [ ] bboxPolygon
- [x] [bearing](https://github.com/dartclub/turf_dart/blob/main/lib/bearing.dart)
- [ ] center
- [x] [bbox](https://github.com/dartclub/turf_dart/blob/main/lib/src/bbox.dart)
- [x] [bboxPolygon](https://github.com/dartclub/turf_dart/blob/main/lib/src/bbox_polygon.dart)
- [x] [bearing](https://github.com/dartclub/turf_dart/blob/main/lib/src/bearing.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)
- [x] [distance](https://github.com/dartclub/turf_dart/blob/main/lib/distance.dart)
- [x] [destination](https://github.com/dartclub/turf_dart/blob/main/lib/src/destination.dart)
- [x] [distance](https://github.com/dartclub/turf_dart/blob/main/lib/src/distance.dart)
- [ ] envelope
- [ ] length
- [x] [midpoint](https://github.com/dartclub/turf_dart/blob/main/lib/midpoint.dart)
- [x] [midpoint](https://github.com/dartclub/turf_dart/blob/main/lib/src/midpoint.dart)
- [ ] pointOnFeature
- [ ] polygonTangents
- [ ] pointToLineDistance
- [ ] rhumbBearing
- [x] [rhumbBearing](https://github.com/dartclub/turf_dart/blob/main/lib/src/rhumb_bearing.dart)
- [ ] rhumbDestination
- [ ] rhumbDistance
- [ ] square
- [ ] greatCircle

### Coordinate Mutation
- [ ] cleanCoords
- [x] [cleanCoords](https://github.com/dartclub/turf_dart/blob/main/lib/src/clean_coords.dart)
- [ ] flip
- [ ] rewind
- [ ] round
- [ ] truncate
- [x] [truncate](https://github.com/dartclub/turf_dart/blob/main/lib/src/truncate.dart)

### Transformation
- [ ] bboxClip
Expand All @@ -122,14 +122,15 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [ ] transformScale
- [ ] union
- [ ] voronoi
- [x] [polyLineDecode](https://github.com/Dennis-Mwea/turf_dart/blob/main/lib/src/polyline.dart)

### Feature Conversion
- [ ] combine
- [ ] explode
- [x] [explode](https://github.com/dartclub/turf_dart/blob/main/lib/src/explode.dart)
- [ ] flatten
- [ ] lineToPolygon
- [x] [lineToPolygon](https://github.com/dartclub/turf_dart/blob/main/lib/src/line_to_polygon.dart)
- [ ] polygonize
- [ ] polygonToLine
- [x] [polygonToLine](https://github.com/dartclub/turf_dart/blob/main/lib/src/polygon_to_line.dart)

### MISC
- [ ] ellipse
Expand All @@ -143,7 +144,7 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [ ] lineSliceAlong
- [ ] lineSplit
- [ ] mask
- [ ] nearestPointOnLine
- [x] [nearestPointOnLine](https://github.com/dartclub/turf_dart/blob/main/lib/src/nearest_point_on_line.dart)
- [ ] sector
- [ ] shortestPath
- [ ] unkinkPolygon
Expand Down Expand Up @@ -175,7 +176,7 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [ ] triangleGrid

### Classification
- [x] [nearestPoint](https://github.com/dartclub/turf_dart/blob/main/lib/nearest_point.dart)
- [x] [nearestPoint](https://github.com/dartclub/turf_dart/blob/main/lib/src/nearest_point.dart)

### Aggregation
- [ ] collect
Expand Down
21 changes: 21 additions & 0 deletions benchmark/explode_benchmark.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:benchmark/benchmark.dart';
import 'package:turf/src/explode.dart';
import 'package:turf/turf.dart';

var poly = Polygon(coordinates: [
[
Position.of([0, 0]),
Position.of([0, 10]),
Position.of([10, 10]),
Position.of([10, 0]),
Position.of([0, 0]),
],
]);

main() {
group('explode', () {
benchmark('simple', () {
explode(poly);
});
});
}
3 changes: 3 additions & 0 deletions lib/bbox.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_bbox;

export "src/bbox.dart";
3 changes: 3 additions & 0 deletions lib/bbox_polygon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_bbox_polygon.dart;

export 'src/bbox_polygon.dart';
1 change: 1 addition & 0 deletions lib/bearing.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library turf_bearing;

export 'src/bearing.dart';
export 'src/rhumb_bearing.dart';
3 changes: 3 additions & 0 deletions lib/center.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_center;

export 'src/center.dart';
3 changes: 3 additions & 0 deletions lib/clean_coords.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library clean_coords.dart;

export 'src/clean_coords.dart';
3 changes: 3 additions & 0 deletions lib/explode.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library explode;

export 'src/explode.dart';
3 changes: 3 additions & 0 deletions lib/line_to_polygon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_line_to_polygon.dart;

export 'src/line_to_polygon.dart';
3 changes: 3 additions & 0 deletions lib/nearest_point_on_line.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_nearest_point_on_line;

export 'src/nearest_point_on_line.dart';
3 changes: 3 additions & 0 deletions lib/polygon_to_line.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_polygon_to_line;

export 'src/polygon_to_line.dart';
3 changes: 3 additions & 0 deletions lib/polyline.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_polyline;

export 'src/polyline.dart';
39 changes: 39 additions & 0 deletions lib/src/bbox.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:turf/helpers.dart';
import 'package:turf/meta.dart';

/// Calculates the bounding box for any [geoJson] object, including [FeatureCollection].
/// If [recompute] is not set and the [bbox] is not null, the function uses the [bbox] of the given [GeoJSONObject].
BBox bbox(GeoJSONObject geoJson, {bool recompute = false}) {
if (geoJson.bbox != null && !recompute) {
return geoJson.bbox!;
}

var result = BBox.named(
lat1: double.infinity,
lng1: double.infinity,
lat2: double.negativeInfinity,
lng2: double.negativeInfinity,
);

coordEach(
geoJson,
(Position? currentCoord, _, __, ___, ____) {
if (currentCoord != null) {
if (result.lng1 > currentCoord.lng) {
result = result.copyWith(lng1: currentCoord.lng);
}
if (result.lat1 > currentCoord.lat) {
result = result.copyWith(lat1: currentCoord.lat);
}
if (result.lng2 < currentCoord.lng) {
result = result.copyWith(lng2: currentCoord.lng);
}
if (result.lat2 < currentCoord.lat) {
result = result.copyWith(lat2: currentCoord.lat);
}
}
},
);

return result;
}
42 changes: 42 additions & 0 deletions lib/src/bbox_polygon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:turf/helpers.dart';

/// Takes a [Bbox] and returns an equivalent [Feature<Polygon>].
/// ```dart
/// var bbox = Bbox(0, 0, 10, 10);
/// var poly = bboxPolygon(bbox);
/// //addToMap
/// var addToMap = [poly]
/// ```
Feature<Polygon> bboxPolygon(BBox bbox,
{Map<String, dynamic> properties = const {}, dynamic id}) {
var west = bbox[0]!;
var south = bbox[1]!;
var east = bbox[2]!;
var north = bbox[3]!;

if (bbox.length == 6) {
throw Exception("turf/bbox-polygon does not support BBox with 6 positions");
}

var lowLeft = [west, south];
var topLeft = [west, north];
var topRight = [east, north];
var lowRight = [east, south];

return Feature(
bbox: bbox.clone(),
properties: properties,
id: id,
geometry: Polygon(
coordinates: [
[
Position.of(lowLeft),
Position.of(lowRight),
Position.of(topRight),
Position.of(topLeft),
Position.of(lowLeft)
]
],
),
);
}
21 changes: 21 additions & 0 deletions lib/src/center.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:turf/bbox.dart' as t;
import 'package:turf/helpers.dart';

/// Takes a [Feature] or a [FeatureCollection] and returns the absolute center point of all feature(s).
Feature<Point> center(
GeoJSONObject geoJSON, {
dynamic id,
BBox? bbox,
Map<String, dynamic>? properties,
}) {
final BBox ext = t.bbox(geoJSON);
final num x = (ext[0]! + ext[2]!) / 2;
final num y = (ext[1]! + ext[3]!) / 2;

return Feature<Point>(
id: id,
bbox: bbox,
properties: properties,
geometry: Point(coordinates: Position.named(lat: y, lng: x)),
);
}

0 comments on commit a9b8df7

Please sign in to comment.