Beispiel #1
0
def main():
    r = RadiosDeCurvatura("WGS 84")
    print(r.getRadioPrimerVertical(0.785398163),
          r.getRadioElipseMeridiana(0.785398163))
    p = pgeo.PuntoGeodesico(ang.Angulo(45, formato="latitud"),
                            ang.Angulo(45, formato="longitud180"))
    print(r.getRadioPrimerVertical(p), r.getRadioElipseMeridiana(p))
    p = pgeo.PuntoGeodesico(ang.Angulo(0, formato="latitud"),
                            ang.Angulo(45, formato="longitud180"))
    print(r.getRadioPrimerVertical(p), r.getRadioElipseMeridiana(p))
def main():
    p = pgeo.PuntoGeodesico(39.205324, -0.524532)  #Valor PAG: 50.256
    print(CalcularOndulacion(p))

    p = pgeo.PuntoGeodesico(39.205324, -0.495632)  #Valor PAG: 50.202
    print(CalcularOndulacion(p))

    p = pgeo.PuntoGeodesico(39.205324, 0.495632)  #Valor PAG: 48.127
    print(CalcularOndulacion(p))

    p = pgeo.PuntoGeodesico(40.505324, 0.495632)  #Valor PAG: 49.689
    print(CalcularOndulacion(p))
Beispiel #3
0
def Geo2CargeoFromFile(File, NombreElipsoide):
    from os.path import exists, isfile
    from PyQt4 import QtGui
    '''!
    '''
    #ID,Lat,Lon,helip?
    if not type(File) == str:
        raise Exception("Not str")
    if not exists(File):
        raise Exception("Not Exists")
    if not isfile(File):
        raise Exception("Not File")
    IDS = []
    Lats = []
    Lons = []
    helip = []
    f = open(File, 'r')
    for i in f:
        QtGui.QApplication.processEvents()
        i = i.split(",")
        IDS.append(i[0])
        Lats.append(i[1])
        Lons.append(i[2])
        try:
            helip.append(i[3])
        except:
            helip.append(None)
    f.close()
    Sal = []
    for ids, lat, lon, hel in zip(IDS, Lats, Lons, helip):
        QtGui.QApplication.processEvents()
        p = pgeo.PuntoGeodesico(lat, lon, helip)
        p1 = Geo2Cargeo(p, NombreElipsoide)
        Sal.append([ids, p, p1])
    return Sal
Beispiel #4
0
    def Calcular(self):
        '''!
        '''
        if self.lineEdit.text() == "":
            self.__msgBoxErr.setText(
                "Debe introducir un valor para la latitud origen.")
            self.__msgBoxErr.exec_()
            return
        if self.lineEdit_2.text() == "":
            self.__msgBoxErr.setText(
                "Debe introducir un valor para la la longitud origen.")
            self.__msgBoxErr.exec_()
            return
        if self.lineEdit_3.text() == "":
            self.__msgBoxErr.setText(
                "Debe introducir un valor para la distancia de calculo.")
            self.__msgBoxErr.exec_()
            return
        if self.lineEdit_4.text() == "":
            self.__msgBoxErr.setText(
                "Debe introducir un valor para el azimut.")
            self.__msgBoxErr.exec_()
            return

        pasos = None
        if self.checkBox.checkState() == 2:
            try:
                int(self.lineEdit_7.text())
            except:
                self.__msgBoxErr.setText(
                    "El número de pasos debe ser un valor entero.")
                self.__msgBoxErr.exec_()
                return
            finally:
                pasos = int(self.lineEdit_7.text())
        try:
            sal = pdg.PDGeodesia(
                pgeo.PuntoGeodesico(self.lineEdit.text(),
                                    self.lineEdit_2.text()),
                self.lineEdit_3.text(), self.lineEdit_4.text())
            lat, lon, az = sal.Rk4o(self.comboBox.currentText(), pasos)
        except Exception as e:
            self.__msgBoxErr.setText(e.__str__())
            self.__msgBoxErr.exec_()

        #ang.Angulo(lat).Convertir('pseudosexagesimal').getAngulo()
        a1 = ang.Angulo(lat, girar=True)
        a1.Convertir('pseudosexagesimal')
        self.lineEdit_6.setText(str(a1.getAngulo()))
        a1 = ang.Angulo(lon, girar=True)
        a1.Convertir('pseudosexagesimal')
        self.lineEdit_5.setText(str(a1.getAngulo()))
        a1 = ang.Angulo(az, girar=True)
        a1.Convertir('pseudosexagesimal')
        self.lineEdit_8.setText(str(a1.getAngulo()))
Beispiel #5
0
def Cargeo2Geo(Punto, NombreElipsoide):
    '''
    @brief: Funcion que transforma de Coordenadas Cartesianas Geocentricas a Geodesicas Elipsoidales.
    
    @param Punto Punto3D: Punto3D con las coordenadas Cartesianas Geocentricas.
    @param NombreElipsoide str: Nombre del elipsoide de calculo.
    
    @raise Valor Punto3D: Se produce una excepción en el caso de que el punto introducido no sea de tipo punto3D.
    @raise Valor Nombre Elipsoide: Se produce una excepción en el caso que el el Nombre del elipsoide no sea de tipo String.
                                   
    @return PuntoGeodesico: Punto Geodesico con el resultado.
    '''
    if not isinstance(Punto, pt3.Punto3D):
        raise Exception(
            "Se esperaba un objeto de la clase Punto3D como primer valor de entrada del constructor."
        )

    try:
        NombreElipsoide = str(NombreElipsoide)
    except:
        raise Exception(
            "Se esperaba un str como segundo valor entrada de la función.")

    x = Punto.getX()
    y = Punto.getY()
    z = Punto.getZ()
    #Calculo de parámetros.
    Elipsoide = Elip.Elipsoides(NombreElipsoide)
    e = Elipsoide.getPrimeraExcentricidad()
    #Calculos auxiliares
    r = sqrt((x**2) + (y**2))
    latact = atan((z / r) / (1.0 - (e**2)))
    latiter = 0.0
    helip = 0.0
    cont = 0
    aux = Rad.RadiosDeCurvatura(NombreElipsoide)
    while abs(latact - latiter) > 0.000000000001:
        if cont != 0:
            latact = latiter
        nhu = aux.getRadioPrimerVertical(latact)
        helip = (r / cos(latact)) - nhu
        latiter = atan((z / r) / (1.0 - ((e**2) * (nhu / (nhu + helip)))))
        cont += 1
    '''
    Casos del arcotangente CUADRANTES
    '''

    Lat = ang.Angulo(latiter, formato='radian')
    Lon = ang.Angulo(atan(y / x), formato='radian')
    Lat.Convertir('latitud')
    Lon.Convertir('longitud180')

    return pgeo.PuntoGeodesico(Lat, Lon, helip)
Beispiel #6
0
def main():
    print("Prueba de la conversión de coordenadas.")
    print("Elipsoide de pruebas:\tGRS80")
    print("Coordenadas geodesicas de prueba:")
    print("\tLatitud:\t45")
    print("\tLongitud:\t-1")
    print("\th elipsoidal:\t50")
    print("\n")
    print("Resultados:")
    p1 = Geo2Cargeo(pgeo.PuntoGeodesico(45, -1, 50), "GRS 1980")
    print("X: %.3f" % p1.getX())
    print("Y: %.3f" % p1.getY())
    print("Z: %.3f" % p1.getZ())
    print("\n")
Beispiel #7
0
def main():
    PD=PDGeodesia(pgeo.PuntoGeodesico(50,10),1500000,140)
    lat,lon,az=PD.Rk4o('Hayford 1950')
    #lat,lon,az=PD.Rk4o('WGS 84')
    #lat,lon,az=PD.CalcularLegendre('WGS 84')
    lat=ang.Angulo(lat)
    lat.Convertir('sexagesimal')
    print(lat.getAngulo())
    lon=ang.Angulo(lon)
    lon.Convertir('sexagesimal')
    print(lon.getAngulo())
    az=ang.Angulo(az)
    az.Convertir('sexagesimal')
    print(az.getAngulo())
    pass
Beispiel #8
0
    def toSHP(self, Elipsoide, path=None):
        '''
        \brief Convierte el fichero NMEA a shp.
        param path str: Ruta en la que se quiere guardar el shp.
        '''
        #Por defecto la ruta sera la misma en la que se encuentre el fichero NMEA.
        import shapefile
        import Proyecciones.Geo2UTM as g2u
        import Geometrias.PuntoGeodesico as pgeo
        if path == None:
            path = self.__filepath

        if not exists(path):
            raise Exception("El fichero introducido no existe.")
        if not isfile(path):
            raise Exception(
                "la ruta introducida no corresponde con un directorio.")

        w = shapefile.Writer(shapeType=8)
        w.field('X', 'F', 10, 4)
        w.field('Y', 'F', 10, 4)
        w.field('h', 'F', 10, 4)  #Float
        #w.field('Fecha','D')#Date YYYYMMDD
        w.field('Hora', 'C', 6)  #String
        w.field('Segundos GPS', 'F', 6, 1)
        w.field('Huso', 'N', 2)  #int, número de valores.
        w.field('Satelites', 'N', 3)
        w.field('HDOP', 'F', 3, 2)

        #print(len(self.getFechas()),len(self.getHoras()),len(self.getSegundosGPS()))

        for i, j, k, hora, sgps, sat, hdop in zip(self.getLatitud(),
                                                  self.getLongitud(),
                                                  self.getAltitud(),
                                                  self.getHoras(),
                                                  self.getSegundosGPS(),
                                                  self.getNumeroSatelites(),
                                                  self.getHDOP()):
            #print(sgps)
            sal = g2u.Geo2UTM(pgeo.PuntoGeodesico(i, j), Elipsoide)
            w.point(sal.getX(), sal.getY(), k, 0)
            w.record(sal.getX(), sal.getY(), k, hora, sgps, sal.getHuso(), sat,
                     hdop)
        w.save(self.__path + '/pruebaSHP')
