aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-10-24 08:53:44 +0200
committerKristian Evers <kristianevers@gmail.com>2018-01-09 23:24:43 +0100
commita053ad0e9172badb14828ab5fe6fc807b686090b (patch)
treec59dc7caf8f32135d7c2330712415474ee30ecb5 /test
parent47953f0a93cd90d0d52b74f2b2705516f018b2f1 (diff)
downloadPROJ-a053ad0e9172badb14828ab5fe6fc807b686090b.tar.gz
PROJ-a053ad0e9172badb14828ab5fe6fc807b686090b.zip
Added json to gie conversion script
Diffstat (limited to 'test')
-rw-r--r--test/gigs/convert_to_gie.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/gigs/convert_to_gie.py b/test/gigs/convert_to_gie.py
new file mode 100644
index 00000000..2b80aaa3
--- /dev/null
+++ b/test/gigs/convert_to_gie.py
@@ -0,0 +1,44 @@
+import sys
+import json
+
+
+with open(sys.argv[1]) as f:
+ data = json.load(f)
+
+coords = data['coordinates']
+tests = data['tests']
+crss = data['projections']
+
+if len(coords[0]) == 3:
+ tolerance_index = 0
+else:
+ tolerance_index = 1
+
+filename = sys.argv[1].replace('json', 'gie')
+with open(filename, 'w') as f:
+ f.write('-'*80 + '\n\n')
+ f.write('{descr}\n\n'.format(descr=data['description']))
+ f.write('-'*80 + '\n\n')
+ f.write('<gie>\n\n');
+ for test in tests:
+ f.write('-'*80 + '\n')
+ f.write('operation +proj=pipeline\n')
+ f.write(' +step {src} +inv\n'.format(src=crss[0]))
+ f.write(' +step {dst}\n'.format(dst=crss[1]))
+ f.write('-'*80 + '\n')
+
+ if test['type'] == 'conversion':
+ write_coords(f, coords, 'fwd', test)
+
+ f.write('-'*80 + '\n')
+ f.write('operation +proj=pipeline\n')
+ f.write(' +step {src} +inv\n'.format(src=crss[1]))
+ f.write(' +step {dst}\n'.format(dst=crss[0]))
+ f.write('-'*80 + '\n')
+
+ write_coords(f, coords, 'inv', test)
+
+ if test['type'] == 'roundtrip':
+ write_coords(f, coords, 'roundtrip', test)
+
+ f.write('</gie>\n')