Support import of preplot lines ancillary information.

Closes #264.
This commit is contained in:
D. Berge
2024-05-04 17:32:30 +02:00
parent 4368cb8571
commit 90782c1b09
2 changed files with 70 additions and 2 deletions

View File

@@ -15,6 +15,12 @@ import configuration
import preplots
from datastore import Datastore
def preplots_sorter (preplot):
rank = {
"x-sl+csv": 10
}
return rank.get(preplot.get("type"), 0)
if __name__ == '__main__':
print("Connecting to database")
@@ -28,7 +34,10 @@ if __name__ == '__main__':
for survey in surveys:
print(f'Survey: {survey["id"]} ({survey["schema"]})')
db.set_survey(survey["schema"])
for file in survey["preplots"]:
# We sort the preplots so that ancillary line info always comes last,
# after the actual line + point data has been imported
for file in sorted(survey["preplots"], key=preplots_sorter):
realpath = configuration.translate_path(file["path"])
print(f"Preplot: {file['path']}")
@@ -48,7 +57,10 @@ if __name__ == '__main__':
if type(preplot) is list:
print("Saving to DB")
db.save_preplots(preplot, file["path"], file["class"], survey["epsg"], file)
if file.get("type") == "x-sl+csv":
db.save_preplot_line_info(preplot, file["path"], file)
else:
db.save_preplots(preplot, file["path"], file["class"], survey["epsg"], file)
elif type(preplot) is str:
print(preplot)
else: