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