172 lines
5.7 KiB
Python
172 lines
5.7 KiB
Python
import sympy as sp
|
|
from decimal import Decimal
|
|
import math
|
|
import numpy as np
|
|
import Datenbank
|
|
|
|
class Berechnungen:
|
|
def __init__(self, a, b):
|
|
self.a_wert = a
|
|
self.b_wert = b
|
|
self.e_quadrat_wert = self.e_quadrat()
|
|
self.e_strich_quadrat_wert = self.e_strich_quadrat()
|
|
|
|
def e_quadrat(self):
|
|
return (self.a_wert**2 - self.b_wert**2) / self.a_wert **2
|
|
|
|
def e_strich_quadrat(self):
|
|
return (self.a_wert**2 - self.b_wert**2) / self.b_wert **2
|
|
|
|
def P(self, x, y):
|
|
return np.sqrt(x**2 + y**2)
|
|
|
|
def hilfswinkel(self, x, y, z):
|
|
hw = np.atan2(z * self.a_wert, self.P(x, y) * self.b_wert)
|
|
return hw
|
|
|
|
def B(self, x, y, z):
|
|
hilfswinkel = self.hilfswinkel(x, y, z)
|
|
B = np.atan2((z + self.e_strich_quadrat_wert * self.b_wert * np.sin(hilfswinkel) ** 3), (self.P(x, y) - self.e_quadrat_wert * self.a_wert * np.cos(hilfswinkel) ** 3))
|
|
return B
|
|
|
|
def L(self, x, y):
|
|
return np.atan2(y, x)
|
|
|
|
def H(self, x, y, z):
|
|
B = self.B(x, y, z)
|
|
H = (self.P(x, y) / np.cos(B)) - self.a_wert / (np.sqrt(1 - self.e_quadrat_wert * np.sin(B) ** 2))
|
|
return H
|
|
|
|
def E(self, L, dX, dY):
|
|
E = -np.sin(L) * dX + np.cos(L) * dY
|
|
return E
|
|
|
|
def N(self, B, L, dX, dY, dZ):
|
|
N = -np.sin(B) * np.cos(L) * dX - np.sin(B) * np.sin(L) * dY + np.cos(B) * dZ
|
|
return N
|
|
|
|
def U(self, B, L, dX, dY, dZ):
|
|
U = np.cos(B) * np.cos(L) * dX + np.cos(B) * np.sin(L) *dY + np.sin(B) * dZ
|
|
return U
|
|
|
|
def horizontalstrecke_ENU(self, E, N):
|
|
s = np.sqrt(E**2 + N**2)
|
|
return s
|
|
|
|
def Zenitwinkel(self, horizontalstrecke_ENU, U):
|
|
zw = np.atan2(horizontalstrecke_ENU, U)
|
|
return zw
|
|
|
|
def Azimut(self, E, N):
|
|
Azimut = np.atan2(E, N)
|
|
if Azimut < 0:
|
|
Azimut += 2 * np.pi
|
|
if Azimut > 2 * np.pi:
|
|
Azimut -= 2 * np.pi
|
|
return Azimut
|
|
|
|
def Richtung(self, Azimut, Orientierung):
|
|
Richtung = Azimut - Orientierung
|
|
if Richtung < 0:
|
|
Richtung += 2 * np.pi
|
|
if Richtung > 2 * np.pi:
|
|
Richtung -= 2 * np.pi
|
|
return Richtung
|
|
|
|
def geometrische_breite_laenge(self, dict_koordinaten):
|
|
for punktnummer, matrix in dict_koordinaten.items():
|
|
|
|
dict_koordinaten[punktnummer] = [matrix, self.B(matrix[0], matrix[1], matrix[2]), self.L(matrix[0], matrix[1])]
|
|
return dict_koordinaten
|
|
|
|
def berechnung_richtung_azimut_zenitwinkel(self, pfad_datenbank, dict_koordinaten):
|
|
dict_koordinaten_erweitert = {}
|
|
dict_orientierungen = {}
|
|
liste_azimut_richtungen = []
|
|
db_zugriff = Datenbank.Datenbankzugriff(pfad_datenbank)
|
|
liste_beobachtungen_tachymeter = db_zugriff.get_beobachtungen_from_beobachtungenid()
|
|
|
|
for punktnummer, koordinaten in dict_koordinaten.items():
|
|
X = float(koordinaten[0])
|
|
Y = float(koordinaten[1])
|
|
Z = float(koordinaten[2])
|
|
|
|
P = self.P(X, Y)
|
|
hilfwinkel = self.hilfswinkel(X, Y, Z)
|
|
B = self.B(X, Y, Z)
|
|
L = self.L(X, Y)
|
|
H = self.H(X, Y, Z)
|
|
|
|
dict_koordinaten_erweitert[punktnummer] = koordinaten, P, hilfwinkel, B, L, H
|
|
|
|
beobachtsgruppeID_vorher = None
|
|
for beobachtung_tachymeter in liste_beobachtungen_tachymeter:
|
|
standpunkt = beobachtung_tachymeter[0]
|
|
zielpunkt = beobachtung_tachymeter[1]
|
|
|
|
X1 = dict_koordinaten[beobachtung_tachymeter[0]][0]
|
|
X2 = dict_koordinaten[beobachtung_tachymeter[1]][0]
|
|
Y1 = dict_koordinaten[beobachtung_tachymeter[0]][1]
|
|
Y2 = dict_koordinaten[beobachtung_tachymeter[1]][1]
|
|
Z1 = dict_koordinaten[beobachtung_tachymeter[0]][2]
|
|
Z2 = dict_koordinaten[beobachtung_tachymeter[1]][2]
|
|
|
|
dX = float(X2 - X1)
|
|
dY = float(Y2 - Y1)
|
|
dZ = float(Z2 - Z1)
|
|
|
|
B = float(dict_koordinaten_erweitert[beobachtung_tachymeter[0]][3])
|
|
L = float(dict_koordinaten_erweitert[beobachtung_tachymeter[0]][4])
|
|
|
|
E = self.E(L, dX, dY)
|
|
N = self.N(B, L, dX, dY, dZ)
|
|
U = self.U(B, L, dX, dY, dZ)
|
|
|
|
horizontalstrecke_ENU = self.horizontalstrecke_ENU(E, N)
|
|
Azimut = float(self.Azimut(E, N))
|
|
Zenitwinkel = float(self.Zenitwinkel(horizontalstrecke_ENU, U))
|
|
|
|
beobachtsgruppeID_aktuell = beobachtung_tachymeter[3]
|
|
if beobachtsgruppeID_aktuell == beobachtsgruppeID_vorher:
|
|
richtung = float(self.Richtung(Azimut, orientierung))
|
|
liste_azimut_richtungen.append((standpunkt, zielpunkt, Azimut, richtung, Zenitwinkel))
|
|
|
|
else:
|
|
orientierung = Azimut
|
|
dict_orientierungen[beobachtsgruppeID_aktuell] = orientierung
|
|
|
|
richtung = float(self.Richtung(Azimut, orientierung))
|
|
liste_azimut_richtungen.append((standpunkt, zielpunkt, Azimut, richtung, Zenitwinkel))
|
|
|
|
beobachtsgruppeID_vorher = beobachtsgruppeID_aktuell
|
|
return liste_azimut_richtungen, dict_orientierungen
|
|
|
|
|
|
class Einheitenumrechnung:
|
|
def __init__(self):
|
|
pass
|
|
|
|
def mas_to_rad(mas):
|
|
umrechnungsfaktor = 1 / 1000 * 1 / 3600 * sp.pi / 180
|
|
grad = mas * umrechnungsfaktor
|
|
return grad
|
|
|
|
def mm_to_m(mm):
|
|
m = mm / 1000
|
|
return m
|
|
|
|
def ppb(ppb):
|
|
ppb *= 10 ** (-9)
|
|
return ppb
|
|
|
|
def gon_to_rad_Decimal(gon):
|
|
gon = Decimal(gon)
|
|
pi = Decimal(str(math.pi))
|
|
rad = (gon / Decimal(200)) * pi
|
|
return rad
|
|
|
|
def mgon_to_rad_Decimal(gon):
|
|
gon = Decimal(gon)
|
|
pi = Decimal(str(math.pi))
|
|
rad = (gon / Decimal(200000)) * pi
|
|
return rad |