source: josm/trunk/test/unit/org/openstreetmap/josm/data/BoundsTests.java@ 6455

Last change on this file since 6455 was 4580, checked in by Don-vip, 12 years ago

see #2212 - Allow JOSM to download data crossing the 180th meridian

File size: 1.5 KB
Line 
1package org.openstreetmap.josm.data;
2
3import org.junit.Test;
4import org.openstreetmap.josm.data.coor.LatLon;
5
6import static org.junit.Assert.assertTrue;
7
8public class BoundsTests {
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}
Note: See TracBrowser for help on using the repository browser.