Skip to content

Commit

Permalink
fixed bug on LineString
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiedentop committed Feb 28, 2024
1 parent 3a0fbf3 commit f4bbca2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/src/turf_equality_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class Equality {
}

bool _compareLineString(LineString line1, LineString line2) {
if (line1.coordinates.length != line2.coordinates.length) return false;

if (!_compareCoords(line1.coordinates.first, line2.coordinates.first)) {
if (!reversedGeometries) {
return false;
Expand Down
11 changes: 3 additions & 8 deletions test/geojson_equality_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ void main() {
expect(result, true);
});

// ToDo: I would expect this to be false, but it could be argued, that
// the line is the same, just the amount of points is different.
test('same line, different amount of points (additional middle point)', () {
final result = eq.compare(
lineString([
Expand All @@ -55,8 +53,8 @@ void main() {
expect(result, false);
});

// ToDo: If the last test case is false, I would expect, that this test
// should also be false. Actually it is true.
// ToDo: This should be resolved as part of data normalization and not
// handled during equality checks.
test('same line, different amount of points (end point duplicated)', () {
final result = eq.compare(
lineString([
Expand All @@ -69,12 +67,9 @@ void main() {
[120, -30],
]),
);
expect(result, true);
expect(result, false);
});

// ToDo: Another test case where the lines have the same shape but not the
// same structure. Here with reversedGeometries, that behaves exactly the
// opposite way as I would expect.
test('same line, different orientation', () {
final line1 = lineString([
[100, -30],
Expand Down

0 comments on commit f4bbca2

Please sign in to comment.