aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/geofence/GeofenceCircleTest.java
blob: 820f34e3439de3095d0f2882d19b7a0fa946aeed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.traccar.geofence;

import java.text.ParseException;

import org.junit.Assert;
import org.junit.Test;

public class GeofenceCircleTest {

    @Test
    public void testCircleWKT() {
        String test = "CIRCLE (55.75414 37.6204, 100)";
        GeofenceGeometry geofenceGeometry = new GeofenceCircle();
        try {
        geofenceGeometry.fromWKT(test);
        } catch (ParseException e){
            Assert.assertTrue("ParseExceprion: " + e.getMessage(), true);
        }
        Assert.assertEquals(geofenceGeometry.toWKT(), test);
    }

    @Test
    public void testContainsCircle() {
        String test = "CIRCLE (55.75414 37.6204, 100)";
        GeofenceGeometry geofenceGeometry = new GeofenceCircle();
        try {
        geofenceGeometry.fromWKT(test);
        } catch (ParseException e){
            Assert.assertTrue("ParseExceprion: " + e.getMessage(), true);
        }

        Assert.assertTrue(geofenceGeometry.containsPoint(55.75477, 37.62025));

        Assert.assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921));
    }
}