1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.coor.conversion;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.trc;
|
---|
5 |
|
---|
6 | import java.text.DecimalFormat;
|
---|
7 | import java.text.NumberFormat;
|
---|
8 | import java.util.Locale;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Abstract base class for {@link ICoordinateFormat} implementations.
|
---|
12 | * @since 12735
|
---|
13 | */
|
---|
14 | public abstract class AbstractCoordinateFormat implements ICoordinateFormat {
|
---|
15 |
|
---|
16 | protected final String id;
|
---|
17 | protected final String displayName;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * The normal number format for server precision coordinates
|
---|
21 | */
|
---|
22 | protected static final DecimalFormat cDdFormatter;
|
---|
23 | static {
|
---|
24 | // Don't use the localized decimal separator. This way we can present
|
---|
25 | // a comma separated list of coordinates.
|
---|
26 | cDdFormatter = (DecimalFormat) NumberFormat.getInstance(Locale.UK);
|
---|
27 | cDdFormatter.applyPattern("###0.0######");
|
---|
28 | }
|
---|
29 |
|
---|
30 | /** Character denoting South, as string */
|
---|
31 | protected static final String SOUTH = trc("compass", "S");
|
---|
32 | /** Character denoting North, as string */
|
---|
33 | protected static final String NORTH = trc("compass", "N");
|
---|
34 | /** Character denoting West, as string */
|
---|
35 | protected static final String WEST = trc("compass", "W");
|
---|
36 | /** Character denoting East, as string */
|
---|
37 | protected static final String EAST = trc("compass", "E");
|
---|
38 |
|
---|
39 | protected AbstractCoordinateFormat(String id, String displayName) {
|
---|
40 | this.id = id;
|
---|
41 | this.displayName = displayName;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public String getId() {
|
---|
46 | return id;
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public String getDisplayName() {
|
---|
51 | return displayName;
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Override
|
---|
55 | public String toString() {
|
---|
56 | return getDisplayName();
|
---|
57 | }
|
---|
58 | }
|
---|