From f4bbca21417114c51e0d5722e7a09905db23bd01 Mon Sep 17 00:00:00 2001 From: Jonas Siedentop Date: Wed, 28 Feb 2024 11:42:59 +0100 Subject: [PATCH] fixed bug on LineString --- lib/src/turf_equality_base.dart | 2 ++ test/geojson_equality_test.dart | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/src/turf_equality_base.dart b/lib/src/turf_equality_base.dart index 4187829..fb6535a 100644 --- a/lib/src/turf_equality_base.dart +++ b/lib/src/turf_equality_base.dart @@ -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; diff --git a/test/geojson_equality_test.dart b/test/geojson_equality_test.dart index 96363ae..e495212 100644 --- a/test/geojson_equality_test.dart +++ b/test/geojson_equality_test.dart @@ -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([ @@ -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([ @@ -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],