Skip to content

Instantly share code, notes, and snippets.

@george-silva
Created September 28, 2012 18:02
Show Gist options
  • Save george-silva/3801297 to your computer and use it in GitHub Desktop.
Save george-silva/3801297 to your computer and use it in GitHub Desktop.
Conversão PTL
@staticmethod
def para_ptl(xo,yo,zo,lato,lono,x_geoc,y_geoc,z_geoc):
"""
xo,yo,zo = origem geocentrica;
lato,lono = origem em lat long;
x_geoc,y_geoc,z_geoc = ponto a ser convertido;
"""
rlat = radians(lato)
rlot = radians(lono)
xp = (-1 * (x_geoc - xo)) * sin(rlot) + (y_geoc - yo) * cos(rlot)
yp = (-1 * (x_geoc - xo)) * cos(rlot)*sin(rlat) - (y_geoc - yo) * sin(rlat)*sin(rlot) + (z_geoc - zo) * cos(rlat)
zp = (x_geoc - xo) * cos(rlat) * cos(rlot) + (y_geoc - yo) * cos(rlat) * sin(rlot) + (z_geoc - zo) * sin(rlat)
return Point(x=xp,y=yp,z=zp,srid=-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment