1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.coor.conversion;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
7 |
|
---|
8 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
9 | import org.junit.jupiter.api.Test;
|
---|
10 | import org.openstreetmap.josm.data.coor.ILatLon;
|
---|
11 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
12 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Test for {@link ICoordinateFormat} implementations.
|
---|
16 | */
|
---|
17 | class ICoordinateFormatTest {
|
---|
18 | /**
|
---|
19 | * Setup test.
|
---|
20 | */
|
---|
21 | @RegisterExtension
|
---|
22 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
23 | public JOSMTestRules test = new JOSMTestRules().projection();
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Tests {@link ICoordinateFormat#latToString(org.openstreetmap.josm.data.coor.ILatLon)}
|
---|
27 | * and {@link ICoordinateFormat#lonToString(org.openstreetmap.josm.data.coor.ILatLon)}
|
---|
28 | * and {@link ICoordinateFormat#toString(ILatLon, String)}
|
---|
29 | * for various implementations.
|
---|
30 | */
|
---|
31 | @Test
|
---|
32 | void testFormatting() {
|
---|
33 | LatLon c = new LatLon(47.000000, 19.000000);
|
---|
34 | assertEquals("47.0", DecimalDegreesCoordinateFormat.INSTANCE.latToString(c));
|
---|
35 | assertEquals("19.0", DecimalDegreesCoordinateFormat.INSTANCE.lonToString(c));
|
---|
36 | assertEquals("47.0 19.0", DecimalDegreesCoordinateFormat.INSTANCE.toString(c, " "));
|
---|
37 | assertEquals("47°00'00.0\"N", DMSCoordinateFormat.INSTANCE.latToString(c));
|
---|
38 | assertEquals("19°00'00.0\"E", DMSCoordinateFormat.INSTANCE.lonToString(c));
|
---|
39 | assertEquals("47°00'00.0\"N 19°00'00.0\"E", DMSCoordinateFormat.INSTANCE.toString(c, " "));
|
---|
40 | assertEquals("47°00.000'N", NauticalCoordinateFormat.INSTANCE.latToString(c));
|
---|
41 | assertEquals("19°00.000'E", NauticalCoordinateFormat.INSTANCE.lonToString(c));
|
---|
42 | assertEquals("5942074.0724311", ProjectedCoordinateFormat.INSTANCE.latToString(c));
|
---|
43 | assertEquals("2115070.3250722", ProjectedCoordinateFormat.INSTANCE.lonToString(c));
|
---|
44 | c = new LatLon(-47.000000, -19.000000);
|
---|
45 | assertEquals("47°00'00.0\"S", DMSCoordinateFormat.INSTANCE.latToString(c));
|
---|
46 | assertEquals("19°00'00.0\"W", DMSCoordinateFormat.INSTANCE.lonToString(c));
|
---|
47 | assertEquals("47°00.000'S", NauticalCoordinateFormat.INSTANCE.latToString(c));
|
---|
48 | assertEquals("19°00.000'W", NauticalCoordinateFormat.INSTANCE.lonToString(c));
|
---|
49 | }
|
---|
50 |
|
---|
51 | }
|
---|