1 | package org.openstreetmap.josm.data;
|
---|
2 |
|
---|
3 | import org.junit.Test;
|
---|
4 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
5 |
|
---|
6 | import static org.junit.Assert.assertTrue;
|
---|
7 |
|
---|
8 | public class BoundsTest {
|
---|
9 |
|
---|
10 | @Test
|
---|
11 | public void crossingTests() {
|
---|
12 | Bounds b1 = new Bounds(0, 170, 50, -170);
|
---|
13 | assertTrue(b1.crosses180thMeridian());
|
---|
14 | assertTrue(!b1.contains(new LatLon(-10, -180)));
|
---|
15 | assertTrue(b1.contains(new LatLon(0, -180)));
|
---|
16 | assertTrue(b1.contains(new LatLon(50, -180)));
|
---|
17 | assertTrue(!b1.contains(new LatLon(60, -180)));
|
---|
18 | assertTrue(!b1.contains(new LatLon(-10, 180)));
|
---|
19 | assertTrue(b1.contains(new LatLon(0, 180)));
|
---|
20 | assertTrue(b1.contains(new LatLon(50, 180)));
|
---|
21 | assertTrue(!b1.contains(new LatLon(60, 180)));
|
---|
22 |
|
---|
23 | Bounds b2 = new Bounds(60, 170, 90, -170);
|
---|
24 | assertTrue(!b1.intersects(b2));
|
---|
25 | assertTrue(!b2.intersects(b1));
|
---|
26 |
|
---|
27 | Bounds b3 = new Bounds(25, 170, 90, -170);
|
---|
28 | assertTrue(b1.intersects(b3));
|
---|
29 | assertTrue(b3.intersects(b1));
|
---|
30 | assertTrue(b2.intersects(b3));
|
---|
31 | assertTrue(b3.intersects(b2));
|
---|
32 |
|
---|
33 | b3.extend(b1);
|
---|
34 | assertTrue(b3.equals(new Bounds(0, 170, 90, -170)));
|
---|
35 | assertTrue(b1.intersects(b3));
|
---|
36 | assertTrue(b3.intersects(b1));
|
---|
37 | assertTrue(b2.intersects(b3));
|
---|
38 | assertTrue(b3.intersects(b2));
|
---|
39 |
|
---|
40 | b3.extend(new LatLon(0, 0));
|
---|
41 | assertTrue(b3.equals(new Bounds(0, 0, 90, -170)));
|
---|
42 | }
|
---|
43 | }
|
---|