Beispiel #1
0
def mga2020_to_mga94(zone, east, north, ell_ht=False, vcv=None):
    """
    Performs conformal transformation of Map Grid of Australia 2020 to Map Grid of Australia 1994 Coordinates
    using the reverse form of the GDA2020 Tech Manual v1.2 7 parameter similarity transformation parameters
    :param zone: Zone Number - 1 to 60
    :param east: Easting (m, within 3330km of Central Meridian)
    :param north: Northing (m, 0 to 10,000,000m)
    :param ell_ht: Ellipsoid Height (m) (optional)
    :param vcv: Optional 3*3 numpy array in local enu units to propagate tf uncertainty
    :return: MGA1994 Zone, Easting, Northing, Ellipsoid Height (if none provided, returns 0), and vcv matrix
    """
    lat, lon, psf, gridconv = grid2geo(zone, east, north)
    if ell_ht is False:
        ell_ht_in = 0
    else:
        ell_ht_in = ell_ht
    if vcv is not None:
        vcv = vcv_local2cart(vcv, lat, lon)
    x94, y94, z94 = llh2xyz(lat, lon, ell_ht_in)
    x20, y20, z20, vcv94 = conform7(x94, y94, z94, -gda94_to_gda2020, vcv=vcv)
    lat, lon, ell_ht_out = xyz2llh(x20, y20, z20)
    if vcv94 is not None:
        vcv94 = vcv_cart2local(vcv94, lat, lon)
    if ell_ht is False:
        ell_ht_out = 0
    hemisphere, zone20, east20, north20, psf, gridconv = geo2grid(lat, lon)
    return zone20, east20, north20, round(ell_ht_out, 4), vcv94
Beispiel #2
0
    def test_xyz2llh(self):
        abs_path = os.path.abspath(os.path.dirname(__file__))

        testdata = read_dnacoord(os.path.join(abs_path, 'resources/natadjust_rvs_example.dat'))
        for coord in testdata:
            coord.converthptodd()
            latcomp, longcomp, ell_htcomp = xyz2llh(coord.x, coord.y, coord.z)
            assert (abs(latcomp - coord.lat) < 2e-9)
            assert (abs(longcomp - coord.long) < 2e-9)
            assert (abs(ell_htcomp - coord.ell_ht) < 1e-4)
Beispiel #3
0
 def geo(self, ellipsoid=grs80, notation=DECAngle):
     """
     Convert coordinates to Geographic
     Note: If no N Value, no Orthometric Height set.
     :param ellipsoid: geodepy.constants.Ellipsoid Object (default: grs80)
     :param notation: Latitude and Longitude Angle Notation format
     :type notation: geodepy.angle class or float
     :return: Geographic Coordinate
     :rtype: CoordGeo
     """
     lat, lon, ell_ht = xyz2llh(self.xaxis, self.yaxis, self.zaxis,
                                ellipsoid)
     if notation is DECAngle:
         lat = DECAngle(lat)
         lon = DECAngle(lon)
     elif notation is HPAngle:
         lat = DECAngle(lat).hpa()
         lon = DECAngle(lon).hpa()
     elif notation is GONAngle:
         lat = DECAngle(lat).gona()
         lon = DECAngle(lon).gona()
     elif notation is DMSAngle:
         lat = DECAngle(lat).dms()
         lon = DECAngle(lon).dms()
     elif notation is DDMAngle:
         lat = DECAngle(lat).ddm()
         lon = DECAngle(lon).ddm()
     elif notation is float:
         pass  # geodepy.convert.grid2geo returns float dec degrees
     else:
         raise ValueError(
             f'CoordCart.geo() notation requires class float or'
             f' class from geodepy.angles module. '
             f'Supplied: {notation}')
     if self.nval is None:
         return CoordGeo(lat, lon, ell_ht)
     else:
         return CoordGeo(lat, lon, ell_ht, ell_ht - self.nval)
