Skip to content

Commit 64ab536

Browse files
committed
Renamed getMapcodeMedium/HighPrecision to getMapcodePrecision1/2
1 parent f70e243 commit 64ab536

File tree

12 files changed

+150
-89
lines changed

12 files changed

+150
-89
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
44

55
----
66

7-
This Java project contains a library to encode latitude/longitude pairs to Mapcodes
8-
and to decode Mapcodes back to latitude/longitude pairs.
7+
This Java project contains a library to encode latitude/longitude pairs to mapcodes
8+
and to decode mapcodes back to latitude/longitude pairs.
99

1010
**Online documentation can be found at: http://mapcode-foundation.github.io/mapcode-java/**
1111

@@ -28,5 +28,5 @@ See the License for the specific language governing permissions and
2828
limitations under the License.
2929

3030
Original C library created by Pieter Geelen. Work on Java version
31-
of the Mapcode library by Rijn Buve and Matthew Lowden.
31+
of the mapcode library by Rijn Buve and Matthew Lowden.
3232

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<name>Mapcode Java Library</name>
1414
<description>
15-
This library offers Java support for Mapcode.
15+
This library offers Java support for mapcodes.
1616
For more info: http://www.mapcode.com
1717
</description>
1818

src/main/java/com/mapcode/Mapcode.java

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,37 @@
2020
import java.util.Arrays;
2121