Beispiel #9
0
 def Calcular(self):
     '''!
     '''
     if self.lineEdit.text()=="":
         self.__msgBoxErr.setText("Debe introducir un valor para la latitud origen.")
         self.__msgBoxErr.exec_()
         return
     if self.lineEdit_2.text()=="":
         self.__msgBoxErr.setText("Debe introducir un valor para la la longitud origen.")
         self.__msgBoxErr.exec_()
         return
     if self.lineEdit_3.text()=="":
         self.__msgBoxErr.setText("Debe introducir un valor para la latitud destino.")
         self.__msgBoxErr.exec_()
         return
     if self.lineEdit_4.text()=="":
         self.__msgBoxErr.setText("Debe introducir un valor para la la longitud destino.")
         self.__msgBoxErr.exec_()
         return
     
     try:
         sal=pig.PIGeodesia(pgeo.PuntoGeodesico(self.lineEdit.text(),self.lineEdit_2.text()),pgeo.PuntoGeodesico(self.lineEdit_3.text(),self.lineEdit_4.text()))   
         az,d=sal.CalcularBessel(self.comboBox.currentText())
     except Exception as e:
         self.__msgBoxErr.setText(e.__str__())
         self.__msgBoxErr.exec_()
         
     a1=ang.Angulo(az,girar=True)
     a1.Convertir('pseudosexagesimal')
     self.lineEdit_6.setText(str(a1.getAngulo()))
     Radio=rcurv.RadiosDeCurvatura(self.comboBox.currentText())
     nhu1=Radio.getRadioPrimerVertical(float(self.lineEdit.text()))
     ro1=Radio.getRadioElipseMeridiana(float(self.lineEdit.text()))
     nhu2=Radio.getRadioPrimerVertical(float(self.lineEdit_3.text()))
     ro2=Radio.getRadioElipseMeridiana(float(self.lineEdit_3.text()))
     from math import sqrt
     Rm=(1/2)*((sqrt(nhu1*ro1))+(sqrt(nhu2*ro2)))
     self.lineEdit_5.setText(str(d*Rm))
def Geo2UTM_From_File(File, NombreElipsoide):
    import os
    '''
Función que realiza la conversión de geodesicas a UTM desde un fichero.
    @param File:
    @type File: str.
'''
    if not type(File) == str:
        raise Exception("Not str")
    if not os.path.exists(File):
        raise Exception("Not Exists")
    if not os.path.isfile(File):
        raise Exception("Not File")

    #ID,Lat,Lon,.....
    f = open(File, 'r')
    Lats = [i.split(",")[1] for i in f]
    f.seek(0)
    Lons = [i.split(",")[2] for i in f]
    f.close()
    Elips = [NombreElipsoide for number in range(len(Lats))]
    Puntos = [pgeo.PuntoGeodesico(i, j) for i, j in zip(Lats, Lons)]
    sal = map(Geo2UTM, Puntos, Elips)
    return sal
Beispiel #11
0
def main():
    #     import os
    #     print("Conversor de Coordenadas Geodesicas a UTM.")
    #     opt=None
    #     while opt!=0:
    #         print()
    #         print("Seleccione una opción:\n\t1-Convertir un punto.\n\t2-Convertir un fichero.\n\t0-Salir.")
    #         opt=int(input("Opción: "))
    #         if opt>2:
    #             print("Opción Invalida")
    #             continue
    #         else:
    #             if opt==1:
    #                 print()
    #                 Lat=float(input("Latitud: "))
    #                 Lon=float(input("Longitud: "))
    #                 Nombre_Elipsoide=input("Elipsoide: ").upper()
    #                 Force=""
    #                 while True:
    #                     Force=input("Forzar Coordenadas a un Huso? (S/N):")
    #                     Force=Force.upper()
    #                     if Force=="S":
    #                         break
    #                     elif Force=="N":
    #                         try:
    #                             p=pgeo.PuntoGeodesico(Lat,Lon)
    #                             sal=Geo2UTM(p,Nombre_Elipsoide)
    #                             print()
    #                             print("Resultados:")
    #                             print("X:\t%.3f"%sal.get_X_UTM())
    #                             print("Y:\t%.3f"%sal.get_Y_UTM())
    #                             print("Z:\t"+str(sal.get_Altura_Elipsoidal()))
    #                             print("Huso:\t"+str(sal.get_Huso()))
    #                             print("W:\t%.8f"%sal.get_Convergencia_Meridianos())
    #                             print("fesca:\t%.9f"%sal.get_Escala_Local_Punto())
    #                         except Exception as e:
    #                             print(e)
    #                             break
    #                         break
    #             elif opt==2:
    #                 print()
    #                 try:
    #                     r_ent=input("Ruta fichero Entrada: ")
    #                     r_sal=input("Ruta fichero Salida: ")
    #                     if r_ent==r_sal:
    #                         print()
    #                         print("Error: El archivo de entrada no puede conincidir con el de salida.")
    #                         continue
    #                     Nombre_Elipsoide=input("Elipsoide: ").upper()
    #                     sal=Geo2UTM_From_File(r_ent,Nombre_Elipsoide)
    #                     pr=open(r_sal,'wb',1024)
    #                     for i in sal:
    #                         a=bytes((""+str(i.get_X_UTM())+";"+str(i.get_Y_UTM())+"\n").encode(encoding='UTF-8',errors='strict'))
    #                         pr.write(a)
    #                 except Exception as e:
    #                     print(e)
    #                     break
    #                 break
    #
    #             else:
    #                 os.system('pause')

    #     sal=Geo2UTM_From_File('GeodesicasElipsoidales.txt','GRS80')
    #     input("Y")
    #     for i in sal:
    #         print(i.get_X_UTM(),i.get_Y_UTM())
    #     print("Prueba de la conversión de coordenadas.")
    #     print("Elipsoide de pruebas:\tGRS80")
    #     print("Coordenadas geodesicas de prueba:")
    #     print("\tLatitud:\t45")
    #     print("\tLongitud:\t-1")
    #     print("\th elipsoidal:\t50")
    #     print("\n")
    p1 = pgeo.PuntoGeodesico(ang.Angulo(45, formato='latitud'),
                             ang.Angulo(0.03, formato='longitud180'), 50)
    p3 = pgeo.PuntoGeodesico(40, -16)
    p2 = Geo2UTM(p3, "GRS 1980")
    print("Resultados:")
    print("X:\t%.3f" % p2.getX())
    print("Y:\t%.3f" % p2.getY())
    print("Z:\t%.3f" % p2.getAlturaElipsoidal())
    print("Huso:\t" + str(p2.getHuso()))
    print("W:\t%.8f" % p2.getConvergenciaMeridianos())
    print("fesca:\t%.9f" % p2.getEscalaLocalPunto())
