diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-06-18 11:56:59 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-18 11:56:59 +1200 |
commit | b3b0cd9d6f2d26cef2e64ef38e23203f1f3fa51a (patch) | |
tree | 2e8deb61d372095aebb8270f740501c8124ea8c4 /test/org/traccar/geofence/GeofencePolygonTest.java | |
parent | d801cba474cd05bb088348f04e8557ca638cd74f (diff) | |
parent | 82a78ff77a076231a8429f0dd84678d61c31d44a (diff) | |
download | trackermap-server-b3b0cd9d6f2d26cef2e64ef38e23203f1f3fa51a.tar.gz trackermap-server-b3b0cd9d6f2d26cef2e64ef38e23203f1f3fa51a.tar.bz2 trackermap-server-b3b0cd9d6f2d26cef2e64ef38e23203f1f3fa51a.zip |
Merge pull request #2012 from Abyss777/master
Implement Geofences on server side
Diffstat (limited to 'test/org/traccar/geofence/GeofencePolygonTest.java')
-rw-r--r-- | test/org/traccar/geofence/GeofencePolygonTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/org/traccar/geofence/GeofencePolygonTest.java b/test/org/traccar/geofence/GeofencePolygonTest.java new file mode 100644 index 000000000..8711a3696 --- /dev/null +++ b/test/org/traccar/geofence/GeofencePolygonTest.java @@ -0,0 +1,38 @@ +package org.traccar.geofence; + +import java.text.ParseException; + +import org.junit.Assert; +import org.junit.Test; + +public class GeofencePolygonTest { + + @Test + public void testPolygonWKT() { + String test = "POLYGON (55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165)"; + GeofenceGeometry geofenceGeometry = new GeofencePolygon(); + try { + geofenceGeometry.fromWkt(test); + } catch (ParseException e){ + Assert.assertTrue("ParseExceprion: " + e.getMessage(), true); + } + Assert.assertEquals(geofenceGeometry.toWkt(), test); + } + + @Test + public void testContainsPolygon() { + String test = "POLYGON (55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165)"; + GeofenceGeometry geofenceGeometry = new GeofencePolygon(); + try { + geofenceGeometry.fromWkt(test); + } catch (ParseException e){ + Assert.assertTrue("ParseExceprion: " + e.getMessage(), true); + } + + Assert.assertTrue(geofenceGeometry.containsPoint(55.75476, 37.61915)); + + Assert.assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); + + } + +} |