Exemple #1
0
def _xUnit(units, Base):  # in .frechet,  .hausdorff
    '''(INTERNAL) Get C{Unit} from C{Unit} or C{name}, ortherwise C{Base}.
    '''
    if not issubclassof(Base, _NamedUnit):
        raise _IsnotError(_NamedUnit.__name__, Base=Base)
    U = globals().get(units.capitalize(), Base) if isstr(units) else (
        units if issubclassof(units, Base) else Base)
    return U if issubclassof(U, Base) else Base
Exemple #2
0
def _Equidistant2(equidistant, datum):
    # (INTERNAL) Get an C{Equidistant} or C{EquidistantKarney} instance
    import pygeodesy.azimuthal as _az

    if equidistant is None or not callable(equidistant):
        equidistant = _az.equidistant
    elif not (issubclassof(equidistant, _az.Equidistant)
              or issubclassof(equidistant, _az.EquidistantKarney)):
        raise _IsnotError(_az.Equidistant.__name__,
                          _az.EquidistantKarney.__name__,
                          equidistant=equidistant)
    return equidistant(0, 0, datum)
Exemple #3
0
    def toLatLon(self, LatLon, datum=None, **LatLon_kwds):
        '''Convert this WM coordinate to a geodetic point.

           @arg LatLon: Ellipsoidal class to return the geodetic
                        point (C{LatLon}).
           @kwarg datum: Optional datum for ellipsoidal or C{None}
                         for spherical B{C{LatLon}} (C{Datum}).
           @kwarg LatLon_kwds: Optional, additional B{C{LatLon}}
                               keyword arguments.

           @return: Point of this WM coordinate (B{C{LatLon}}).

           @raise TypeError: If B{C{LatLon}} and B{C{datum}} are
                             incompatible or if B{C{datum}} is
                             invalid or not ellipsoidal.

           @example:

           >>> w = Wm(448251.795, 5411932.678)
           >>> from pygeodesy import sphericalTrigonometry as sT
           >>> ll = w.toLatLon(sT.LatLon)  # 43°39′11.58″N, 004°01′36.17″E
        '''
        e = issubclassof(LatLon, _LLEB)
        if e and datum:
            kwds = _xkwds(LatLon_kwds, datum=datum)
        elif not (e or datum):  # and LatLon
            kwds = LatLon_kwds
            datum = None
        else:
            raise _TypeError(LatLon=LatLon, datum=datum)

        r = self.latlon2(datum=datum)
        r = LatLon(r.lat, r.lon, **kwds)
        return self._xnamed(r)
Exemple #4
0
def _xUnits(units, Base=_NamedUnit):  # in .frechet, .hausdorff
    '''(INTERNAL) Set property C{units} as C{Unit} or C{Str}.
    '''
    if not issubclassof(Base, _NamedUnit):
        raise _IsnotError(_NamedUnit.__name__, Base=Base)
    elif issubclassof(units, Base):
        return units
    elif isstr(units):
        return Str(
            units,
            name=_units_)  # XXX Str to _Pass and for backward compatibility
    else:
        raise _IsnotError(Base.__name__,
                          Str.__name__,
                          str.__name__,
                          units=units)
Exemple #5
0
 def _xtend(self, NamedTuple, *items):
     '''(INTERNAL) Extend this C{_Tuple} with C{items} to an other C{NamedTuple}.
     '''
     if not (issubclassof(NamedTuple, _NamedTuple) and
             (len(self._Names_) + len(items)) == len(NamedTuple._Names_)
             and self._Names_ == NamedTuple._Names_[:len(self)]):
         raise TypeError('%s%r vs %s%r' %
                         (self.classname, self._Names_, NamedTuple.__name__,
                          NamedTuple._Names_))
     return self._xnamed(NamedTuple(*(self + items)))
Exemple #6
0
 def _xtend(self, xTuple, *items):
     '''(INTERNAL) Extend this C{Named-Tuple} with C{items} to an other B{C{xTuple}}.
     '''
     if not (issubclassof(xTuple, _NamedTuple) and
             (len(self._Names_) + len(items)) == len(xTuple._Names_)
             and self._Names_ == xTuple._Names_[:len(self)]):
         c = NN(self.classname, repr(self._Names_))
         x = NN(xTuple.__name__, repr(xTuple._Names_))
         raise TypeError(_SPACE_(c, _vs_, x))
     return self._xnamed(xTuple(*(self + items)))