diff --git a/benchmark/explode_benchmark.dart b/benchmark/explode_benchmark.dart index 52f1808..1e916ae 100644 --- a/benchmark/explode_benchmark.dart +++ b/benchmark/explode_benchmark.dart @@ -1,5 +1,4 @@ import 'package:benchmark/benchmark.dart'; -import 'package:turf/src/explode.dart'; import 'package:turf/turf.dart'; var poly = Polygon(coordinates: [ diff --git a/benchmark/line_segment_benchmark.dart b/benchmark/line_segment_benchmark.dart index b15ed89..0bdd982 100644 --- a/benchmark/line_segment_benchmark.dart +++ b/benchmark/line_segment_benchmark.dart @@ -1,6 +1,5 @@ import 'package:benchmark/benchmark.dart'; import 'package:turf/line_segment.dart'; -import 'package:turf/helpers.dart'; void main() { LineString lineString = LineString( diff --git a/lib/intersection.dart b/lib/intersection.dart deleted file mode 100644 index 38b2cdb..0000000 --- a/lib/intersection.dart +++ /dev/null @@ -1,4 +0,0 @@ -library turf_intersection; - -export 'package:geotypes/geotypes.dart'; -export 'src/intersection.dart'; diff --git a/lib/src/along.dart b/lib/src/along.dart index f4b5026..5912431 100644 --- a/lib/src/along.dart +++ b/lib/src/along.dart @@ -4,8 +4,8 @@ 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'; +import 'distance.dart' as measure_distance; +import 'invariant.dart'; /// Takes a [line] and returns a [Point] at a specified [distance] along the line. /// @@ -24,16 +24,16 @@ Feature along(Feature line, num distance, if (distance < 0) { distance = max(0, length(line, unit) + distance); } - num travelled = 0; + num traveled = 0; for (int i = 0; i < coords.length; i++) { - if (distance >= travelled && i == coords.length - 1) { + if (distance >= traveled && i == coords.length - 1) { break; } - if (travelled == distance) { + if (traveled == distance) { return Feature(geometry: Point(coordinates: coords[i])); } - if (travelled > distance) { - final overshot = distance - travelled; + if (traveled > distance) { + final overshot = distance - traveled; final direction = bearing(Point(coordinates: coords[i]), Point(coordinates: coords[i - 1])) - 180; @@ -45,7 +45,7 @@ Feature along(Feature line, num distance, ); return Feature(geometry: interpolated); } else { - travelled += measure_distance.distance(Point(coordinates: coords[i]), + traveled += measure_distance.distance(Point(coordinates: coords[i]), Point(coordinates: coords[i + 1]), unit); } } diff --git a/lib/src/bbox.dart b/lib/src/bbox.dart index a7d37ab..7ac1bb4 100644 --- a/lib/src/bbox.dart +++ b/lib/src/bbox.dart @@ -1,4 +1,3 @@ -import 'package:turf/helpers.dart'; import 'package:turf/meta.dart'; /// Calculates the bounding box for any [geoJson] object, including [FeatureCollection]. diff --git a/lib/src/bearing.dart b/lib/src/bearing.dart index f979375..4fe7504 100644 --- a/lib/src/bearing.dart +++ b/lib/src/bearing.dart @@ -1,7 +1,6 @@ import 'dart:math'; - -import 'geojson.dart'; import 'helpers.dart'; +import 'package:geotypes/geotypes.dart'; // http://en.wikipedia.org/wiki/Haversine_formula // http://www.movable-type.co.uk/scripts/latlong.html diff --git a/lib/src/booleans/boolean_contains.dart b/lib/src/booleans/boolean_contains.dart index 171baaa..3e1b6b7 100644 --- a/lib/src/booleans/boolean_contains.dart +++ b/lib/src/booleans/boolean_contains.dart @@ -1,4 +1,3 @@ -import 'package:turf/src/invariant.dart'; import 'package:turf/turf.dart'; import 'boolean_helper.dart'; diff --git a/lib/src/booleans/boolean_intersects.dart b/lib/src/booleans/boolean_intersects.dart index 2c97870..695452a 100644 --- a/lib/src/booleans/boolean_intersects.dart +++ b/lib/src/booleans/boolean_intersects.dart @@ -1,4 +1,3 @@ -import '../../helpers.dart'; import '../../meta.dart'; import 'boolean_disjoint.dart'; diff --git a/lib/src/booleans/boolean_overlap.dart b/lib/src/booleans/boolean_overlap.dart index c4f4f36..5a12df5 100644 --- a/lib/src/booleans/boolean_overlap.dart +++ b/lib/src/booleans/boolean_overlap.dart @@ -1,4 +1,3 @@ -import 'package:turf/helpers.dart'; import 'package:turf/line_overlap.dart'; import 'package:turf/line_segment.dart'; import 'package:turf/src/invariant.dart'; diff --git a/lib/src/booleans/boolean_valid.dart b/lib/src/booleans/boolean_valid.dart index 5a06e74..cd37dac 100644 --- a/lib/src/booleans/boolean_valid.dart +++ b/lib/src/booleans/boolean_valid.dart @@ -4,7 +4,6 @@ import 'package:turf/src/booleans/boolean_point_on_line.dart'; import 'package:turf/src/invariant.dart'; import 'package:turf/src/meta/extensions.dart'; -import '../../helpers.dart'; import '../line_intersect.dart'; import 'boolean_crosses.dart'; diff --git a/lib/src/centroid.dart b/lib/src/centroid.dart index 33874ad..73f7666 100644 --- a/lib/src/centroid.dart +++ b/lib/src/centroid.dart @@ -1,7 +1,7 @@ -import 'package:turf/helpers.dart'; import 'package:turf/meta.dart'; -/// Takes a [Feature] or a [FeatureCollection] and computes the centroid as the mean of all vertices within the object. +/// Takes a [Feature] or a [FeatureCollection] and computes the centroid as +/// the mean of all vertices within the object. /// /// example: /// ```dart diff --git a/lib/src/destination.dart b/lib/src/destination.dart index 48461b9..3dfb8bd 100644 --- a/lib/src/destination.dart +++ b/lib/src/destination.dart @@ -1,6 +1,5 @@ import 'dart:math'; - -import 'geojson.dart'; +import 'package:geotypes/geotypes.dart'; import 'helpers.dart'; Position destinationRaw(Position origin, num distance, num bearing, diff --git a/lib/src/distance.dart b/lib/src/distance.dart index f8bd526..39e042c 100644 --- a/lib/src/distance.dart +++ b/lib/src/distance.dart @@ -1,6 +1,6 @@ import 'dart:math'; -import 'geojson.dart'; +import 'package:geotypes/geotypes.dart'; import 'helpers.dart'; //http://en.wikipedia.org/wiki/Haversine_formula diff --git a/lib/src/explode.dart b/lib/src/explode.dart index b2e0811..b381486 100644 --- a/lib/src/explode.dart +++ b/lib/src/explode.dart @@ -1,8 +1,7 @@ -import 'package:turf/helpers.dart'; import 'package:turf/meta.dart'; /// Takes a feature or set of features and returns all positions as [Point]s. -/// Takes [GeoJSONObhect] input. +/// Takes [GeoJSONObject] input. /// Returns [FeatureCollection] representing the exploded input features /// Throws [Exception] if it encounters an unknown geometry type /// ```dart diff --git a/lib/src/geojson.dart b/lib/src/geojson.dart deleted file mode 100644 index 24af095..0000000 --- a/lib/src/geojson.dart +++ /dev/null @@ -1 +0,0 @@ -export 'package:geotypes/geotypes.dart'; diff --git a/lib/src/intersection.dart b/lib/src/intersection.dart index 72ecf35..f8af3e7 100644 --- a/lib/src/intersection.dart +++ b/lib/src/intersection.dart @@ -1,4 +1,5 @@ -import 'geojson.dart'; +// internal functions, not meant to be exposed +import 'package:geotypes/geotypes.dart'; Point? intersects(LineString line1, LineString line2) { if (line1.coordinates.length != 2) { diff --git a/lib/src/line_overlap.dart b/lib/src/line_overlap.dart index 51d6ab6..5c7ecca 100644 --- a/lib/src/line_overlap.dart +++ b/lib/src/line_overlap.dart @@ -1,9 +1,12 @@ import 'package:rbush/rbush.dart'; +import 'package:turf/boolean.dart'; import 'package:turf/line_segment.dart'; import 'package:turf/meta.dart'; import 'package:turf/src/booleans/boolean_helper.dart'; -import 'package:turf/turf.dart'; +import '../helpers.dart'; +import 'destination.dart'; import 'invariant.dart'; +import 'nearest_point_on_line.dart'; /// Takes any [LineString], [MultiLineString], [Polygon] or [MultiPolygon] and /// returns the overlapping lines between both features. diff --git a/lib/src/line_segment.dart b/lib/src/line_segment.dart index 02df7ad..444a4e8 100644 --- a/lib/src/line_segment.dart +++ b/lib/src/line_segment.dart @@ -1,7 +1,6 @@ -import 'package:turf/src/meta/coord.dart'; -import 'package:turf/src/meta/flatten.dart'; - -import 'geojson.dart'; +import 'meta/coord.dart'; +import 'meta/flatten.dart'; +import 'package:geotypes/geotypes.dart'; /// Creates a [FeatureCollection] of 2-vertex [LineString] segments from a /// [LineString] or [MultiLineString] or [Polygon] and [MultiPolygon] diff --git a/lib/src/line_slice.dart b/lib/src/line_slice.dart index cbd53b2..d5fdf94 100644 --- a/lib/src/line_slice.dart +++ b/lib/src/line_slice.dart @@ -1,6 +1,7 @@ -import 'package:turf/helpers.dart'; -import 'package:turf/nearest_point_on_line.dart'; -import 'package:turf/src/invariant.dart'; +import 'package:geotypes/geotypes.dart'; + +import 'nearest_point_on_line.dart'; +import 'invariant.dart'; /// Takes a [line], at a start point [startPt], and a stop point [stopPt] /// and returns a subsection of the line in-between those points. diff --git a/lib/src/midpoint.dart b/lib/src/midpoint.dart index 7176457..e571348 100644 --- a/lib/src/midpoint.dart +++ b/lib/src/midpoint.dart @@ -1,7 +1,7 @@ import 'bearing.dart'; import 'destination.dart'; import 'distance.dart'; -import 'geojson.dart'; +import 'package:geotypes/geotypes.dart'; Position midpointRaw(Position point1, Position point2) { var dist = distanceRaw(point1, point2); @@ -12,7 +12,8 @@ Position midpointRaw(Position point1, Position point2) { } /// Takes two [Point]s and returns a point midway between them. -/// The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account. +/// The midpoint is calculated geodesically, meaning the curvature of the +/// earth is taken into account. /// For example: /// /// ``` diff --git a/lib/src/nearest_point.dart b/lib/src/nearest_point.dart index afd1b94..60253d1 100644 --- a/lib/src/nearest_point.dart +++ b/lib/src/nearest_point.dart @@ -1,5 +1,5 @@ import 'distance.dart'; -import 'geojson.dart'; +import 'package:geotypes/geotypes.dart'; /// Takes a reference [Point] and a FeatureCollection of Features /// with Point geometries and returns the diff --git a/lib/src/nearest_point_on_line.dart b/lib/src/nearest_point_on_line.dart index 1e037be..fe5c90f 100644 --- a/lib/src/nearest_point_on_line.dart +++ b/lib/src/nearest_point_on_line.dart @@ -1,9 +1,9 @@ import 'dart:math'; +import 'package:geotypes/geotypes.dart'; import 'bearing.dart'; import 'destination.dart'; import 'distance.dart'; -import 'geojson.dart'; import 'helpers.dart'; import 'intersection.dart'; diff --git a/lib/src/rhumb_destination.dart b/lib/src/rhumb_destination.dart index b901632..c94c1a2 100644 --- a/lib/src/rhumb_destination.dart +++ b/lib/src/rhumb_destination.dart @@ -4,8 +4,8 @@ import 'package:turf/helpers.dart'; import 'package:turf/src/invariant.dart'; /// -/// Returns the destination [Point] having travelled the given distance along a Rhumb line from the -/// origin Point with the (varant) given bearing. +/// Returns the destination [Point] having traveled the given distance along a Rhumb line from the +/// origin Point with the (variant) given bearing. /// /// example: /// ```dart @@ -62,7 +62,7 @@ Position calculateRhumbDestination(Position origin, num distance, num bearing, final dPhi = delta * math.cos(theta); var phi2 = phi1 + dPhi; - // check for some daft bugger going past the pole, normalise latitude if so + // check for some daft bugger going past the pole, normalize latitude if so if (phi2.abs() > math.pi / 2) { phi2 = phi2 > 0 ? math.pi - phi2 : -math.pi - phi2; } @@ -75,7 +75,7 @@ Position calculateRhumbDestination(Position origin, num distance, num bearing, final dLambda = (delta * math.sin(theta)) / q; final lambda2 = lambda1 + dLambda; - // normalise to −180..+180° + // normalize to −180..+180° final lng = (((lambda2 * 180) / math.pi + 540) % 360) - 180; final lat = (phi2 * 180) / math.pi; diff --git a/lib/turf.dart b/lib/turf.dart index d867b21..b36424c 100644 --- a/lib/turf.dart +++ b/lib/turf.dart @@ -16,7 +16,6 @@ export 'distance.dart'; export 'explode.dart'; export 'extensions.dart'; export 'helpers.dart'; -export 'intersection.dart'; export 'invariant.dart'; export 'length.dart'; export 'line_intersect.dart'; diff --git a/test/booleans/overlap_test.dart b/test/booleans/overlap_test.dart index 0a309e1..a2bbb49 100644 --- a/test/booleans/overlap_test.dart +++ b/test/booleans/overlap_test.dart @@ -1,7 +1,7 @@ +import 'package:geotypes/geotypes.dart'; import 'package:test/test.dart'; import 'package:turf/src/booleans/boolean_helper.dart'; import 'package:turf/src/booleans/boolean_overlap.dart'; -import 'package:turf/src/geojson.dart'; import '../context/helper.dart'; import '../context/load_test_cases.dart'; diff --git a/test/components/center_test.dart b/test/components/center_test.dart index c642d22..1f8cd79 100644 --- a/test/components/center_test.dart +++ b/test/components/center_test.dart @@ -2,9 +2,10 @@ import 'dart:convert'; import 'dart:io'; import 'package:test/test.dart'; +import 'package:turf/bbox.dart'; +import 'package:turf/center.dart'; import 'package:turf/meta.dart'; import 'package:turf/src/bbox_polygon.dart'; -import 'package:turf/turf.dart'; void main() { group( diff --git a/test/components/centroid_test.dart b/test/components/centroid_test.dart index 30ceb0b..6449019 100644 --- a/test/components/centroid_test.dart +++ b/test/components/centroid_test.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:test/test.dart'; -import 'package:turf/src/meta/feature.dart'; import 'package:turf/turf.dart'; import 'package:turf_equality/turf_equality.dart'; diff --git a/test/components/explode_test.dart b/test/components/explode_test.dart index d5c5598..443d84e 100644 --- a/test/components/explode_test.dart +++ b/test/components/explode_test.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import 'dart:io'; +import 'package:geotypes/geotypes.dart'; import 'package:test/test.dart'; import 'package:turf/src/explode.dart'; -import 'package:turf/turf.dart'; void main() { group( diff --git a/test/components/polyline.dart b/test/components/polyline.dart index 1083e68..3cf2906 100644 --- a/test/components/polyline.dart +++ b/test/components/polyline.dart @@ -1,5 +1,4 @@ import 'package:test/test.dart'; -import 'package:turf/helpers.dart'; import 'package:turf/polyline.dart'; void main() { diff --git a/test/components/transform_rotate_test.dart b/test/components/transform_rotate_test.dart index 0320294..12d7e05 100644 --- a/test/components/transform_rotate_test.dart +++ b/test/components/transform_rotate_test.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:test/test.dart'; -import 'package:turf/helpers.dart'; import 'package:turf/src/centroid.dart'; import 'package:turf/src/invariant.dart'; import 'package:turf/src/transform_rotate.dart'; diff --git a/test/components/truncate_test.dart b/test/components/truncate_test.dart index aff618d..b39bf58 100644 --- a/test/components/truncate_test.dart +++ b/test/components/truncate_test.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:test/test.dart'; -import 'package:turf/helpers.dart'; import 'package:turf/truncate.dart'; import 'package:turf_equality/turf_equality.dart'; diff --git a/test/context/matcher.dart b/test/context/matcher.dart index 011b03f..aa35005 100644 --- a/test/context/matcher.dart +++ b/test/context/matcher.dart @@ -1,6 +1,5 @@ import 'package:test/test.dart'; import 'package:turf/helpers.dart'; -import 'package:turf/src/geojson.dart'; import 'package:turf_equality/turf_equality.dart'; Matcher equals(T? expected) => _Equals(expected);