-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_endpoints.py
33 lines (27 loc) · 995 Bytes
/
get_endpoints.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""
Description:
Extract segment endpoints from a segments.json file
Usage:
get_endpoints.py --segments <filename> (--output <filename> | --output_csv <filaname>)
get_endpoints.py -h | --help
Options:
-h --help Show this screen.
--segments <filename> Filename of segments.json
--output <filename> File to write geojson to.
--output_csv <filename> File to write CSV to.
"""
from docopt import docopt
from lib.geojson_io import get_features
from lib.endpoints import get_endpoint_data, generate_geojson, write_geojson, write_csv
if __name__ == '__main__':
arguments = docopt(__doc__)
segments_file = arguments["--segments"]
geojson_out_file = arguments["--output"]
csv_out_file = arguments["--output_csv"]
features = get_features(segments_file)
data = get_endpoint_data(features)
if geojson_out_file is not None:
write_geojson(geojson_out_file, generate_geojson(data))
else:
write_csv(csv_out_file, data)