diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-19 22:09:54 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-19 22:09:54 -0800 |
commit | 6d9708e7e8688727fbb6e1db04cf667854addba7 (patch) | |
tree | 4c3e90fd2e8f51d3233fd8813d3400a86d5ccd87 /src/test/java/org/traccar | |
parent | 6ea7e5229f8a9269cbcee639a0bd6ede3c7ceb88 (diff) | |
download | traccar-server-6d9708e7e8688727fbb6e1db04cf667854addba7.tar.gz traccar-server-6d9708e7e8688727fbb6e1db04cf667854addba7.tar.bz2 traccar-server-6d9708e7e8688727fbb6e1db04cf667854addba7.zip |
Fix polygon area calculation
Diffstat (limited to 'src/test/java/org/traccar')
-rw-r--r-- | src/test/java/org/traccar/geofence/GeofencePolygonTest.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/test/java/org/traccar/geofence/GeofencePolygonTest.java b/src/test/java/org/traccar/geofence/GeofencePolygonTest.java index 94b73af3a..cc9c46c94 100644 --- a/src/test/java/org/traccar/geofence/GeofencePolygonTest.java +++ b/src/test/java/org/traccar/geofence/GeofencePolygonTest.java @@ -5,11 +5,18 @@ import java.text.ParseException; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class GeofencePolygonTest { @Test + public void testCalculateArea() throws ParseException { + String test = "POLYGON((-23.559204099194772 148.8653145299711, -23.6000443437826 148.85956016213583, -23.600411843430095 148.89462111436828, -23.5626384786532 148.90278297873897, -23.5574863232753 148.88137329347367, -23.559204099194772 148.8653145299711))"; + assertEquals(17, new GeofencePolygon(test).calculateArea(), 1); + } + + @Test public void testPolygonWkt() throws ParseException { String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); @@ -23,7 +30,7 @@ public class GeofencePolygonTest { GeofenceGeometry geofenceGeometry = new GeofencePolygon(); geofenceGeometry.fromWkt(test); assertTrue(geofenceGeometry.containsPoint(55.75476, 37.61915)); - assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); + assertFalse(geofenceGeometry.containsPoint(55.75545, 37.61921)); } @@ -34,7 +41,7 @@ public class GeofencePolygonTest { geofenceGeometry.fromWkt(test); assertTrue(geofenceGeometry.containsPoint(66.9015, -180.0096)); assertTrue(geofenceGeometry.containsPoint(66.9015, 179.991)); - assertTrue(!geofenceGeometry.containsPoint(66.8368, -179.8792)); + assertFalse(geofenceGeometry.containsPoint(66.8368, -179.8792)); } @@ -45,7 +52,7 @@ public class GeofencePolygonTest { geofenceGeometry.fromWkt(test); assertTrue(geofenceGeometry.containsPoint(51.0466, -0.0165)); assertTrue(geofenceGeometry.containsPoint(51.0466, 0.018)); - assertTrue(!geofenceGeometry.containsPoint(50.9477, 0.5836)); + assertFalse(geofenceGeometry.containsPoint(50.9477, 0.5836)); } |