Beispiel #12
0
def Geo2UTMFromFile(File, NombreElipsoide, w=True, kp=True, parent=None):
    '''
    @brief: Función que realiza la conversión de geodesicas a UTM desde un fichero.
    @param File str:Ruta del fichero con las coordenadas a transformar.
    @note: El fichero debe tener el siguiente formato como mínimo: id,Lat,Lon
    '''
    from os.path import exists, isfile
    from PyQt4 import QtGui

    if not type(File) == str:
        raise Exception(
            "El formato del fichero introducido no es de tipo str.")
    if not exists(File):
        raise Exception("El fichero introducido no existe.")
    if not isfile(File):
        raise Exception(
            "El fichero introducido no se corresponde con un archivo.")

    #ID,Lat,Lon,.....
    IDS = []
    Lats = []
    Lons = []
    helips = []
    Forzar = []
    f = open(File, 'r')
    for i in f:
        QtGui.QApplication.processEvents()
        i = i.split(",")
        IDS.append(i[0])
        Lats.append(i[1])
        Lons.append(i[2])
        try:
            helips.append(i[3])
        except:
            helips.append(None)
        try:
            Forzar.append(i[4])
        except:
            Forzar.append(False)
    f.close()

    Sal = []

    for iden, lat, lon, h, f in zip(IDS, Lats, Lons, helips, Forzar):
        QtGui.QApplication.processEvents()
        if parent.pd.wasCanceled():
            return
        p = pgeo.PuntoGeodesico(lat, lon, h)

        p1 = Geo2UTM(p, NombreElipsoide)
        Sal.append([iden, p, p1])
        if Forzar == True:
            ant = p1.getHuso() - 1
            sig = p1.getHuso() + 1
            try:
                p2 = Geo2UTM(pgeo.PuntoGeodesico(lat, lon, h), NombreElipsoide,
                             ant, w, kp)
                Sal.append([iden, p, p2])
            except:
                try:
                    p3 = Geo2UTM(pgeo.PuntoGeodesico(lat, lon, h),
                                 NombreElipsoide, sig, w, kp)
                    Sal.append([iden, p, p3])
                except:
                    continue

    return Sal
Beispiel #13
0
def main():
    PI = PIGeodesia(pgeo.PuntoGeodesico(50, 10), pgeo.PuntoGeodesico(40, 9))
    az, s = PI.CalcularBessel('WGS 84')
    az = ang.Angulo(az)
    az.Convertir('sexagesimal')
    print(az.getAngulo(), s)