Beispiel #4
0
                if l[20:25].strip() == 'CCC':
                    apref[str(stn)] = {
                        'P': P,
                        'L': L,
                        'OHGT': H,
                        'EHGT': h,
                        'X': X,
                        'Y': Y,
                        'Z': Z
                    }
                if str(stn) == first_stn:
                    for b in xyz_bases:
                        x = X + float(xyz_bases[b]['dX'])
                        y = Y + float(xyz_bases[b]['dY'])
                        z = Z + float(xyz_bases[b]['dZ'])
                        P, L, h = xyz2llh(x, y, z)
                        ngca[str(b)] = {
                            'P': P,
                            'L': L,
                            'EHGT': h,
                            'X': x,
                            'Y': y,
                            'Z': z
                        }
            if c < 0: c += 1

    ###########################################################################
    #               Analyse vector agreement of NGCA Vs APREF                 #
    ###########################################################################
    best_sum = 0
    prev_best = 1000000000000000000
Beispiel #5
0
def gnss_xyz2dah(coords, xyz_bases):
    dah_bases = {}
    print('   Calculating baseline transformations ')
    for b in xyz_bases:
        f_x, f_y, f_z = llh2xyz(coords[xyz_bases[b]['first']]['LAT'],
                                coords[xyz_bases[b]['first']]['LON'],
                                coords[xyz_bases[b]['first']]['EHGT'])
        Calc_point_x = f_x + xyz_bases[b]['dX']
        Calc_point_y = f_y + xyz_bases[b]['dY']
        Calc_point_z = f_z + xyz_bases[b]['dZ']
        p, l, h = xyz2llh(Calc_point_x, Calc_point_y, Calc_point_z)
        e_dist, b_az, b_rev_az = vincinv(coords[xyz_bases[b]['first']]['LAT'],
                                         coords[xyz_bases[b]['first']]['LON'],
                                         p, l)
        adj_dist, adj_az, b_rev_az = vincinv(
            coords[xyz_bases[b]['first']]['LAT'],
            coords[xyz_bases[b]['first']]['LON'],
            coords[xyz_bases[b]['second']]['LAT'],
            coords[xyz_bases[b]['second']]['LON'])
        e_dist_res = adj_dist - e_dist
        b_az_res = adj_az - b_az
        e_ht_diff = h - coords[xyz_bases[b]['first']]['EHGT']
        n1 = coords[xyz_bases[b]['first']]['OHGT'] - coords[xyz_bases[b]
                                                            ['first']]['EHGT']
        n2 = coords[xyz_bases[b]['second']]['OHGT'] - coords[
            xyz_bases[b]['second']]['EHGT']
        o_ht_diff = -1 * n1 + e_ht_diff + n2
        o_ht_diff_res = (coords[xyz_bases[b]['second']]['OHGT'] -
                         coords[xyz_bases[b]['first']]['OHGT']) - o_ht_diff

        #transfor the baseline to distance, azimuth, up
        #translated code from http://peas13.dli.wa.gov.au/svn-intsvc/Delphi/GesmarComponents/trunk/Geodetic.pas
        m_lat = (coords[xyz_bases[b]['first']]['LAT'] + p) / 2
        m_x = (f_x + Calc_point_x) / 2
        m_y = (f_y + Calc_point_y) / 2

        dR = sqrt(m_x * m_x + m_y * m_y)
        dE2 = grs80.ecc1sq
        dQ = radians(m_lat)
        sinQ = sin(dQ)
        dTemp = sqrt(1.0 - dE2 * sinQ * sinQ)
        dN = grs80.semimaj / dTemp
        dM = dN * ((1.0 - dE2) / (dTemp * dTemp))
        sinQ = sin(dQ)
        cosQ = cos(dQ)
        secQ = 1.0 / cosQ
        dF = grs80.f
        dE2 = 2 * dF - (dF * dF)
        dA = m_x * tan(dQ) / (dR * dR * (dE2 - secQ * secQ))
        dB = 1.0 / (dR * secQ * secQ - dE2 * dN * cosQ)
        dC = dR * sinQ / (cosQ * cosQ) - dN * dE2 * sinQ * cosQ / (
            1.0 - dE2 * sinQ * sinQ)

        JMatrix = np.zeros([3, 3])
        JMatrix[0, 0] = dM * dA
        JMatrix[0, 1] = dM * (m_y * dA / m_x)
        JMatrix[0, 2] = dM * dB
        JMatrix[1, 0] = -(dN * cosQ) * m_y / (dR * dR)
        JMatrix[1, 1] = (dN * cosQ) * m_x / (dR * dR)
        JMatrix[1, 2] = 0.0
        JMatrix[2, 0] = m_x / (dR * cosQ) + dA * dC
        JMatrix[2, 1] = m_y / (dR * cosQ) + m_y * dA * dC / m_x
        JMatrix[2, 2] = dB * dC

        b_var_matrix = np.zeros([3, 3])
        b_var_matrix[0, 0] = xyz_bases[b]['sdev_x']**2
        b_var_matrix[1, 1] = xyz_bases[b]['sdev_y']**2
        b_var_matrix[2, 2] = xyz_bases[b]['sdev_z']**2

        b_nst_matrix = np.zeros([3, 3])
        b_nst_matrix[0, 0] = xyz_bases[b]['nstat_x']**2
        b_nst_matrix[1, 1] = xyz_bases[b]['nstat_y']**2
        b_nst_matrix[2, 2] = xyz_bases[b]['nstat_z']**2

        cosAz = cos(radians(b_az))
        sinAz = sin(radians(b_az))
        AMatrix = np.zeros([3, 3])
        AMatrix[0, 0] = cosAz
        AMatrix[0, 1] = sinAz
        if e_dist == 0:
            AMatrix[1, 0] = degrees(sinAz / 0.00001)
            AMatrix[1, 1] = -degrees(cosAz / 0.00001)
        else:
            AMatrix[1, 0] = degrees(sinAz / e_dist)
            AMatrix[1, 1] = -degrees(cosAz / e_dist)

        GMatrix = np.matmul(np.matmul(JMatrix, b_var_matrix),
                            JMatrix.transpose())
        dah_Matrix = np.matmul(np.matmul(AMatrix, GMatrix),
                               AMatrix.transpose())

        n_GMatrix = np.matmul(np.matmul(JMatrix, b_nst_matrix),
                              JMatrix.transpose())
        nstat_Matrix = np.matmul(np.matmul(AMatrix, n_GMatrix),
                                 AMatrix.transpose())

        dah_bases[b] = {
            'first': xyz_bases[b]['first'],
            'second': xyz_bases[b]['second'],
            'dX': xyz_bases[b]['dX'],
            'dY': xyz_bases[b]['dY'],
            'dZ': xyz_bases[b]['dZ'],
            'e_dist': e_dist,
            'e_dist_res': e_dist_res,
            'e_dist_sdev': sqrt(abs(dah_Matrix[0, 0])),
            'e_dist_nstat': sqrt(abs(nstat_Matrix[0, 0])),
            'b_az': b_az,
            'b_az_res': b_az_res,
            'b_az_sdev': sqrt(abs(dah_Matrix[1, 1])),
            'b_az_nstat': sqrt(abs(sin(radians(nstat_Matrix[1, 1])) * e_dist)),
            'o_ht_diff': o_ht_diff,
            'e_ht_diff': e_ht_diff,
            'o_ht_diff_res': o_ht_diff_res,
            'e_ht_diff_sdev': sqrt(abs(GMatrix[2, 2])),
            'e_ht_diff_nstat': sqrt(abs(n_GMatrix[2, 2]))
        }
    return coords, dah_bases