Skip to content

Commit 7678b7a

Browse files
committed
Merge pull request #41 from google/drinckes-api-update
Update API.txt
2 parents 122c7b2 + 3ff03c9 commit 7678b7a

File tree

1 file changed

+22
-49
lines changed

1 file changed

+22
-49
lines changed

API.txt

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,25 @@ isValid:
1818
sequence or not.
1919

2020
To be valid, all characters must be from the Open Location Code character
21-
set with at most one separator. If the separator character is present, it
22-
must be after four characters. If the prefix character is present, it must
23-
be the first character.
21+
set with exactly one separator. There must be an even number of at most
22+
eight characters before the separator. (Zero characters before the
23+
separator is valid.)
2424

2525
isShort:
2626
The isShort method takes a single parameter, a string, and returns a
2727
boolean indicating whether the string is a valid short Open Location Code
2828
or not.
2929

30-
A short Open Location Code is a sequence created by removing the first
31-
four or six characters from a full Open Location Code.
32-
33-
A code must be a possible sub-string of a generated Open Location Code, at
34-
least four and at most seven characters long and not include a separator
35-
character. If the prefix character is present, it must be the first
36-
character.
30+
A short Open Location Code is a sequence created by removing a even number
31+
of characters from a full Open Location Code. The resulting code must still
32+
include the separator character.
3733

3834
isFull:
3935
Determines if a code is a valid full Open Location Code.
4036

4137
Not all possible combinations of Open Location Code characters decode to
4238
valid latitude and longitude values. This checks that a code is valid and
43-
also that the latitude and longitude values are legal. If the prefix
44-
character is present, it must be the first character. If the separator
39+
also that the latitude and longitude values are legal. If the separator
4540
character is present, it must be after four characters.
4641

4742
encode:
@@ -55,43 +50,21 @@ decode:
5550
returns an object with the lower and upper latitude and longitude pairs,
5651
the center latitude and longitude, and the length of the original code.
5752

58-
shortenBy4:
59-
Passed a valid full 10 or 11 character Open Location Code and a latitude
60-
and longitude, this tries to remove the first four characters. This will
61-
only succeed if both the latitude and longitude are less than 0.25
62-
degrees from the code center. (Up to 0.5 degrees difference would work,
63-
the requirement for 0.25 degrees represents a safety margin for cases
64-
where the coordinates have come from a geocoding system and where the
65-
center of large entities, such as cities, is subject to debate.)
66-
67-
If not possible, the original code is returned. If trimming is possible,
68-
the first four characters are removed and the subsequent characters are
69-
returned with the prefix added.
70-
71-
shortenBy6:
72-
Passed a valid full 10 or 11 character Open Location Code and a latitude
73-
and longitude, this tries to remove the first six characters. This will
74-
only succeed if both the latitude and longitude are less than 0.0125
75-
degrees from the code center. (Up to 0.025 degrees difference would
76-
work, the requirement for 0.0125 degrees represents a safety margin for
77-
cases where the coordinates have come from a geocoding system and where
78-
the center of large entities, such as cities, is subject to debate.)
79-
80-
If not possible, the original code is returned. If trimming is possible,
81-
the first six characters are removed and the subsequent characters are
82-
returned with the prefix added.
53+
shorten:
54+
Passed a valid full Open Location Code and a latitude and longitude this
55+
removes as many digits as possible (up to a maximum of eight) such that
56+
the resulting code is the closest matching code to the passed location.
57+
A safety factor may be included.
58+
59+
If the code cannot be shortened, the original full code should be
60+
returned.
61+
62+
Since the only really useful shortenings are removing the first four or
63+
six characters, this method may be replaced with methods such as
64+
shortenBy4 or shortenBy6.
8365

8466
recoverNearest:
85-
This method is passed a valid short Open Location Code (of four to seven
86-
characters) and a latitude and longitude, and returns the nearest
87-
matching full Open Location Code to the specified location.
88-
89-
The number of characters that will be prepended to the short code, where S
90-
is the supplied short code and R are the computed characters, are:
91-
SSSS -> RRRR.RRSSSS
92-
SSSSS -> RRRR.RRSSSSS
93-
SSSSSS -> RRRR.SSSSSS
94-
SSSSSSS -> RRRR.SSSSSSS
95-
Note that short codes with an odd number of characters will have their
96-
last character decoded using the grid refinement algorithm.
67+
This method is passed a valid short Open Location Code and a latitude and
68+
longitude, and returns the nearest matching full Open Location Code to
69+
the specified location.
9770

0 commit comments

Comments
 (0)