Beispiel #14
0
def CalcularOndulacion(PuntoGeodesico, tipo='bilineal'):
    '''!
    \brief Función para calcular la ondulación del geoide con el modelo EGM08 del IGN.
    \param PuntoGeodesico PuntoGeodesico: Punto geodesico de cálculo:
    \param tipo str: Tipo de interpolación que realizara. bilineal distancia.
    '''
    if tipo != 'bilineal' and tipo != 'bicubica' and tipo != 'distancia':
        raise Exception(
            "La interpolación de la ondulación ha de ser de tipo bilineal o bicubica."
        )
    # Conexión a las bases de datos existentes.
    rutafil, file = split(realpath(__file__))
    #print(rutafil)
    db1 = DB.SQLiteManager(rutafil + '/EGM_Peninsula.db')
    db2 = DB.SQLiteManager(rutafil + '/EGM_Canarias.db')
    # comprobar si el punto introducido puede ser calculado.
    lat = PuntoGeodesico.getLatitud()
    lon = PuntoGeodesico.getLongitud()

    vals1 = db1.ObtenerTodo('Cabecera')
    #print(vals1)
    lat1 = vals1[0][0]
    lon1 = vals1[0][1]
    ilat1 = vals1[0][2]
    ilon1 = vals1[0][3]
    fil1 = vals1[0][4]
    col1 = vals1[0][5]
    Alat = ilat1 * fil1
    Alon = ilon1 * col1
    lat1f = lat1 - Alat
    lon1f = lon1 + Alon
    if lon1f >= 360:
        lon1f -= 360
    #print(Alat,Alon,lat1f,lon1f)

    vals2 = db2.ObtenerTodo('Cabecera')
    #print(vals2)
    lat2 = vals2[0][0]
    lon2 = vals2[0][1]
    ilat2 = vals2[0][2]
    ilon2 = vals2[0][3]
    fil2 = vals2[0][4]
    col2 = vals2[0][5]
    Alat = ilat2 * fil2
    Alon = ilon2 * col2
    lat2f = lat2 - Alat
    lon2f = lon2 + Alon
    if lon2f >= 360:
        lon2f -= 360
    #print(Alat,Alon,lat2f,lon2f)

    lonaux = lon
    if lon < 0:
        lonaux = lon + 360

#     print(lonaux)

    incfil = 0
    inccol = 0
    onds1 = None
    onds2 = None
    onds3 = None
    onds4 = None
    lat_calc = 0
    lon_calc = 0

    if (lat < lat1 and lat > lat1f):
        # Si el punto de cálculo está en la peninsula y al oeste de greenwhich
        if lonaux < 360 and lonaux > lon1:
            #print('Peninsula')
            diflat = lat1 - lat
            diflon = lonaux - lon1
            incfil = int(diflat / ilat1)
            inccol = int(diflon / ilon1)

            if tipo == 'bilineal' or 'distancia':
                onds1 = db1.ObtenerFila('Ondulaciones', str(incfil))
                onds2 = db1.ObtenerFila('Ondulaciones', str(incfil + 1))
            elif tipo == 'bicubica':
                onds1 = db1.ObtenerFila('Ondulaciones', str(incfil - 1))
                onds2 = db1.ObtenerFila('Ondulaciones', str(incfil))
                onds3 = db1.ObtenerFila('Ondulaciones', str(incfil + 1))
                onds4 = db1.ObtenerFila('Ondulaciones', str(incfil + 2))
            lat_calc = lat1 - ilat1 * incfil
            lon_calc = lon1 + ilon1 * inccol
            if lon_calc >= 360:
                lon_calc -= 360
        elif lonaux >= 0 and lonaux < lon1f:
            # Si el punto de cálculo está en la peninsula y al este de greenwhich
            #print('Peninsula')
            diflat = lat1 - lat
            diflon = (360 - lon1) + lonaux
            incfil = int(diflat / ilat1)
            inccol = int(diflon / ilon1)

            if tipo == 'bilineal' or 'distancia':
                onds1 = db1.ObtenerFila('Ondulaciones', str(incfil))
                onds2 = db1.ObtenerFila('Ondulaciones', str(incfil + 1))
            elif tipo == 'bicubica':
                onds1 = db1.ObtenerFila('Ondulaciones', str(incfil - 1))
                onds2 = db1.ObtenerFila('Ondulaciones', str(incfil))
                onds3 = db1.ObtenerFila('Ondulaciones', str(incfil + 1))
                onds4 = db1.ObtenerFila('Ondulaciones', str(incfil + 2))
            lat_calc = lat1 - ilat1 * incfil
            lon_calc = lon1 + ilon1 * inccol
            if lon_calc >= 360:
                lon_calc -= 360
    elif (lat < lat2 and lat > lat2f) and (lonaux > lon2 and lonaux < lon2f):
        #Si el punto está en las canarias.
        #print('Canarias')
        diflat = lat2 - lat
        diflon = lonaux - lon2
        incfil = int(diflat / ilat2)
        inccol = int(diflon / ilon2)

        if tipo == 'bilineal':
            onds1 = db1.ObtenerFila('Ondulaciones', str(incfil))
            onds2 = db1.ObtenerFila('Ondulaciones', str(incfil + 1))
        elif tipo == 'bicubica':
            onds1 = db1.ObtenerFila('Ondulaciones', str(incfil - 1))
            onds2 = db1.ObtenerFila('Ondulaciones', str(incfil))
            onds3 = db1.ObtenerFila('Ondulaciones', str(incfil + 1))
            onds4 = db1.ObtenerFila('Ondulaciones', str(incfil + 2))
        lat_calc = lat2 - ilat2 * incfil
        lon_calc = lon2 + ilon2 * inccol
        if lon_calc >= 360:
            lon_calc -= 360
    else:
        #Se devuelve None ya que no se pyede calcular con estas bases de datos.
        #Se puede añadir un elipsoide global para estos casos.
        #print('No valido')
        return None


