1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs;
|
---|
3 |
|
---|
4 | import static org.hamcrest.CoreMatchers.is;
|
---|
5 | import static org.junit.Assert.assertThat;
|
---|
6 |
|
---|
7 | import org.junit.Test;
|
---|
8 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
9 |
|
---|
10 | public class LatLonDialogTest {
|
---|
11 | @Test
|
---|
12 | public void test1() throws Exception {
|
---|
13 | assertThat(LatLonDialog.parseLatLon("49.29918° 19.24788°"), is(new LatLon(49.29918, 19.24788)));
|
---|
14 | }
|
---|
15 |
|
---|
16 | @Test
|
---|
17 | public void test2() throws Exception {
|
---|
18 | assertThat(LatLonDialog.parseLatLon("N 49.29918 E 19.24788°"), is(new LatLon(49.29918, 19.24788)));
|
---|
19 | }
|
---|
20 |
|
---|
21 | @Test
|
---|
22 | public void test3() throws Exception {
|
---|
23 | assertThat(LatLonDialog.parseLatLon("49.29918° 19.24788°"), is(new LatLon(49.29918, 19.24788)));
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Test
|
---|
27 | public void test4() throws Exception {
|
---|
28 | assertThat(LatLonDialog.parseLatLon("N 49.29918 E 19.24788"), is(new LatLon(49.29918, 19.24788)));
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Test
|
---|
32 | public void test5() throws Exception {
|
---|
33 | assertThat(LatLonDialog.parseLatLon("W 49°29.918' S 19°24.788'"), is(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60)));
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Test
|
---|
37 | public void test6() throws Exception {
|
---|
38 | assertThat(LatLonDialog.parseLatLon("N 49°29'04\" E 19°24'43\""), is(new LatLon(49 + 29. / 60 + 04. / 3600, 19 + 24. / 60 + 43. / 3600)));
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Test
|
---|
42 | public void test7() throws Exception {
|
---|
43 | assertThat(LatLonDialog.parseLatLon("49.29918 N, 19.24788 E"), is(new LatLon(49.29918, 19.24788)));
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Test
|
---|
47 | public void test8() throws Exception {
|
---|
48 | assertThat(LatLonDialog.parseLatLon("49°29'21\" N 19°24'38\" E"), is(new LatLon(49 + 29. / 60 + 21. / 3600, 19 + 24. / 60 + 38. / 3600)));
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Test
|
---|
52 | public void test9() throws Exception {
|
---|
53 | assertThat(LatLonDialog.parseLatLon("49 29 51, 19 24 18"), is(new LatLon(49 + 29. / 60 + 51. / 3600, 19 + 24. / 60 + 18. / 3600)));
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Test
|
---|
57 | public void test10() throws Exception {
|
---|
58 | assertThat(LatLonDialog.parseLatLon("49 29, 19 24"), is(new LatLon(49 + 29. / 60, 19 + 24. / 60)));
|
---|
59 | }
|
---|
60 |
|
---|
61 | @Test
|
---|
62 | public void test11() throws Exception {
|
---|
63 | assertThat(LatLonDialog.parseLatLon("E 49 29, N 19 24"), is(new LatLon(19 + 24. / 60, 49 + 29. / 60)));
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Test
|
---|
67 | public void test12() throws Exception {
|
---|
68 | assertThat(LatLonDialog.parseLatLon("49° 29; 19° 24"), is(new LatLon(49 + 29. / 60, 19 + 24. / 60)));
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Test
|
---|
72 | public void test13() throws Exception {
|
---|
73 | assertThat(LatLonDialog.parseLatLon("49° 29; 19° 24"), is(new LatLon(49 + 29. / 60, 19 + 24. / 60)));
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Test
|
---|
77 | public void test14() throws Exception {
|
---|
78 | assertThat(LatLonDialog.parseLatLon("N 49° 29, W 19° 24"), is(new LatLon(49 + 29. / 60, -19 - 24. / 60)));
|
---|
79 | }
|
---|
80 |
|
---|
81 | @Test
|
---|
82 | public void test15() throws Exception {
|
---|
83 | assertThat(LatLonDialog.parseLatLon("49° 29.5 S, 19° 24.6 E"), is(new LatLon(-49 - 29.5 / 60, 19 + 24.6 / 60)));
|
---|
84 | }
|
---|
85 |
|
---|
86 | @Test
|
---|
87 | public void test16() throws Exception {
|
---|
88 | assertThat(LatLonDialog.parseLatLon("N 49 29.918 E 19 15.88"), is(new LatLon(49 + 29.918 / 60, 19 + 15.88 / 60)));
|
---|
89 | }
|
---|
90 |
|
---|
91 | @Test
|
---|
92 | public void test17() throws Exception {
|
---|
93 | assertThat(LatLonDialog.parseLatLon("49 29.4 19 24.5"), is(new LatLon(49 + 29.4 / 60, 19 + 24.5 / 60)));
|
---|
94 | }
|
---|
95 |
|
---|
96 | @Test
|
---|
97 | public void test18() throws Exception {
|
---|
98 | assertThat(LatLonDialog.parseLatLon("-49 29.4 N -19 24.5 W"), is(new LatLon(-49 - 29.4 / 60, 19 + 24.5 / 60)));
|
---|
99 | }
|
---|
100 | }
|
---|