Ejemplo n.º 1
0
def toUtmUps8(latlon,
              lon=None,
              datum=None,
              Utm=Utm,
              Ups=Ups,
              pole='',
              name=''):
    '''Convert a lat-/longitude point to a UTM or UPS coordinate.

       @param latlon: Latitude (C{degrees}) or an (ellipsoidal)
                      geodetic C{LatLon} point.
       @keyword lon: Optional longitude (C{degrees}) or C{None}.
       @keyword datum: Optional datum to use this UTM coordinate,
                       overriding I{latlon}'s datum (C{Datum}).
       @keyword Utm: Optional (sub-)class to return the UTM coordinate
                     (L{Utm}) or C{None}.
       @keyword Ups: Optional (sub-)class to return the UPS coordinate
                     (L{Ups}) or C{None}.
       @keyword pole: Optional top/center of UPS (stereographic)
                      projection (C{str}, C{'N[orth]'} or C{'S[outh]'}).
       @keyword name: Optional name (C{str}).

       @return: The UTM or UPS coordinate (L{Utm} respectively L{Ups})
                or an 8-tuple (C{zone, hemisphere/pole, easting, northing,
                Band, datum, convergence, scale}) if I{Utm} respectively
                I{Ups} is C{None} or I{cmoff} is C{False} as (C{int,
                'N'|'S', meter, meter, str, degrees, scalar}) where C{zone}
                is C{1..60} for UTM or C{0} for UPS and C{Band} is C{""}
                or C{'C'|'D'..'W'|'X'} for UTM or C{'A'|'B'|'Y'|'Z'} for
                UPS.

       @raise RangeError: If I{lat} outside the valid UTM or UPS bands
                          or if I{lat} or I{lon} outside the valid range
                          and I{rangerrrors} set to C{True}.

       @raise TypeError: If I{latlon} is not ellipsoidal or I{lon}
                         value is missing.

       @raise UTMUPSError: UTM or UPS validation failed.

       @raise ValueError: Invalid I{lat} or I{lon}.

       @see: Functions L{toUtm8} and L{toUps8}.
    '''
    lat, lon, d, name = _to4lldn(latlon, lon, datum, name)
    z, B, p, lat, lon = utmupsZoneBand5(lat, lon)

    if z == _UPS_ZONE:
        u = toUps8(lat,
                   lon,
                   datum=d,
                   Ups=Ups,
                   pole=pole or p,
                   falsed=True,
                   name=name)
    else:
        u = toUtm8(lat, lon, datum=d, Utm=Utm, cmoff=True, name=name)
    return u
Ejemplo n.º 2
0
    def toUps(self, pole='', eps=EPS, **unused):
        '''Convert this UTM coordinate to a UPS coordinate.

           @keyword pole: Optional top/center of the UPS projection,
                          (C{str}, 'N[orth]'|'S[outh]').
           @keyword eps: Optional convergence limit, L{EPS} or above
                         (C{float}), see method L{Utm.toLatLon}.

           @return: The UPS coordinate (L{Ups}).
        '''
        u = self._ups
        if u is None or u.pole != (pole or u.pole):
            from ups import toUps8  # PYCHOK recursive import
            ll = self.toLatLon(LatLon=_LLEB, eps=eps)
            self._ups = u = toUps8(ll, pole=pole, strict=False)
        return u
Ejemplo n.º 3
0
    def toUps(self, pole='N', falsed=True):
        '''Convert this C{LatLon} point to a UPS coordinate.

           @keyword pole: Optional top/center of (stereographic)
                          projection (C{str}, 'N[orth]' or 'S[outh]').
           @keyword falsed: False easting and northing (C{bool}).

           @return: The UPS coordinate (L{Ups}).

           @see: Function L{toUps8}.
        '''
        if self._ups is None:
            from ups import toUps8, Ups  # PYCHOK recursive import
            self._ups = toUps8(self,
                               datum=self.datum,
                               Ups=Ups,
                               pole=pole,
                               falsed=falsed)
        return self._ups
Ejemplo n.º 4
0
def toUtmUps8(latlon,
              lon=None,
              datum=None,
              falsed=True,
              Utm=Utm,
              Ups=Ups,
              pole='',
              name='',
              **cmoff):
    '''Convert a lat-/longitude point to a UTM or UPS coordinate.

       @param latlon: Latitude (C{degrees}) or an (ellipsoidal)
                      geodetic C{LatLon} point.
       @keyword lon: Optional longitude (C{degrees}) or C{None}.
       @keyword datum: Optional datum to use this UTM coordinate,
                       overriding B{C{latlon}}'s datum (C{Datum}).
       @keyword falsed: False both easting and northing (C{bool}).
       @keyword Utm: Optional (sub-)class to return the UTM coordinate
                     (L{Utm}) or C{None}.
       @keyword Ups: Optional (sub-)class to return the UPS coordinate
                     (L{Ups}) or C{None}.
       @keyword pole: Optional top/center of UPS (stereographic)
                      projection (C{str}, C{'N[orth]'} or C{'S[outh]'}).
       @keyword name: Optional name (C{str}).
       @keyword cmoff: DEPRECATED, use B{C{falsed}}.  Offset longitude
                       from zone's central meridian, for UTM only (C{bool}).

       @return: The UTM or UPS coordinate (B{C{Utm}} respectively B{C{Ups}})
                or a L{UtmUps8Tuple}C{(zone,
                hemipole, easting, northing, band, datum, convergence,
                scale)} if B{C{Utm}} respectively B{C{Ups}} is C{None} or
                B{C{cmoff}} is C{False}.

       @raise RangeError: If B{C{lat}} outside the valid UTM or UPS bands
                          or if B{C{lat}} or B{C{lon}} outside the valid
                          range and L{rangerrors} set to C{True}.

       @raise TypeError: If B{C{latlon}} is not ellipsoidal or B{C{lon}}
                         value is missing.

       @raise UTMUPSError: UTM or UPS validation failed.

       @raise ValueError: Invalid B{C{lat}} or B{C{lon}}.

       @see: Functions L{toUtm8} and L{toUps8}.
    '''
    lat, lon, d, name = _to4lldn(latlon, lon, datum, name)
    z, B, p, lat, lon = utmupsZoneBand5(lat, lon)

    f = falsed and cmoff.get('cmoff', True)
    if z == _UPS_ZONE:
        u = toUps8(lat,
                   lon,
                   datum=d,
                   falsed=f,
                   Ups=Ups,
                   pole=pole or p,
                   name=name)
    else:
        u = toUtm8(lat, lon, datum=d, falsed=f, Utm=Utm, name=name)
    return u