#     print(onds1)
#     print(onds2)
    if tipo == 'bilineal':
        ond0 = onds1[0][inccol + 1]
        ond1 = onds1[0][inccol]
        ond2 = onds2[0][inccol + 1]
        ond3 = onds2[0][inccol]

        Alat = abs(lat_calc - lat)
        Alon = abs(lon_calc - lonaux)

        v1 = ond0 * Alon * Alat
        v2 = ond1 * (ilon1 - Alon) * Alat
        v3 = ond2 * Alon * (ilat1 - Alat)
        v4 = ond3 * (ilon1 - Alon) * (ilat1 - Alat)
        #print(v1,v2,v3,v4)
        return (v1 + v2 + v3 + v4) / (ilon1 * ilat1)

    elif tipo == 'distancia':
        ond0 = onds1[0][inccol + 1]
        ond1 = onds1[0][inccol]
        ond2 = onds2[0][inccol + 1]
        ond3 = onds2[0][inccol]
        import Geodesia.PIGeodesia as pigeo
        #print(PuntoGeodesico.getLongitud(),lon_calc)

        p = pigeo.PIGeodesia(
            pgeo.PuntoGeodesico(PuntoGeodesico.getLatitud(), lonaux),
            pgeo.PuntoGeodesico(lat_calc, lon_calc))
        az, dr1 = p.CalcularBessel('GRS 1980')

        p = pigeo.PIGeodesia(
            pgeo.PuntoGeodesico(PuntoGeodesico.getLatitud(), lonaux),
            pgeo.PuntoGeodesico(lat_calc, lon_calc + ilon1))
        az, dr2 = p.CalcularBessel('GRS 1980')

        p = pigeo.PIGeodesia(
            pgeo.PuntoGeodesico(PuntoGeodesico.getLatitud(), lonaux),
            pgeo.PuntoGeodesico(lat_calc + ilat1, lon_calc))
        az, dr3 = p.CalcularBessel('GRS 1980')

        p = pigeo.PIGeodesia(
            pgeo.PuntoGeodesico(PuntoGeodesico.getLatitud(), lonaux),
            pgeo.PuntoGeodesico(lat_calc + ilat1, lon_calc + ilon1))
        az, dr4 = p.CalcularBessel('GRS 1980')

        az = None
        print((dr1 * ond1 + dr2 * ond0 + dr3 * ond3 + dr4 * ond2) /
              (dr1 + dr2 + dr3 + dr4))
        print(dr1, dr2, dr3, dr4)
        pass
def main():
    p=pgeo.PuntoGeodesico(40,-1)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(40,-1.1)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(40,-0.9)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(40.1,-1)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(39.9,-1)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(40,-1.111)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(40,-0.999)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(40.111,-1)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(39.999,-1)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(39.999,-1.111)
    print(CalcularOndulacion(p))
    p=pgeo.PuntoGeodesico(39.999,-0.999)
    print(CalcularOndulacion(p))
