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

release 0.0.9 #164

Merged
merged 75 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ab88527
initial null-safety implementation
lukas-h Nov 21, 2021
851338f
attributes non-nullable + tests, fix meta tests
lukas-h Nov 22, 2021
31f9e21
make altitude for Position and BBox nullable
lukas-h Nov 22, 2021
d7a630b
update action deps, build runner
lukas-h Nov 22, 2021
b23f3f1
delete conflicting outputs, dart test on PR action
lukas-h Nov 23, 2021
95631be
Strongly type and refactor geomEach meta function
baparham Nov 22, 2021
6494415
simplify geomEach
lukas-h Nov 23, 2021
0360b08
Add coverage reporting to pull requests tests
baparham Nov 23, 2021
3a21086
Allow PR coverage comment to fail
baparham Nov 24, 2021
736342d
Refactor coverage reporting into its own job
baparham Nov 24, 2021
d35c4ce
Move coverage reporting into separate workflow
baparham Nov 25, 2021
b5935d4
geomEach: nullable fields #36
lukas-h Nov 24, 2021
dee647e
fix types in tests
lukas-h Nov 24, 2021
272a778
Update to latest romeovs/lcov-reporter-action
baparham Nov 28, 2021
13ff21d
raise version for release 0.0.3
lukas-h Nov 28, 2021
bb33084
[meta] add implementation and test for featureEach and propEach (#24)
tobrun Dec 7, 2021
bcc7cfb
Assemble different types, refactor GeoJSON serialization, general imp…
lukas-h Dec 14, 2021
0b02608
bump version for release
lukas-h Dec 19, 2021
d427d05
Add basic benchmarking framework (#51)
baparham Jan 15, 2022
fde7642
Add pub version badge
lukas-h Jan 15, 2022
2aff26e
[meta] add coordeach implementation (#50)
tobrun Feb 20, 2022
f3b6b0a
Add implementation for getCoord & getCoords // invariant package (#53)
lukas-h Mar 16, 2022
0c4522c
Add flattenEach function and tests (#48)
baparham Mar 16, 2022
ad7b2ad
refactor coordEach with geomEach, change type in geomEach callback (#68)
lukas-h Mar 19, 2022
5c0d02a
Port coordAll function and test, also: refactor coordEach callback (…
armantorkzaban Mar 21, 2022
4f49a28
Update README.md
lukas-h Mar 24, 2022
16ade7a
Feature reducers (#49)
baparham Mar 25, 2022
03d1839
Port cluster functions and tests (#69)
lukas-h Apr 1, 2022
b3b0ae2
Port meta segment functions & lineSegment (#70)
lukas-h Apr 4, 2022
f8f95eb
split up meta into separate files (#72)
lukas-h Apr 4, 2022
4fdcb58
Meta functions extension methods (#73)
lukas-h Apr 4, 2022
a35adb1
Update functions and packages in README.md (#67)
armantorkzaban Apr 12, 2022
6d6d786
Raise version to 0.0.5
lukas-h Apr 12, 2022
2ecfc4f
Documentation (#75)
armantorkzaban Apr 15, 2022
4cb1ca7
raise to version 0.0.6
lukas-h Apr 19, 2022
9135395
Improve pub score & raise to version 0.0.6+2 (#82)
lukas-h Apr 19, 2022
a940904
Improve pub score (rename example file, raise to 0.0.6+3) (#84)
lukas-h Apr 19, 2022
57c3616
Implement `nearestPointOn(Multi)Line` and `internal` intersects helpe…
lukas-h Apr 20, 2022
560d2a8
Port explode function and test (#93)
lukas-h Jun 15, 2022
25c99d2
Merge bbox-polygon and bbox, center, polyline decode (#99)
armantorkzaban Jun 19, 2022
1e83297
Added missing alt1, alt2 in BBox constructor, BBox put in README (#100)
armantorkzaban Jun 20, 2022
ea56d89
Implement rhumbBearing function and test (#109)
lukas-h Jul 4, 2022
b17d3fd
Ports lineToPolygon, polygonToLine, and their tests (#104)
armantorkzaban Jul 4, 2022
358a43e
Adds proper documentation to feature-conversion Part I (#115)
armantorkzaban Jul 7, 2022
885bd6d
Update impl status of feature conversion package
lukas-h Jul 7, 2022
f2cfcc6
Ports truncate package and its test (#111)
armantorkzaban Jul 7, 2022
2ffce92
add truncate reference
lukas-h Jul 7, 2022
037b03c
Ports clean_coords and its test (#112)
armantorkzaban Jul 7, 2022
0895750
Debugs GeometryCollection condition in truncate (#121)
armantorkzaban Jul 7, 2022
01029fa
close #116 - add src path to README
lukas-h Jul 7, 2022
78f68e9
update changelog, bump version for release
lukas-h Jul 7, 2022
5770e4c
Added support for the area function (#123)
yardenfi Jul 28, 2022
f503b90
Implement polygon-smooth and its tests (#127)
lukas-h Aug 22, 2022
b17c9bf
Port boolean functions and tests (#91)
armantorkzaban Sep 11, 2022
c584336
Add missing parameter 'unit'. (#145)
Just-gomin Dec 21, 2022
e39cc45
Implement rhumb_distance with tests.
ggastv Apr 19, 2023
bfbbe11
Implement rhumb_destination with tests.
ggastv Apr 19, 2023
02f5497
Implement centroid with tests.
ggastv Apr 19, 2023
a0aba24
Implement transform_rotate with tests.
ggastv Apr 20, 2023
49ff385
Add truncate tests for MultiLineString, MultiPoint, MultiPolygon
ggastv Apr 20, 2023
2c2f5c5
run dart format
ggastv Apr 27, 2023
0be7e68
introduce localCoordIndex in coordEach, cover more test cases in trun…
lukas-h Apr 28, 2023
98fa780
prepare for next release, support
lukas-h Jun 13, 2023
4b7e16f
work student position
lukas-h Jun 13, 2023
38edf93
Fix excludeWrapCoord in coordEach for MultiPolygon type. (#148)
ggastv Jun 13, 2023
dcbd0e5
Merge remote-tracking branch 'origin/releases'
lukas-h Jun 13, 2023
bbccfb3
format markdown
lukas-h Jun 13, 2023
c3537d6
Document properties set by NearestPointOnLine on returned Point (#155)
Leffe108 Jan 25, 2024
bec5af9
Implement length and along (#153)
leiflinse-trivector Jan 25, 2024
c123163
Fix length_test.dart formatting (#159)
leiflinse-trivector Jan 25, 2024
620d1f9
Change return type of along to Feature<Point> (#161)
leiflinse-trivector Jan 29, 2024
a0b9304
Prepare release 0.0.9 (#162)
jsiedentop Jan 31, 2024
db20dfe
Merge branch 'releases' into main
jsiedentop Jan 31, 2024
ac46ee1
Entfernt .DS_Store
jsiedentop Jan 31, 2024
41d5b4c
Remove job offer
jsiedentop Jan 31, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ coverage/

.idea/

.DS_Store
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.9

- Implements `length`, `along` [#153](https://github.com/dartclub/turf_dart/pull/153)
- Documentation: Improves pub.dev scores by fixing bad links in Readme.md

## 0.0.8

- Implements `transformRotate`, `rhumbDistance`, `rhumbDestination`, `centroid` [#147](https://github.com/dartclub/turf_dart/pull/147)
Expand Down Expand Up @@ -38,7 +43,8 @@

## 0.0.5

- Implements *all* meta functions and`lineSegment`

- Implements *all* meta functions and `lineSegment`
- Adds a lot of documentation
- Several bug and type fixes

Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# turf.dart

ℹ️ Looking for maintainers as a work student position in Germany: Write an email to [[email protected]](mailto:[email protected]) ℹ️

[![pub package](https://img.shields.io/pub/v/turf.svg)](https://pub.dev/packages/turf)

THIS PROJECT IS WORK IN PROCESS
Expand Down Expand Up @@ -80,7 +78,7 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the

### Measurement

- [ ] along
- [x] [along](https://github.com/dartclub/turf_dart/blob/main/lib/src/along.dart)
- [x] [area](https://github.com/dartclub/turf_dart/blob/main/lib/src/area.dart)
- [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)
Expand All @@ -91,7 +89,7 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [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] [length](https://github.com/dartclub/turf_dart/blob/main/lib/src/length.dart)
- [x] [midpoint](https://github.com/dartclub/turf_dart/blob/main/lib/src/midpoint.dart)
- [ ] pointOnFeature
- [ ] polygonTangents
Expand Down Expand Up @@ -123,7 +121,7 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [ ] dissolve
- [ ] intersect
- [ ] lineOffset
- [x] [polygonSmooth](ttps://github.com/dartclub/turf_dart/blob/main/lib/src/polygon_smooth.dart)
- [x] [polygonSmooth](https://github.com/dartclub/turf_dart/blob/main/lib/src/polygon_smooth.dart)
- [ ] simplify
- [ ] tesselate
- [x] [transformRotate](https://github.com/dartclub/turf_dart/blob/main/lib/src/transform_rotate.dart)
Expand Down Expand Up @@ -234,7 +232,7 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [x] [booleanCrosses](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_crosses.dart)
- [x] [booleanDisjoint](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_disjoint.dart)
- [x] [booleanEqual](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_equal.dart)
- [x] [booleanIntersects](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_intersect.dart)
- [x] [booleanIntersects](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_intersects.dart)
- [ ] booleanOverlap
- [x] [booleanParallel](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_parallel.dart)
- [x] [booleanPointInPolygon](https://github.com/dartclub/turf_dart/blob/main/lib/src/booleans/boolean_point_in_polygon.dart)
Expand All @@ -252,4 +250,4 @@ Any new benchmarks must be named `*_benchmark.dart` and reside in the
- [x] [radiansToLength](https://github.com/dartclub/turf_dart/blob/main/lib/src/helpers.dart)
- [x] [radiansToDegrees](https://github.com/dartclub/turf_dart/blob/main/lib/src/helpers.dart)
- [ ] toMercator
- [ ] toWgs84
- [ ] toWgs84
3 changes: 3 additions & 0 deletions lib/along.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library turf_along;

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

export "src/length.dart";
54 changes: 54 additions & 0 deletions lib/src/along.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'dart:math';

import 'package:turf/bearing.dart';
import 'package:turf/destination.dart';
import 'package:turf/helpers.dart';
import 'package:turf/length.dart';
import 'package:turf/src/distance.dart' as measure_distance;
import 'package:turf/src/invariant.dart';

/// Takes a [line] and returns a [Point] at a specified [distance] along the line.
///
/// If [distance] is less than 0, it will count distance along the line from end
/// to start of line. If negative [distance] overshoots the length of the line,
/// the start point of the line is returned.
/// If [distance] is larger than line length, the end point is returned
/// If [line] have no geometry or coordinates, an Exception is thrown
Feature<Point> along(Feature<LineString> line, num distance,
[Unit unit = Unit.kilometers]) {
// Get Coords
final coords = getCoords(line);
if (coords.isEmpty) {
throw Exception('line must contain at least one coordinate');
}
if (distance < 0) {
distance = max(0, length(line, unit) + distance);
}
num travelled = 0;
for (int i = 0; i < coords.length; i++) {
if (distance >= travelled && i == coords.length - 1) {
break;
}
if (travelled == distance) {
return Feature<Point>(geometry: Point(coordinates: coords[i]));
}
if (travelled > distance) {
final overshot = distance - travelled;
final direction = bearing(Point(coordinates: coords[i]),
Point(coordinates: coords[i - 1])) -
180;
final interpolated = destination(
Point(coordinates: coords[i]),
overshot,
direction,
unit,
);
return Feature<Point>(geometry: interpolated);
} else {
travelled += measure_distance.distance(Point(coordinates: coords[i]),
Point(coordinates: coords[i + 1]), unit);
}
}
return Feature<Point>(
geometry: Point(coordinates: coords[coords.length - 1]));
}
25 changes: 25 additions & 0 deletions lib/src/length.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:turf/distance.dart';
import 'package:turf/helpers.dart';
import 'package:turf/line_segment.dart';

/// Takes a [line] and measures its length in the specified [unit].
num length(Feature<LineString> line, [Unit unit = Unit.kilometers]) {
return segmentReduce<num>(line, (
previousValue,
currentSegment,
initialValue,
featureIndex,
multiFeatureIndex,
geometryIndex,
segmentIndex,
) {
final coords = currentSegment.geometry!.coordinates;
return previousValue! +
distance(
Point(coordinates: coords[0]),
Point(coordinates: coords[1]),
unit,
);
}, 0.0) ??
0.0;
}
7 changes: 7 additions & 0 deletions lib/src/nearest_point_on_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ _NearestMulti? _nearestPointOnMultiLine(
}

/// Takes a [Point] and a [LineString] and calculates the closest Point on the [LineString].
///
/// The properties of returned [Point] will contain three values:
/// * index: closest point was found on nth line part
/// * dist: distance between [point] and the closest point on line
/// * location: distance along the line between start and the closest point.
///
/// Example:
/// ```dart
/// var line = LineString(
/// coordinates: [
Expand Down
2 changes: 2 additions & 0 deletions lib/turf.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library turf;

export 'src/along.dart';
export 'src/area.dart';
export 'src/bbox.dart';
export 'src/bearing.dart';
Expand All @@ -9,6 +10,7 @@ export 'src/destination.dart';
export 'src/distance.dart';
export 'src/geojson.dart';
export 'src/helpers.dart';
export 'src/length.dart';
export 'src/midpoint.dart';
export 'src/nearest_point.dart';
export 'src/polyline.dart';
Expand Down
15 changes: 8 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
name: turf
description: A turf.js-like geospatial analysis library working with GeoJSON, written in pure Dart.
version: 0.0.8
version: 0.0.9
environment:
sdk: ">=2.15.0 <4.0.0"
sdk: ">=2.17.0 <4.0.0"
homepage: https://github.com/dartclub/turf_dart
repository: https://github.com/dartclub/turf_dart

dependencies:
json_annotation: ^4.8.1
turf_equality: ^0.0.2
turf_pip: ^0.0.1+1

turf_equality: ^0.0.3
turf_pip: ^0.0.2
rbush: ^1.1.0
sweepline_intersections: ^0.0.3+1
sweepline_intersections: ^0.0.4

dev_dependencies:
lints: ^2.1.1
lints: ^3.0.0
test: ^1.24.3
json_serializable: ^6.7.0
build_runner: ^2.4.5
analyzer: ^5.13.0
analyzer: ^6.4.0
benchmark: ^0.3.0
Binary file removed test/.DS_Store
Binary file not shown.
98 changes: 98 additions & 0 deletions test/components/along_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'package:test/test.dart';
import 'package:turf/along.dart';
import 'package:turf/distance.dart';
import 'package:turf/helpers.dart';
import 'package:turf/length.dart';

void main() {
test('along - negative distance should count backwards', () {
final viaToEndDistance =
distance(Point(coordinates: via), Point(coordinates: end), Unit.meters);
expect(viaToEndDistance.round(), equals(198));
final resolvedViaPoint = along(line, -1 * viaToEndDistance, Unit.meters);
expect(resolvedViaPoint.geometry, isNotNull);
expect(resolvedViaPoint.geometry!.coordinates, equals(via));
});
test('along - to start point', () {
final resolvedStartPoint = along(line, 0, Unit.meters);
expect(resolvedStartPoint.geometry, isNotNull);
expect(resolvedStartPoint.geometry!.coordinates, equals(start));
});
test('along - to point between start and via', () {
final startToViaDistance = distance(
Point(coordinates: start), Point(coordinates: via), Unit.meters);
expect(startToViaDistance.round(), equals(57));
final resolvedViaPoint = along(line, startToViaDistance / 2, Unit.meters);
expect(resolvedViaPoint.geometry, isNotNull);
expect(resolvedViaPoint.geometry!.coordinates.lat.toStringAsFixed(6),
equals('55.709028'));
expect(resolvedViaPoint.geometry!.coordinates.lng.toStringAsFixed(6),
equals('13.185096'));
});
test('along - to via point', () {
final startToViaDistance = distance(
Point(coordinates: start), Point(coordinates: via), Unit.meters);
expect(startToViaDistance.round(), equals(57));
final resolvedViaPoint = along(line, startToViaDistance, Unit.meters);
expect(resolvedViaPoint.geometry, isNotNull);
expect(resolvedViaPoint.geometry!.coordinates, equals(via));
});
test('along - to point between via and end', () {
final startToViaDistance = distance(
Point(coordinates: start), Point(coordinates: via), Unit.meters);
final viaToEndDistance =
distance(Point(coordinates: via), Point(coordinates: end), Unit.meters);
expect(startToViaDistance.round(), equals(57));
expect(viaToEndDistance.round(), equals(198));
final resolvedViaPoint =
along(line, startToViaDistance + viaToEndDistance / 2, Unit.meters);
expect(resolvedViaPoint.geometry, isNotNull);
expect(resolvedViaPoint.geometry!.coordinates.lat.toStringAsFixed(6),
equals('55.708330'));
expect(resolvedViaPoint.geometry!.coordinates.lng.toStringAsFixed(6),
equals('13.186555'));
});
test('along - to end point', () {
final len = length(line, Unit.meters);
expect(len.round(), equals(254));
final resolvedEndPoint = along(line, len, Unit.meters);
expect(resolvedEndPoint.geometry, isNotNull);
expect(resolvedEndPoint.geometry!.coordinates, equals(end));
});
test('along - to end point - default unit (km)', () {
final len = length(line);
expect((len * 1000).round(), equals(254));
final resolvedEndPoint = along(line, len);
expect(resolvedEndPoint.geometry, isNotNull);
expect(resolvedEndPoint.geometry!.coordinates, equals(end));
});
test('along - beyond end point', () {
final len = length(line, Unit.meters);
expect(len.round(), equals(254));
final resolvedEndPoint = along(line, len + 100, Unit.meters);
expect(resolvedEndPoint.geometry, isNotNull);
expect(resolvedEndPoint.geometry!.coordinates, equals(end));
});
}

final start = Position.named(
lat: 55.7090430186194,
lng: 13.184645393920405,
);
final via = Position.named(
lat: 55.70901279569489,
lng: 13.185546616182755,
);
final end = Position.named(
lat: 55.70764669578079,
lng: 13.187563637197076,
);
final line = Feature<LineString>(
geometry: LineString(
coordinates: [
start,
via,
end,
],
),
);
36 changes: 36 additions & 0 deletions test/components/length_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:test/test.dart';
import 'package:turf/helpers.dart';
import 'package:turf/length.dart';

void main() {
test('length - in meters', () {
final len = length(line, Unit.meters);
expect(len.round(), equals(254));
});
test('length - default unit (km)', () {
final len = length(line);
expect((len * 1000).round(), equals(254));
});
}

final start = Position.named(
lat: 55.7090430186194,
lng: 13.184645393920405,
);
final via = Position.named(
lat: 55.70901279569489,
lng: 13.185546616182755,
);
final end = Position.named(
lat: 55.70764669578079,
lng: 13.187563637197076,
);
final line = Feature<LineString>(
geometry: LineString(
coordinates: [
start,
via,
end,
],
),
);
Binary file removed test/examples/.DS_Store
Binary file not shown.
Binary file removed test/examples/booleans/.DS_Store
Binary file not shown.
Binary file removed test/examples/booleans/disjoint/.DS_Store
Binary file not shown.
Loading