-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclick_nav.py
More file actions
32 lines (26 loc) · 819 Bytes
/
click_nav.py
File metadata and controls
32 lines (26 loc) · 819 Bytes
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
import json
import click
'''
The purpose of this script is to perform a patch to cchdo with an infile that
is a nav_file in .txt format containing LATITUDE and LONGITUDE information
to update the coordinate information for a cruise with no track
'''
@click.command()
@click.argument('infile', type = click.File('r'), nargs = 1)
@click.argument('outfile', type = click.File('w'), nargs = 1)
def nav(infile, outfile):
points = []
for line in infile:
point = [float(p) for p in line.split()[:2]]
if point not in points:
points.append(point)
linestring = {
"type": "LineString",
"coordinates": points
}
patch = [
{"path":"/geometry/track", "op":"replace", "value":linestring}
]
json.dump(patch, outfile)
if __name__ == '__main__':
nav()