22from openlocationcode import openlocationcode as olc
33
44# https://github.com/google/open-location-code/blob/master/python/openlocationcode_test.py
5+ # https://grid.plus.codes/
56
67
78def check_spatial_reference (feature_class ):
9+ """
10+ Check if the feature class is using the Geographic Reference System WGS84 (Lat / Long). The wkid should be 4326.
11+ An exception will be raised if that's not the case.
12+ :param feature_class: The feature class that will be used to generate the Open Location Code.
13+ :return:
14+ """
815 sr = arcpy .Describe (feature_class ).spatialReference
916 if sr .factoryCode != 4326 :
1017 raise ValueError ('The input feature class must be in WHS84 (WKID 4326)' )
1118
1219
13- def validate_plus_code_length (code ):
20+ def validate_plus_code_length (code_length ):
21+ """
22+ Validate if the Plus Code Length is valid. That does not account for the character '+' added by the API. The
23+ function will raise an exception if the number of character used is not valid.
24+ :param code_length: The number of characters used to encode the Open Location Code.
25+ :return: None
26+ """
1427
1528 # Those are the number of digit required from the specifications.
1629 valid_codes_length = [
@@ -23,9 +36,9 @@ def validate_plus_code_length(code):
2336 12 # Level 6
2437 ]
2538
26- if code not in valid_codes_length :
39+ if code_length not in valid_codes_length :
2740 raise ValueError ('Valid Plus Code must be one of the following value: {}' .format (
28- ', ' .join ([str (code ) for code in valid_codes_length ])
41+ ', ' .join ([str (code_length ) for code_length in valid_codes_length ])
2942 ))
3043
3144
@@ -56,7 +69,7 @@ def generate_plus_code(feature_class, plus_code_field, code_length):
5669
5770 :param feature_class: The input feature class. The EPSG must be 4326
5871 :param plus_code_field: The field that will contain the plus codes.
59- :param code_length: The maximum length for the plus code .
72+ :param code_length: The number of characters used to encode the Open Location Code .
6073 :return:
6174 """
6275
0 commit comments