Beispiel #16
0
def UTM2Geo(PuntoUTM, NombreElipsoide):
    '''!
    @brief: Método que convierte coordenadas UTM a coordenadas geodeésicas elipsoidales.
    @param PuntoUTM PuntoUTM: Punto con las Coordenadas UTM.
    @param NombreElipsoide str: Nombre del elipsoide de calculo.                           
    @return PuntoGeodesico: PuntoGeodesico con las coordenadas transfromadas.
    '''
    #     print(type(PuntoUTM))
    #     print(putm.PuntoUTM.__class__)
    if not isinstance(PuntoUTM.__class__, putm.PuntoUTM.__class__):
        raise Exception("Valor Punto UTM.")

    try:
        NombreElipsoide = str(NombreElipsoide)
    except:
        raise Exception("Valor Nombre Elipsoide")

    x = PuntoUTM.getX()
    y = PuntoUTM.getY()
    helip = PuntoUTM.getAlturaElipsoidal()
    posY = PuntoUTM.getHemisferioY()
    Huso = PuntoUTM.getHuso()

    Elipsoide = Elip.Elipsoides(NombreElipsoide)
    a = Elipsoide.getSemiEjeMayor()
    e = Elipsoide.getPrimeraExcentricidad()
    e2 = Elipsoide.getSegundaExcentricidad()
    #Calculos auxiliares.
    if posY is "S":
        y = 10000000.0 - y

    x = (x - 500000.0) / 0.9996
    y = y / 0.9996

    #Calculo iterativo de la latitud auxiliar.
    Lat = (y) / (a * (1 - (e**2)))
    Latsig = 0.0
    cont = 0
    while abs(Lat - Latsig) > 0.000000000001:
        if cont != 0:
            Lat = Latsig

        s1 = sin(Lat)
        s3 = (s1**3)
        s5 = (s1**5)
        s7 = (s1**7)
        s9 = (s1**9)
        c1 = cos(Lat)
        g2 = 1.5 * (e**2) * ((-0.5 * s1 * c1) + 0.5 * Lat)
        g3 = (15.0 / 8.0) * (e**4) * ((-0.25 * s3 * c1) -
                                      ((3.0 / 8.0) * s1 * c1) +
                                      ((3.0 / 8.0) * Lat))
        g4 = (35.0 / 16.0) * (e**6) * ((-(1.0 / 6.0) * s5 * c1) -
                                       ((5.0 / 24.0) * s3 * c1) -
                                       ((5.0 / 16.0) * s1 * c1) +
                                       ((5.0 / 16.0) * Lat))
        g5 = (315.0 / 128.0) * (e**8) * ((-(1.0 / 8.0) * s7 * c1) -
                                         ((7.0 / 48.0) * s5 * c1) -
                                         ((35.0 / 192.0) * s3 * c1) -
                                         ((35.0 / 128.0) * s1 * c1) +
                                         ((35.0 / 128.0) * Lat))
        g6 = (693.0 / 256.0) * (e**10) * ((-(1.0 / 10.0) * s9 * c1) -
                                          ((9.0 / 80.0) * s7 * c1) -
                                          ((21.0 / 160.0) * s5 * c1) -
                                          ((21.0 / 128.0) * s3 * c1) -
                                          ((63.0 / 256.0) * s1 * c1) +
                                          ((63.0 / 256.0) * Lat))
        Latsig = (y) / (a * (1 - (e**2))) - (g2 + g3 + g4 + g5 + g6)
        cont += 1

    #Valores Auxiliares
    t = tan(Latsig)
    t2 = (t**2)
    t4 = (t**4)
    t6 = (t**6)
    t8 = (t**8)
    n2 = ((e2**2)) * ((cos(Latsig)**2))
    n4 = (n2**2)
    n6 = (n2**3)
    n8 = (n2**4)
    n10 = (n2**5)
    n12 = (n2**6)
    n14 = (n2**7)
    #Claculo de las series de terminos.
    #Calculo del incremento de longitud.
    #x cubo.
    x3 = (1.0 + 2.0 * t2 + n2)
    #x quinta.
    x5 = (5.0 + 28.0 * t2 + 24.0 * t4 + 6.0 * n2 + 8.0 * n2 * t2 - 3.0 * n4 +
          4.0 * n4 * t2 - 4.0 * n6 + 24.0 * n6 * t2)
    #x septima.
    x7 = (61.0 + 662.0 * t2 + 1320.0 * t4 + 720.0 * t6 + 107.0 * n2 +
          440.0 * n2 * t2 + 336.0 * n2 * t4 + 43.0 * n4 - 234.0 * n4 * t2 -
          192.0 * n4 * t4 + 97.0 * n6 - 772.0 * n6 * t2 + 408.0 * n6 * t4 +
          188.0 * n8 - 2392.0 * n8 * t2 + 1536.0 * n8 * t4 + 88.0 * n10 -
          1632.0 * n10 * t2 + 1920.0 * n10 * t4)
    #x novena.
    x9 = (1385.0 + 24568.0 * t2 + 83664.0 * t4 + 100800.0 * t6 + 40320.0 * t8 +
          3116.0 * n2 + 26736.0 * n2 * t2 + 47808.0 * n2 * t4 +
          24192.0 * n2 * t6 + 1158.0 * n4 - 4884.0 * n4 * t2 -
          20736.0 * n4 * t4 - 13824.0 * n4 * t6 - 3500.0 * n6 +
          27104.0 * n6 * t2 + 576.0 * n6 * t4 + 12192.0 * n6 * t6 -
          11735.0 * n8 + 44788.0 * n8 * t2 - 195984.0 * n8 * t4 +
          9788.0 * n8 * t6 - 20280.0 * n10 + 459312.0 * n12 * t2 -
          1239552.0 * n12 * t4 + 437760.0 * n12 * t6 - 4672.0 * n14 +
          175680.0 * n14 * t2 - 603648.0 * n14 * t4 + 322560.0 * n14 * t6)
    nhu = Rad.RadiosDeCurvatura(NombreElipsoide).getRadioPrimerVertical(Latsig)
    c1 = cos(Latsig)
    Alon = (x / (nhu * c1)) - (((x**3) / (6.0 * (nhu**3) * c1)) * x3) + ((
        (x**5) / (120.0 * (nhu**5) * c1)) * x5) - ((
            (x**7) / (5040.0 * (nhu**7) * c1)) * x7) + (((x**9) /
                                                         (362880.0 *
                                                          (nhu**9) * c1)) * x9)

    lon0 = ang.Angulo((Huso * 6) - 183, formato='longitud180')
    lon0.Convertir('radian')
    Lon = lon0.getAngulo() + Alon
    #Calculo de la Latitud.
    #x cuadrado.
    x2 = (1.0 + n2)
    #x cuarta.
    x4 = (5.0 + 3.0 * t2 + 6.0 * n2 - 6.0 * n2 * t2 - 3.0 * n4 -
          9.0 * n4 * t2 - 4.0 * n6)
    #x sexta.
    x6 = (61.0 + 90.0 * t2 + 45.0 * t4 + 107.0 * n2 - 162.0 * n2 * t2 -
          45.0 * n2 * t4 + 43.0 * n4 - 318.0 * n4 * t2 + 135.0 * n4 * t4 +
          97.0 * n6 + 18.0 * n6 * t2 + 225.0 * n6 * t4)
    #x octava.
    x8 = (1385.0 + 3633.0 * t2 + 4515.0 * t4 + 2310.0 * t4 + 3116.0 * n2 -
          5748.0 * n2 * t2 + 4704.0 * n2 * t4 - 525.0 * n2 * t6 + 1158.0 * n4 -
          17826.0 * n4 * t2 + 37734.0 * n4 * t4 - 9450.0 * n4 * t6 -
          3500.0 * n6 + 1164.0 * n6 * t2 + 14006.0 * n6 * t4 -
          20790.0 * n6 * t6 - 11735.0 * n8 + 29001.0 * n8 * t2 +
          13389.0 * n8 * t4 - 45.0 * n8 * t6 - 20280.0 * n10 +
          64272.0 * n10 * t2 - 15864.0 * n10 * t4 - 16144.0 * n12 +
          75408.0 * n12 * t2 - 31872.0 * n12 * t4 - 4672.0 * n14 +
          30528.0 * n14 * t2 - 23040.0 * n14 * t4)

    Lats = Latsig + (((-(x**2) / (2.0 * (nhu**2))) * t * x2) +
                     ((((x**4) / (24.0 * (nhu**4))) * t * x4)) -
                     ((((x**6) / (720.0 * (nhu**6))) * t * x6)) +
                     ((((-x**8) / (40320.0 * (nhu**8))) * t * x8)))

    #Cálculo de la convergencia de meridianos.
    #coeficientes.
    s1 = sin(Lats)
    c1 = cos(Lats)
    c2 = (c1**2)
    c4 = (c1**4)
    c6 = (c1**6)
    t = tan(Lats)
    t2 = (t**2)
    t4 = (t**4)
    t6 = (t**6)
    t8 = (t**8)
    n2 = ((e2**2)) * ((cos(Lats)**2))
    n4 = (n2**2)
    n6 = (n2**3)
    n8 = (n2**4)
    n10 = (n2**5)
    n12 = (n2**6)
    n14 = (n2**7)
    m3 = (1.0 + 3.0 * n2 + 2 * n4)
    m5 = (2.0 - t2 + 15.0 * n2 * t2 + 35.0 * n4 - 50.0 * n4 * t2 + 33.0 * n6 -
          60.0 * n6 * t2 + 11.0 * n8 - 24.0 * n8 * t2)
    m7 = (-148.0 - 3427.0 * t2 + 18.0 * t4 - 1387.0 * t6 + 2023.0 * n2 -
          46116.0 * n2 * t2 + 5166.0 * n2 * t4 + 18984.0 * n4 -
          100212.0 * n4 * t4 + 34783 * n6 - 219968.0 * n6 * t2 +
          144900.0 * n6 * t4 + 36180.0 * n8 - 261508.0 * n8 * t2 +
          155904.0 * n8 * t4 + 18472.0 * n10 - 114528.0 * n10 * t2 +
          94080.0 * n10 * t4 + 4672.0 * n12 - 30528.0 * n12 * t2 +
          23040.0 * n12 * t4)
    convmed = (Alon * s1) + (((Alon**3) / 3.0) * s1 * c2 * m3) + ((
        (Alon**5) / 15.0) * s1 * c4 * m5) + ((
            (Alon**7) / 5040.0) * s1 * c6 * m7)
    convmed = ang.Angulo(convmed, formato='radian')
    convmed.Convertir('pseudosexagesimal')
    convmed = convmed.getAngulo()
    #Calculo de la escala local del punto.
    #coeficientes.
    k2 = (1 + n2)
    k4 = (5.0 - 4.0 * t2 + 14.0 * n2 - 28.0 * n2 * t2 + 13.0 * n4 -
          48.0 * n4 * t2 + 4.0 * n6 - 24.0 * n6 * t2)
    k6 = (61.0 + 10636.0 * t2 - 9136.0 * t4 + 224.0 * t6 + 331.0 * n2 +
          44432.0 * n2 * t2 - 50058.0 * n2 * t4 - 715.0 * n4 +
          68100.0 * n4 * t2 - 95680.0 * n4 * t4 + 769.0 * n6 +
          43816.0 * n6 * t2 - 80160.0 * n6 * t4 + 412.0 * n8 +
          9644.0 * n8 * t2 - 21888.0 * n8 * t4 + 88.0 * n10 -
          1632.0 * n10 * t2 + 1920.0 * n10 * t4)
    kp = (0.9996) * (1 + (0.5 * (Alon**2) * c2 * k2) +
                     (((Alon**4) / 24.0) * c4 * k4) +
                     (((Alon**6) / 720.0) * c6 * k6))
    #kp=sqrt(kp)

    Lats = ang.Angulo(Lats, formato='radian')
    Lats.Convertir('latitud')
    Lats = Lats.getAngulo()

    Lon = ang.Angulo(Lon, formato='radian')
    Lon.Convertir('longitud180')
    Lon = Lon.getAngulo()

    p1 = pgeo.PuntoGeodesico(Lats, Lon, helip)
    PuntoUTM.setConvergenciaMeridianos(convmed)
    PuntoUTM.setEscalaLocalPunto(kp)

    return p1