Skip to content

Commit de80d65

Browse files
Fixed codeLength input validation in the encode method.
- Valid lengths are divisible by 2 until the pair code length, not separator position.
1 parent ecf5d75 commit de80d65

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/openlocationcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def isFull(code):
208208
including any separator characters.
209209
"""
210210
def encode(latitude, longitude, codeLength=PAIR_CODE_LENGTH_):
211-
if codeLength < 2 or (codeLength < SEPARATOR_POSITION_ and codeLength % 2 == 1):
211+
if codeLength < 2 or (codeLength < PAIR_CODE_LENGTH_ and codeLength % 2 == 1):
212212
raise ValueError('Invalid Open Location Code length - ' + str(codeLength))
213213
# Ensure that latitude and longitude are valid.
214214
latitude = clipLatitude(latitude)

0 commit comments

Comments
 (0)