mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-12-21 07:52:20 +00:00
110 lines
3.8 KiB
Python
110 lines
3.8 KiB
Python
#!/usr/bin/python
|
|
|
|
import csv
|
|
import re
|
|
#import math
|
|
|
|
# dataset generated from CaveRenderer
|
|
# *fix where from=to, convert grads to degrees and print out legs
|
|
# A better conversion would identify caves and put in begin/end pairs
|
|
# Offset Easting by 450k and Northing by 200k to fit with the CUCC standard
|
|
|
|
fin = open("Uebersicht_2011.txt")
|
|
|
|
fout = open("Uebersicht_2011.svx", "w")
|
|
fout.write("*begin 1626\n")
|
|
|
|
rows = list(csv.reader(fin.readlines(), csv.excel_tab))
|
|
assert rows[0] == ['RH\xf6hle', 'RGang', 'RPunkt', 'H\xf6hle', 'Gang', 'Punkt', 'Start', 'Ende', 'L\xe4nge', 'Azimut', 'Neigung', 'Links', 'Rechts', 'Oben', 'Unten', 'Ger\xe4t', 'Richtung', 'Ring', 'Farbe', 'Ebene', 'Datum', 'Vermesser', 'Bezeichnung', 'Material', 'Ma\xdfnahmen', 'Bemerkung', 'Datei/URL', 'Include-Datei', 'RefX', 'RefY', 'RefZ', 'X', 'Y', 'Z']
|
|
headers = ['RHohle', 'RGang', 'RPunkt', 'Hohle', 'Gang', 'Punkt', 'Start', 'End', 'Tape', 'Compass', 'Clino', 'Left', 'Right', 'Up', 'Down', 'Instruments', 'Direction', 'Ring', 'Colour', 'Ebene', 'Date', 'Surveyor', 'Description', 'Material', 'Massnahmen', 'Marking', 'Datei-URL', 'Include-Datei', 'RefX', 'RefY', 'RefZ', 'X', 'Y', 'Z']
|
|
#sfromfixes = set()
|
|
|
|
cave=instruments=None
|
|
beginname=None
|
|
|
|
|
|
for i, row in enumerate(rows[1:]):
|
|
data = dict(zip(headers, row))
|
|
|
|
for k in ['RefX', 'RefY', 'RefZ', 'X', 'Y', 'Z', 'Left', 'Right', 'Up', 'Down', 'Tape', 'Compass', 'Clino']:
|
|
data[k] = float(re.sub(",", ".", data[k]))
|
|
assert data["Start"] == '0', (i, data)
|
|
del data["Start"]
|
|
assert data["End"] == '0', (i, data)
|
|
del data["End"]
|
|
assert not data['Include-Datei']
|
|
del data["Include-Datei"]
|
|
assert not data['Datei-URL']
|
|
del data["Datei-URL"]
|
|
|
|
prevlinecave=cave
|
|
cave=data['RHohle']
|
|
|
|
prevlineinstruments=instruments
|
|
instruments=data["Instruments"]
|
|
|
|
if cave != prevlinecave:
|
|
if beginname != None:
|
|
fout.write(f"*end {beginname}\n")
|
|
beginname = None
|
|
if row != i: #don't start new begin for last line
|
|
fout.write(f"\n*begin {cave}\n")
|
|
beginname = cave
|
|
|
|
|
|
|
|
#'Geraet/Instruments' column indicates instruments used (360 degrees, 400 grads)
|
|
#1 = azimuth in degrees, slope in degrees
|
|
#2 = azimuth in grads, slope in grads
|
|
#3 = azimuth in grads, slope in degrees
|
|
#4 = azimuth in degrees, slope in grads
|
|
|
|
# Better to put data in as-is with appropriate *commands - this will do for now
|
|
if data["Instruments"] in ["2", "3"]:
|
|
bearing = data["Compass"] * 0.9
|
|
else:
|
|
bearing = data["Compass"]
|
|
if data["Instruments"] in ["2", "4"]:
|
|
slope = data["Clino"] * 0.9
|
|
else:
|
|
slope = data["Clino"]
|
|
|
|
|
|
#vx, vy, vz = data["X"] - data["RefX"], data["Y"] - data["RefY"], data["Z"] - data["RefZ"]
|
|
|
|
#tape = math.sqrt(vx*vx + vy*vy + vz*vz)
|
|
#if math.fabs(tape-data["Tape"]) > 0.2:
|
|
# print (i, tape, tape-data["Tape"])
|
|
|
|
#compass = (math.degrees(math.atan2(vx, vy))+360) % 360
|
|
#if math.fabs(((compass - data["Compass"] + 180) % 360) - 180) > 0.9:
|
|
# print (i, data["Instruments"], compass, data["Compass"])
|
|
|
|
#clino = math.degrees(math.atan2(vz, math.sqrt(vx*vx + vy*vy)))
|
|
#if math.fabs(clino - data["Clino"]) > 4.9:
|
|
# print (i, data["Instruments"], clino, data["Clino"]), (vx,vy,vz)
|
|
|
|
#if i < 10: print data
|
|
|
|
sfrom = f"{data['RGang']}-{data['RPunkt']}"
|
|
sto = f"{data['Gang']}-{data['Punkt']}"
|
|
if data['Description']:
|
|
fout.write(f";{data['Description']}\n")
|
|
if sfrom == sto:
|
|
if data['RefX'] == data['X'] and data['RefY'] == data['Y'] and data['RefZ'] == data['Z']:
|
|
fout.write(f"*fix {sfrom} {data['RefX'] - 450000:f} {data['RefY'] - 200000:f} {data['RefZ']:f}\n")
|
|
else:
|
|
print ("Fix 'leg' with non-matching co-ordinates - line i\n")
|
|
else:
|
|
fout.write(f"{sfrom} {sto}\t{data['Tape']}\t{bearing}\t{slope}\n")
|
|
# if sfrom not in sfromfixes:
|
|
# fout.write("*fix %s %f %f %f\n" % (sfrom, data['RefX']-450000, data['RefY']-200000, data['RefZ']))
|
|
# sfromfixes.add(sfrom)
|
|
|
|
if beginname != None:
|
|
fout.write(f"*end {beginname}\n")
|
|
|
|
fout.write("\n*end 1626\n")
|
|
fout.close()
|
|
|