mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 09:27:07 +00:00
Record P1/11 line name in database on import
This commit is contained in:
@@ -406,12 +406,12 @@ class Datastore:
|
|||||||
self.del_hash("*online*", cursor)
|
self.del_hash("*online*", cursor)
|
||||||
|
|
||||||
qry = """
|
qry = """
|
||||||
INSERT INTO raw_lines (sequence, line, remarks, ntbp, incr)
|
INSERT INTO raw_lines (sequence, line, remarks, ntbp, incr, meta)
|
||||||
VALUES (%s, %s, '', %s, %s)
|
VALUES (%s, %s, '', %s, %s, %s)
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], ntbp, incr))
|
cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], ntbp, incr, json.dumps(fileinfo["meta"])))
|
||||||
|
|
||||||
qry = """
|
qry = """
|
||||||
INSERT INTO raw_lines_files (sequence, hash)
|
INSERT INTO raw_lines_files (sequence, hash)
|
||||||
@@ -448,12 +448,12 @@ class Datastore:
|
|||||||
hash = self.add_file(filepath, cursor)
|
hash = self.add_file(filepath, cursor)
|
||||||
|
|
||||||
qry = """
|
qry = """
|
||||||
INSERT INTO final_lines (sequence, line, remarks)
|
INSERT INTO final_lines (sequence, line, remarks, meta)
|
||||||
VALUES (%s, %s, '')
|
VALUES (%s, %s, '', %s)
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"]))
|
cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], json.dumps(fileinfo["meta"])))
|
||||||
|
|
||||||
qry = """
|
qry = """
|
||||||
INSERT INTO final_lines_files (sequence, hash)
|
INSERT INTO final_lines_files (sequence, hash)
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ if __name__ == '__main__':
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
file_info = dict(zip(pattern["captures"], match.groups()))
|
file_info = dict(zip(pattern["captures"], match.groups()))
|
||||||
|
file_info["meta"] = {}
|
||||||
|
|
||||||
if pending:
|
if pending:
|
||||||
print("Skipping / removing final file because marked as PENDING", filepath)
|
print("Skipping / removing final file because marked as PENDING", filepath)
|
||||||
@@ -117,6 +118,7 @@ if __name__ == '__main__':
|
|||||||
print("Saving")
|
print("Saving")
|
||||||
|
|
||||||
p111_records = p111.p111_type("S", p111_data)
|
p111_records = p111.p111_type("S", p111_data)
|
||||||
|
file_info["meta"]["lineName"] = p111.line_name(p111_data)
|
||||||
|
|
||||||
db.save_final_p111(p111_records, file_info, filepath, survey["epsg"])
|
db.save_final_p111(p111_records, file_info, filepath, survey["epsg"])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -75,12 +75,14 @@ if __name__ == '__main__':
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
file_info = dict(zip(pattern["captures"], match.groups()))
|
file_info = dict(zip(pattern["captures"], match.groups()))
|
||||||
|
file_info["meta"] = {}
|
||||||
|
|
||||||
p111_data = p111.from_file(filepath)
|
p111_data = p111.from_file(filepath)
|
||||||
|
|
||||||
print("Saving")
|
print("Saving")
|
||||||
|
|
||||||
p111_records = p111.p111_type("S", p111_data)
|
p111_records = p111.p111_type("S", p111_data)
|
||||||
|
file_info["meta"]["lineName"] = p111.line_name(p111_data)
|
||||||
|
|
||||||
db.save_raw_p111(p111_records, file_info, filepath, survey["epsg"], ntbp=ntbp)
|
db.save_raw_p111(p111_records, file_info, filepath, survey["epsg"], ntbp=ntbp)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -153,6 +153,9 @@ def parse_line (string):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def line_name(records):
|
||||||
|
return set([ r['Acquisition Line Name'] for r in p111_type("S", records) ]).pop()
|
||||||
|
|
||||||
def p111_type(type, records):
|
def p111_type(type, records):
|
||||||
return [ r for r in records if r["type"] == type ]
|
return [ r for r in records if r["type"] == type ]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user