Erstellen Sie die SQL -Funktion, um ECEF in geodetisch umzuwandelnPython

Python-Programme
Anonymous
 Erstellen Sie die SQL -Funktion, um ECEF in geodetisch umzuwandeln

Post by Anonymous »

Ich habe ein Python -Skript unten, das Ergebnis zu rad liefert, das ich dann in Grad umwandelte. Es funktioniert gut, aber ich bin interessiert, die gleiche Funktion in SQL zu erstellen, damit ich sie in der Tabelle an Parse ECEF -Werten verwenden kann. < /P>

Code: Select all

import math
def xyz2llh(x,y,z):
'''
Function to convert xyz ECEF to llh
convert cartesian coordinate into geographic coordinate
ellipsoid definition: WGS84
a= 6,378,137m
f= 1/298.257

Input
x: coordinate X meters
y: coordinate y meters
z: coordinate z meters
Output
lat: latitude rad
lon: longitude rad
h: height meters
'''
# --- WGS84 constants
a = 6378137.0
f = 1.0 / 298.257223563
# --- derived constants
b = a - f*a
e = math.sqrt(math.pow(a,2.0)-math.pow(b,2.0))/a
clambda = math.atan2(y,x)
p = math.sqrt(pow(x,2.0)+pow(y,2))
h_old = 0.0
# first guess with h=0 meters
theta = math.atan2(z,p*(1.0-math.pow(e,2.0)))
cs = math.cos(theta)
sn = math.sin(theta)
N = math.pow(a,2.0)/math.sqrt(math.pow(a*cs,2.0)+math.pow(b*sn,2.0))
h = p/cs - N
while abs(h-h_old) > 1.0e-6:
h_old = h
theta = math.atan2(z,p*(1.0-math.pow(e,2.0)*N/(N+h)))
cs = math.cos(theta)
sn = math.sin(theta)
N = math.pow(a,2.0)/math.sqrt(math.pow(a*cs,2.0)+math.pow(b*sn,2.0))
h = p/cs - N
llh = {'lon':clambda, 'lat':theta, 'height': h}
return llh

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post