2222
/**
23-
* This class defines a single Mapcode encoding result, including the Mapcode itself and the
23+
* This class defines a single mapcode encoding result, including the mapcode itself and the
2424
* territory definition.
2525
*/
2626
public final class Mapcode {
2727
@Nonnull private final String mapcode;
28-
@Nonnull private final String mapcodeHighPrecision;
29-
@Nonnull private final String mapcodeMediumPrecision;
28+
@Nonnull private final String mapcodePrecision1;
29+
@Nonnull private final String mapcodePrecision2;
3030
@Nonnull private final Territory territory;
3131

3232
public Mapcode(
3333
@Nonnull final String mapcode,
3434
@Nonnull final Territory territory) {
35-
this.mapcodeHighPrecision = mapcode;
35+
this.mapcodePrecision2 = mapcode;
3636
if (mapcode.contains("-")) {
3737
this.mapcode = mapcode.substring(0, mapcode.length() - 3);
38-
this.mapcodeMediumPrecision = mapcode.substring(0, mapcode.length() - 1);
38+
this.mapcodePrecision1 = mapcode.substring(0, mapcode.length() - 1);
3939
}
4040
else {
4141
this.mapcode = mapcode;
42-
this.mapcodeMediumPrecision = mapcode;
42+
this.mapcodePrecision1 = mapcode;
4343
}
4444
this.territory = territory;
4545
}
4646

4747
/**
48-
* Get the Mapcode string (without territory information).
48+
* Get the Mapcode string (without territory information) with standard precision.
49+
* The returned mapcode does not include the '-' separator and additional digits.
50+
*
51+
* The returned precision is approximately 5 meters. The precision is defined as the maximum distance to the
52+
* (latitude, longitude) pair that encoded to this mapcode, which means the mapcode defines an area of
53+
* approximately 10 x 10 meters (100 m2).
4954
*
5055
* @return Mapcode string.
5156
*/
@@ -55,25 +60,63 @@ public String getMapcode() {
5560
}
5661

5762
/**
58-
* Get the high-precision Mapcode string (without territory information).
59-
* If a high precision code is not available, the regular Mapcode is returned.
63+
* Alias for {@link #getMapcode}.
6064
*
61-
* @return High Precision Mapcode string.
65+
* @return Mapcode string.
6266
*/
6367
@Nonnull
64-
public String getMapcodeHighPrecision() {
65-
return mapcodeHighPrecision;
68+
public String getMapcodePrecision0() {
69+
return mapcode;
6670
}
6771

6872
/**
69-
* Get the medium-precision Mapcode string (without territory information).
70-
* If a medium precision code is not available, the regular Mapcode is returned.
73+
* Get the medium-precision mapcode string (without territory information).
74+
* The returned mapcode includes the '-' separator and 1 additional digit, if available.
75+
* If a medium precision code is not available, the regular mapcode is returned.
76+
*
77+
* The returned precision is approximately 1 meter. The precision is defined as the maximum distance to the
78+
* (latitude, longitude) pair that encoded to this mapcode, which means the mapcode defines an area of
79+
* approximately 2 x 2 meters (4 m2).
7180
*
72-
* @return Medium Precision Mapcode string.
81+
* @return Medium precision mapcode string.
82+
*/
83+
@Nonnull
84+
public String getMapcodePrecision1() {
85+
return mapcodePrecision1;
86+
}
87+
88+
/**
89+
* Deprecated alias for {@link #getMapcodePrecision1}.
7390
*/
91+
@Deprecated
7492
@Nonnull
7593
public String getMapcodeMediumPrecision() {
76-
return mapcodeMediumPrecision;
94+
return mapcodePrecision1;
95+
}
96+
97+
/**
98+
* Get the high-precision mapcode string (without territory information).
99+
* The returned mapcode includes the '-' separator and 2 additional digit2, if available.
100+
* If a high precision code is not available, the regular mapcode is returned.
101+
*
102+
* The returned precision is approximately 16 centimeters. The precision is defined as the maximum distance to the
103+
* (latitude, longitude) pair that encoded to this mapcode, which means the mapcode defines an area of
104+
* approximately 32 x 32 centimeters (0.1 m2).
105+
*
106+
* @return High precision mapcode string.
107+
*/
108+
@Nonnull
109+
public String getMapcodePrecision2() {
110+
return mapcodePrecision2;
111+
}
112+
113+
/**
114+
* Deprecated alias for {@see #getMapcodePrecision2}.
115+
*/
116+
@Deprecated
117+
@Nonnull
118+
public String getMapcodeHighPrecision() {
119+
return mapcodePrecision2;
77120
}
78121

79122
/**
@@ -92,36 +135,36 @@ public int hashCode() {
92135
}
93136

94137
/**
95-
* Return the local Mapcode string, potentially ambiguous.
138+
* Return the local mapcode string, potentially ambiguous.
96139
*
97140
* Example:
98141
* 49.4V
99142
*
100-
* @return Local Mapcode.
143+
* @return Local mapcode.
101144
*/
102145
@Nonnull
103146
public String asLocal() {
104147
return mapcode;
105148
}
106149

107150
/**
108-
* Return the full international Mapcode, including the full name of the territory and the Mapcode itself.
151+
* Return the full international mapcode, including the full name of the territory and the Mapcode itself.
109152
* The format of the code is:
110153
* full-territory-name mapcode
111154
*
112155
* Example:
113156
* Netherlands 49.4V (regular code)
114157
* Netherlands 49.4V-K2 (high precision code)
115158
*
116-
* @return Full international Mapcode.
159+
* @return Full international mapcode.
117160
*/
118161
@Nonnull
119162
public String asInternationalFullName() {
120163
return territory.getFullName() + ' ' + mapcode;
121164
}
122165

123166
/**
124-
* Return the international Mapcode as a shorter version using the ISO territory codes where possible.
167+
* Return the international mapcode as a shorter version using the ISO territory codes where possible.
125168
* International codes use a territory code "AAA".
126169
* The format of the code is:
127170
* short-territory-name mapcode
@@ -130,7 +173,7 @@ public String asInternationalFullName() {
130173
* NLD 49.4V (regular code)
131174
* NLD 49.4V-K2 (high-precision code)
132175
*
133-
* @return Short-hand international Mapcode.
176+
* @return Short-hand international mapcode.
134177
*/
135178
@Nonnull
136179
public String asInternationalISO() {
@@ -155,4 +198,3 @@ public boolean equals(final Object obj) {
155198
return mapcode.equals(that.mapcode) && (this.territory.equals(that.territory));
156199
}
157200
}
158-

0 commit comments

Comments
 (0)