Пример #1
0
    def others(self, other, name='other'):
        '''Refine the class comparison.

           @param other: The other point (C{LatLon}).
           @keyword name: Optional, other's name (C{str}).

           @raise TypeError: Incompatible B{C{other}} C{type}.
        '''
        try:
            LatLonHeightBase.others(self, other, name=name)
        except TypeError:
            if not isinstance(other, Nvector):
                raise
Пример #2
0
    def others(self, other, name='other'):
        '''Refine class comparison.

           @param other: The other point (L{LatLon}).
           @keyword name: Other's name (string).

           @raise TypeError: Incompatible type(other).
        '''
        try:
            LatLonHeightBase.others(self, other, name=name)
        except TypeError:
            if not isinstance(other, Nvector):
                raise
Пример #3
0
    def __init__(self, lat, lon, height=0, datum=None):
        '''Create an (ellipsoidal) LatLon point frome the given
           lat-, longitude and height (elevation, altitude) on
           a given datum.

           @param lat: Latitude (degrees or DMS string with N or S suffix).
           @param lon: Longitude (degrees or DMS string with E or W suffix).
           @keyword height: Elevation (meter or the same units as datum's half-axes).
           @keyword datum: Datum to use (L{Datum}).

           @example:

           >>> p = LatLon(51.4778, -0.0016)  # height=0, datum=Datums.WGS84
        '''
        LatLonHeightBase.__init__(self, lat, lon, height=height)
        if datum:  # check datum
            self.datum = datum
Пример #4
0
    def copy(self):
        '''Copy this I{LatLon} point.

           @return: Copy of this point (L{LatLonEllipsoidalBase}).
        '''
        p = LatLonHeightBase.copy(self)
        assert hasattr(p, 'datum')
        p.datum = self.datum
        return p
Пример #5
0
    def __init__(self, lat, lon, height=0, datum=None, name=''):
        '''Create an (ellipsoidal) C{LatLon} point frome the given
           lat-, longitude and height on the given datum.

           @param lat: Latitude (C{degrees} or DMS C{[N|S]}).
           @param lon: Longitude (C{degrees} or DMS C{str[E|W]}).
           @keyword height: Optional elevation (C{meter}, the same units
                            as the datum's half-axes).
           @keyword datum: Optional datum to use (L{Datum}).
           @keyword name: Optional name (string).

           @example:

           >>> p = LatLon(51.4778, -0.0016)  # height=0, datum=Datums.WGS84
        '''
        LatLonHeightBase.__init__(self, lat, lon, height=height, name=name)
        if datum:  # check datum
            self.datum = datum
Пример #6
0
    def to4xyzh(self):
        '''Convert this (geodetic) point to n-vector (normal
           to the earth's surface) x/y/z components and height.

           @return: 4-Tuple (x, y, z, h) in (meter).
        '''
        # Kenneth Gade eqn (3), but using right-handed
        # vector x -> 0°E,0°N, y -> 90°E,0°N, z -> 90°N
        #       a, b = self.to2ab()
        #       ca = cos(a)
        #       x, y, z = ca * cos(b), ca * sin(b), sin(a)
        return LatLonHeightBase.to3xyz(self) + (self.height, )
Пример #7
0
    def antipode(self, height=None):
        '''Return the antipode, the point diametrically opposite
           to this point.

           @keyword height: Optional height of the antipode, height
                            of this point otherwise (meter).

           @return: The antipodal point (I{LatLon}).
        '''
        lla = LatLonHeightBase.antipode(self, height=height)
        if lla.datum != self.datum:
            lla.datum = self.datum
        return lla
Пример #8
0
    def to4xyzh(self):
        '''Convert this (geodetic) point to n-vector (normal
           to the earth's surface) x/y/z components and height.

           @return: 4-Tuple (x, y, z, h) in (C{meter}).
        '''
        # Kenneth Gade eqn (3), but using right-handed
        # vector x -> 0°E,0°N, y -> 90°E,0°N, z -> 90°N
        #       a, b = self.to2ab()
        #       sa, ca, sb, cb = sincos2(a, b)
        #       x, y, z = ca * cb, ca * sb, sa
        # XXX don't use self.to3xyz() + ....
        return LatLonHeightBase.to3xyz(self) + (self.height, )
Пример #9
0
    def __init__(self,
                 lat,
                 lon,
                 height=0,
                 datum=None,
                 reframe=None,
                 epoch=None,
                 name=''):
        '''Create an (ellipsoidal) C{LatLon} point frome the given
           lat-, longitude and height on the given datum and with
           the given reference frame and epoch.

           @param lat: Latitude (C{degrees} or DMS C{[N|S]}).
           @param lon: Longitude (C{degrees} or DMS C{str[E|W]}).
           @keyword height: Optional elevation (C{meter}, the same units
                            as the datum's half-axes).
           @keyword datum: Optional datum to use (L{Datum}).
           @keyword reframe: Optional reference frame (L{RefFrame}).
           @keyword epoch: Optional epoch to observe for B{C{reframe}}
                           (C{scalar}), a non-zero, fractional calendar
                           year.
           @keyword name: Optional name (string).

           @raise TypeError: B{C{datum}} is not a L{datum}, B{C{reframe}}
                             is not a L{RefFrame} or B{C{epoch}} is not
                             C{scalar} non-zero.

           @example:

           >>> p = LatLon(51.4778, -0.0016)  # height=0, datum=Datums.WGS84
        '''
        LatLonHeightBase.__init__(self, lat, lon, height=height, name=name)
        if datum:
            self.datum = datum
        if reframe:
            self.reframe = reframe
            self.epoch = epoch
Пример #10
0
    def to4xyzh(self, h=None):
        '''Convert this (geodetic) point to n-vector (normal
           to the earth's surface) x/y/z components and height.

           @keyword h: Optional height, overriding this point's
                       height (C{meter}).

           @return: A L{Vector4Tuple}C{(x, y, z, h)}, all in
                    (C{meter}).
        '''
        # Kenneth Gade eqn (3), but using right-handed
        # vector x -> 0°E,0°N, y -> 90°E,0°N, z -> 90°N
        #       a, b = self.to2ab()
        #       sa, ca, sb, cb = sincos2(a, b)
        #       x, y, z = ca * cb, ca * sb, sa
        # XXX don't use self.to3xyz() + ....
        x, y, z = LatLonHeightBase.to3xyz(self)
        r = Vector4Tuple(x, y, z, self.height if h is None else h)
        return self._xnamed(r)
Пример #11
0
 def _update(self, updated):
     if updated:  # reset caches
         self._osgr = self._utm = self._wm = None
         LatLonHeightBase._update(self, updated)
Пример #12
0
 def _xcopy(self, *attrs):
     '''(INTERNAL) Make copy with add'l, subclass attributes.
     '''
     return LatLonHeightBase._xcopy(self, '_datum', '_epoch', '_reframe',
                                    *attrs)
Пример #13
0
 def _update(self, updated):
     if updated:  # reset caches
         self._etm = self._lcc = self._osgr = self._ups = \
                     self._utm = self._wm = self._3xyz = None
         self._elevation2 = self._geoidHeight2 = ()
         LatLonHeightBase._update(self, updated)