Skip to content

Commit beec124

Browse files
committed
additional edits
1 parent 96b29aa commit beec124

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

java/com/google/openlocationcode/OpenLocationCode.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,29 @@
1919
/**
2020
* Convert locations to and from convenient short codes.
2121
*
22-
* <p>Open Location Codes are short, ~10 character codes that can be used instead of street
22+
* Open Location Codes are short, ~10 character codes that can be used instead of street
2323
* addresses. The codes can be generated and decoded offline, and use a reduced character set that
2424
* minimises the chance of codes including words.
2525
*
26-
* <p>This provides both an object and static methods.
26+
* This provides both object and static methods.
27+
*
28+
* Create an object with:
29+
* OpenLocationCode code = new OpenLocationCode("7JVW52GR+2V");
30+
* OpenLocationCode code = new OpenLocationCode("52GR+2V");
31+
* OpenLocationCode code = new OpenLocationCode(27.175063, 78.042188);
32+
* OpenLocationCode code = new OpenLocationCode(27.175063, 78.042188, 11);
33+
*
34+
* Once you have a code object, you can apply the other methods to it, such as to shorten:
35+
* code.shorten(27.176, 78.05)
36+
*
37+
* Recover the nearest match (if the code was a short code):
38+
* code.recover(27.176, 78.05)
39+
*
40+
* Or decode a code into it's coordinates, returning a CodeArea object.
41+
* code.decode()
42+
*
43+
* @author Jiri Semecky
44+
* @author Doug Rinckes
2745
*/
2846
public final class OpenLocationCode {
2947

@@ -132,6 +150,7 @@ public double getEastLongitude() {
132150
* Creates Open Location Code object for the provided code.
133151
* @param code A valid OLC code. Can be a full code or a shortened code.
134152
* @throws IlegalArgumentException when the passed code is not valid.
153+
* @constructor
135154
*/
136155
public OpenLocationCode(String code) {
137156
if (!isValidCode(code.toUpperCase())) {
@@ -147,6 +166,7 @@ public OpenLocationCode(String code) {
147166
* @param longitude The longitude in decimal degrees.
148167
* @param codeLength The desired number of digits in the code.
149168
* @throws IllegalArgumentException if the code length is not valid.
169+
* @constructor
150170
*/
151171
public OpenLocationCode(double latitude, double longitude, int codeLength)
152172
throws IllegalArgumentException {
@@ -215,18 +235,28 @@ public OpenLocationCode(double latitude, double longitude, int codeLength)
215235
this.code = codeBuilder.toString();
216236
}
217237

218-
/** Creates Open Location Code with code length 10 from the provided latitude, longitude. */
238+
/**
239+
* Creates Open Location Code with the default precision length.
240+
* @param latitude The latitude in decimal degrees.
241+
* @param longitude The longitude in decimal degrees.
242+
* @constructor
243+
*/
219244
public OpenLocationCode(double latitude, double longitude) {
220245
this(latitude, longitude, CODE_PRECISION_NORMAL);
221246
}
222247

248+
/**
249+
* Returns the string representation of the code.
250+
*/
223251
public String getCode() {
224252
return code;
225253
}
226254

227255
/**
228256
* Encodes latitude/longitude into 10 digit Open Location Code. This method is equivalent to
229257
* creating the OpenLocationCode object and getting the code from it.
258+
* @param latitude The latitude in decimal degrees.
259+
* @param longitude The longitude in decimal degrees.
230260
*/
231261
public static String encode(double latitude, double longitude) {
232262
return new OpenLocationCode(latitude, longitude).getCode();
@@ -235,6 +265,8 @@ public static String encode(double latitude, double longitude) {
235265
/**
236266
* Encodes latitude/longitude into Open Location Code of the provided length. This method is
237267
* equivalent to creating the OpenLocationCode object and getting the code from it.
268+
* @param latitude The latitude in decimal degrees.
269+
* @param longitude The longitude in decimal degrees.
238270
*/
239271
public static String encode(double latitude, double longitude, int codeLength) {
240272
return new OpenLocationCode(latitude, longitude, codeLength).getCode();

0 commit comments

Comments
 (0)