source: josm/trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java@ 11259

Last change on this file since 11259 was 11259, checked in by Don-vip, 7 years ago

see #10387 - see #12914 - add debug info for failing unit test, remove operator=RFF check as the tag does not exist anymore

  • Property svn:eol-style set to native
File size: 5.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.fail;
5
6import org.junit.Rule;
7import org.junit.Test;
8import org.openstreetmap.josm.data.coor.LatLon;
9import org.openstreetmap.josm.testutils.JOSMTestRules;
10
11/**
12 * Unit tests of {@link RightAndLefthandTraffic} class.
13 */
14public class RightAndLefthandTrafficTest {
15 /**
16 * Test rules.
17 */
18 @Rule
19 public JOSMTestRules rules = new JOSMTestRules().platform().projection().commands();
20
21 /**
22 * Test of {@link RightAndLefthandTraffic#isRightHandTraffic} method.
23 */
24 @Test
25 public void testIsRightHandTraffic() {
26 check(true, "Paris", 48.8567, 2.3508);
27 check(true, "Berlin", 52.5167, 13.383);
28 check(true, "New York", 40.7127, -74.0059);
29 check(true, "Papeete", -17.5419, -149.5617);
30 check(true, "Guantanamo", 19.912, -75.209);
31 check(true, "Guadeloupe", 16.243, -61.533);
32 check(true, "Martinique", 14.604, -61.069);
33 check(true, "Madagascar", -20.119, 46.316);
34 check(true, "Shangai", 31.196, 121.36);
35 check(true, "Gibraltar", 36.141244, -5.347369);
36 check(true, "British Indian Ocean Territory", -7.3, 72.4);
37
38 check(false, "London", 51.507222, -0.1275);
39 check(false, "Valetta (Malta)", 35.897778, 14.5125);
40 check(false, "Jersey", 49.19, -2.11);
41 check(false, "Isle of Man", 54.25, -4.5);
42 check(false, "Dublin (Ireland)", 53.347778, -6.259722);
43 check(false, "Guernsey", 49.45, -2.6);
44 check(false, "Nicosia (Cyprus)", 35.166667, 33.366667);
45 check(false, "Georgetown (Guyana)", 6.8, -58.166667);
46 check(false, "Paramaribo (Suriname)", 5.866667, -55.166667);
47 check(false, "Anguilla", 18.22723, -63.04899);
48 check(false, "Antigua and Barbuda", 17.05, -61.8);
49 check(false, "Bahamas", 24.25, -76);
50 check(false, "Barbados", 13.166667, -59.55);
51 check(false, "British Virgin Islands", 18.5, -64.5);
52 check(false, "Cayman Islands", 19.5, -80.5);
53 check(false, "Dominica", 15.416667, -61.333333);
54 check(false, "Grenada", 12.116667, -61.666667);
55 check(false, "Jamaica", 18, -77);
56 check(false, "Montserrat", 16.75, -62.2);
57 check(false, "Saint Kitts and Nevis", 17.333333, -62.75);
58 check(false, "Saint Lucia", 13.883333, -60.966667);
59 check(false, "Saint Vincent and the Grenadines", 13.25, -61.2);
60 check(false, "Trinidad and Tobago", 11.249285, -60.652557);
61 check(false, "Turks and Caicos Islands", 21.75, -71.583333);
62 check(false, "United States Virgin Islands", 18.35, -64.933333);
63 check(false, "Bermuda", 32.333333, -64.75);
64 check(false, "Falkland Islands", -51.683333, -59.166667);
65 check(false, "Saint Helena, Ascension and Tristan da Cunha", -15.933, -5.717);
66 check(false, "South Georgia and the South Sandwich Islands", -54.25, -36.75);
67 check(false, "Maldives", 3.2, 73.22);
68 check(false, "Mauritius", -20.2, 57.5);
69 check(false, "Seychelles", -4.583333, 55.666667);
70 check(false, "Bangladesh", 23.8, 90.3);
71 check(false, "Bhutan", 27.417, 90.435);
72 check(false, "Brunei", 4.5, 114.666667);
73 check(false, "East Timor", -8.833333, 125.916667);
74 check(false, "Hong Kong", 22.3, 114.2);
75 check(false, "Indonesia", -5, 120);
76 check(false, "India", 21, 78);
77 check(false, "Japan", 35, 136);
78 check(false, "Macau", 22.166667, 113.55);
79 check(false, "Malaysia", 2.5, 112.5);
80 check(false, "Nepal", 28.166667, 84.25);
81 check(false, "Pakistan", 30, 70);
82 check(false, "Singapore", 1.3, 103.8);
83 check(false, "Sri Lanka", 7, 81);
84 check(false, "Thailand", 15.4, 101.3);
85 check(false, "Botswana", -24.658333, 25.908333);
86 check(false, "Kenya", 1, 38);
87 check(false, "Lesotho", -29.6, 28.3);
88 check(false, "Malawi", -13.5, 34);
89 check(false, "Mauritius", -20.2, 57.5);
90 check(false, "Mozambique", -18.25, 35);
91 check(false, "Namibia", -22, 17);
92 check(false, "South Africa", -30, 25);
93 check(false, "Swaziland", -26.5, 31.5);
94 check(false, "Tanzania", -6.307, 34.854);
95 check(false, "Uganda", 1, 32);
96 check(false, "Zambia", -15, 30);
97 check(false, "Zimbabwe", -20, 30);
98 check(false, "Australia", -27, 133);
99 check(false, "Christmas Island", -10.483333, 105.633333);
100 check(false, "Cocos (Keeling) Islands", -12.116667, 96.9);
101 check(false, "Cook Islands", -21.233333, -159.766667);
102 check(false, "Fiji", -18, 179);
103 check(false, "Kiribati", 1.416667, 173);
104 check(false, "Nauru", -0.533333, 166.933333);
105 check(false, "New Zealand", -42, 174);
106 check(false, "Niue", -19.05, -169.916667);
107 check(false, "Norfolk Island", -29.033333, 167.95);
108 check(false, "Papua New Guinea", -6, 147);
109 check(false, "Pitcairn Islands", -25.066667, -130.1);
110 check(false, "Solomon Islands", -8, 159);
111 check(false, "Samoa", -13.583333, -172.333333);
112 check(false, "Tokelau", -9.166667, -171.833333);
113 check(false, "Tonga", -20, -175);
114 check(false, "Tuvalu", -8, 178);
115 }
116
117 private static void check(boolean expected, String name, double lat, double lon) {
118 boolean actual = RightAndLefthandTraffic.isRightHandTraffic(new LatLon(lat, lon));
119 if (actual != expected) {
120 fail(name + " -> " +
121 RightAndLefthandTraffic.leftHandTrafficPolygons.size() + " polygons, cache: " +
122 RightAndLefthandTraffic.rlCache);
123 }
124 }
125}
Note: See TracBrowser for help on using the repository browser.