Exemplo n.º 1
0
    def convertRefFrame(self, reframe2, reframe, epoch=None):
        '''Convert this Cartesian point from one to an other reference frame.

           @param reframe2: Reference frame to convert I{to} (L{RefFrame}).
           @param reframe: Reference frame to convert I{from} (L{RefFrame}).
           @keyword epoch: Optional epoch to observe for B{C{reframe}}, a
                           fractional calendar year (C{scalar}).

           @return: The converted Cartesian point (C{Cartesian}) or
                    this Cartesian point if conversion is C{nil}.

           @raise TRFError: No conversion available from
                                 B{C{reframe}} to B{C{reframe2}}.

           @raise TypeError: B{C{reframe2}} or B{C{reframe}} not a
                             L{RefFrame} or B{C{epoch}} not C{scalar}.
        '''
        _TypeError(RefFrame, reframe2=reframe2, reframe=reframe)

        c = self
        for t in _reframeTransforms(
                reframe2, reframe,
                reframe.epoch if epoch is None else _2epoch(epoch)):
            c = c._applyHelmert(t, False)
        return c
Exemplo n.º 2
0
    def convertRefFrame(self, reframe2, reframe, epoch=None):
        '''Convert this cartesian point from one to an other reference frame.

           @arg reframe2: Reference frame to convert I{to} (L{RefFrame}).
           @arg reframe: Reference frame to convert I{from} (L{RefFrame}).
           @kwarg epoch: Optional epoch to observe for B{C{reframe}}, a
                         fractional calendar year (C{scalar}).

           @return: The converted point (C{Cartesian}) or this point if
                    conversion is C{nil}.

           @raise TRFError: No conversion available from B{C{reframe}}
                            to B{C{reframe2}}.

           @raise TypeError: B{C{reframe2}} or B{C{reframe}} not a
                             L{RefFrame} or B{C{epoch}} not C{scalar}.
        '''
        from pygeodesy.trf import RefFrame, _reframeTransforms
        _xinstanceof(RefFrame, reframe2=reframe2, reframe=reframe)

        c, d = self, self.datum
        for t in _reframeTransforms(
                reframe2, reframe,
                reframe.epoch if epoch is None else Epoch(epoch)):
            c = c._applyHelmert(t, False, datum=d)
        return c
    def convertRefFrame(self, reframe2):
        '''Convert this point to an other reference frame.

           @param reframe2: Reference frame to convert I{to} (L{RefFrame}).

           @return: The converted point (ellipsoidal C{LatLon}) or
                    this point if conversion is C{nil}.

           @raise TRFError: No B{C{.reframe}} or no conversion
                            available from B{C{.reframe}} to
                            B{C{reframe2}}.

           @raise TypeError: The B{C{reframe2}} is not a L{RefFrame}.

           @example:

           >>> p = LatLon(51.4778, -0.0016, reframe=RefFrames.ETRF2000)  # default Datums.WGS84
           >>> p.convertRefFrame(RefFrames.ITRF2014)  # 51.477803°N, 000.001597°W, +0.01m
        '''
        _TypeError(RefFrame, reframe2=reframe2)

        if not self.reframe:
            raise TRFError('no %r.%s' % (self, 'reframe'))

        ts = _reframeTransforms(reframe2, self.reframe, self.epoch)
        if ts:
            c = self.toCartesian()
            for t in ts:
                c = c._applyHelmert(t, False)
            ll = c.toLatLon(datum=self.datum, LatLon=self.classof,
                            epoch=self.epoch, reframe=reframe2)
            # ll.reframe, ll.epoch = reframe2, self.epoch
        else:
            ll = self
        return ll
Exemplo n.º 4
0
    def convertRefFrame(self, reframe2):
        '''Convert this point to an other reference frame.

           @arg reframe2: Reference frame to convert I{to} (L{RefFrame}).

           @return: The converted point (ellipsoidal C{LatLon}) or
                    this point if conversion is C{nil}.

           @raise TRFError: No B{C{.reframe}} or no conversion
                            available from B{C{.reframe}} to
                            B{C{reframe2}}.

           @raise TypeError: The B{C{reframe2}} is not a L{RefFrame}.

           @example:

           >>> p = LatLon(51.4778, -0.0016, reframe=RefFrames.ETRF2000)  # default Datums.WGS84
           >>> p.convertRefFrame(RefFrames.ITRF2014)  # 51.477803°N, 000.001597°W, +0.01m
        '''
        from pygeodesy.trf import RefFrame, _reframeTransforms
        _xinstanceof(RefFrame, reframe2=reframe2)

        if not self.reframe:
            t = _SPACE_(_DOT_(repr(self), 'reframe'), MISSING)
            raise TRFError(_no_(_conversion_), txt=t)

        ts = _reframeTransforms(reframe2, self.reframe, self.epoch)
        if ts:
            c = self.toCartesian()
            for t in ts:
                c = c._applyHelmert(t, False)
            ll = c.toLatLon(datum=self.datum,
                            LatLon=self.classof,
                            epoch=self.epoch,
                            reframe=reframe2)
            # ll.reframe, ll.epoch = reframe2, self.epoch
        else:
            ll = self
        return ll