Skip to content

Commit 5fa230d

Browse files
authored
added aoi config key
1 parent 366f99a commit 5fa230d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

label_maker/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,19 @@ def cli():
8282
valid = v.validate(config)
8383
if not valid:
8484
raise Exception(v.errors)
85-
85+
86+
# for aoi, overwrite bounding_box config key to correct labelling
87+
if 'aoi' in config.keys:
88+
config['bounding_box'] = get_bounds(json.load(open(config.get('aoi'), 'r')))
89+
8690
# custom validation for top level keys
8791
# require either: country & bounding_box or geojson
88-
if not ('country' in config.keys() and 'geojson' in config.keys()) and not ('country' in config.keys() and 'bounding_box' in config.keys()):
89-
raise Exception('either "country" and "geojson" or "country" and "bounding_box" must be present in the configuration JSON')
92+
if 'geojson' not in config.keys()) and not ('country' in config.keys() and 'bounding_box' in config.keys()):
93+
raise Exception('either "geojson" or "country" and "bounding_box" must be present in the configuration JSON')
9094

9195
# for geojson, overwrite other config keys to correct labeling
9296
if 'geojson' in config.keys():
97+
config['country'] = op.splitext(op.basename(config.get('geojson')))[0]
9398
config['bounding_box'] = get_bounds(json.load(open(config.get('geojson'), 'r')))
9499

95100
if cmd == 'download':

0 commit comments

Comments
 (0)