// Path: grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java
// public static double longitudeDiff(double a, double b) {
//     a = to180(a);
//     b = to180(b);
//     return Math.abs(to180(a - b));
// }
// 
// Path: grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java
// public static double to180(double d) {
//     if (d < 0)
//         return -to180(abs(d));
//     else {
//         if (d > 180) {
//             long n = round(floor((d + 180) / 360.0));
//             return d - n * 360;
//         } else
//             return d;
//     }
// }
// 
// Path: grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java
// public static class LongitudePair {
//     private final double lon1, lon2;
// 
//     public LongitudePair(double lon1, double lon2) {
//         this.lon1 = lon1;
//         this.lon2 = lon2;
//     }
// 
//     public double getLon1() {
//         return lon1;
//     }
// 
//     public double getLon2() {
//         return lon2;
//     }
// 
//     @Override
//     public String toString() {
//         return "LongitudePair [lon1=" + lon1 + ", lon2=" + lon2 + "]";
//     }
// 
// }


import static com.github.davidmoten.grumpy.core.Position.longitudeDiff;
import static com.github.davidmoten.grumpy.core.Position.to180;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import com.github.davidmoten.grumpy.core.Position.LongitudePair;
        Position p = new Position(-10, 110);
        assertTrue(p.isOutside(squareRegion, MIN_DISTANCE_KM));
    }

    /**
     * Test when a position is outside a given region consisting of several
     * joining points. In this test the region is a roughly square region
     * consisting of four segments or eight {@link Position}s. The test position
     * is on the region path.
     */
    @Test
    public void testIsOutside3() {
        Position p = new Position(20.07030897931526, 24.999999999999996);
        assertFalse(p.isOutside(squareRegion, MIN_DISTANCE_KM));
    }

    /**
     * Test when a position is outside a given region consisting of several
     * joining points. In this test the region is a roughly square region
     * consisting of four segments or eight {@link Position}s. The test position
     * is within the region path.
     */
    @Test
    public void testIsOutside4() {
        Position p = new Position(30, 30);
        assertFalse(p.isOutside(squareRegion, MIN_DISTANCE_KM));
    }

    @Test
    public void testTo180() {
// Path: grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java
// public static double longitudeDiff(double a, double b) {
//     a = to180(a);
//     b = to180(b);
//     return Math.abs(to180(a - b));
// }
// 
// Path: grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java
// public static double to180(double d) {
//     if (d < 0)
//         return -to180(abs(d));
//     else {
//         if (d > 180) {
//             long n = round(floor((d + 180) / 360.0));
//             return d - n * 360;
//         } else
//             return d;
//     }
// }
// 
// Path: grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java
// public static class LongitudePair {
//     private final double lon1, lon2;
// 
//     public LongitudePair(double lon1, double lon2) {
//         this.lon1 = lon1;
//         this.lon2 = lon2;
//     }
// 
//     public double getLon1() {
//         return lon1;
//     }
// 
//     public double getLon2() {
//         return lon2;
//     }
// 
//     @Override
//     public String toString() {
//         return "LongitudePair [lon1=" + lon1 + ", lon2=" + lon2 + "]";
//     }
// 
// }


// Path: grumpy-core/src/test/java/com/github/davidmoten/grumpy/core/PositionTest.java
import static com.github.davidmoten.grumpy.core.Position.longitudeDiff;
import static com.github.davidmoten.grumpy.core.Position.to180;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import com.github.davidmoten.grumpy.core.Position.LongitudePair;

        Position p = new Position(-10, 110);
        assertTrue(p.isOutside(squareRegion, MIN_DISTANCE_KM));
    }

    /**
     * Test when a position is outside a given region consisting of several
     * joining points. In this test the region is a roughly square region
     * consisting of four segments or eight {@link Position}s. The test position
     * is on the region path.
     */
    @Test
    public void testIsOutside3() {
        Position p = new Position(20.07030897931526, 24.999999999999996);
        assertFalse(p.isOutside(squareRegion, MIN_DISTANCE_KM));
    }

    /**
     * Test when a position is outside a given region consisting of several
     * joining points. In this test the region is a roughly square region
     * consisting of four segments or eight {@link Position}s. The test position
     * is within the region path.
     */
    @Test
    public void testIsOutside4() {
        Position p = new Position(30, 30);
        assertFalse(p.isOutside(squareRegion, MIN_DISTANCE_KM));
    }

    @Test
    public void testTo180() {
        assertEquals(0, to180(0), PRECISION);