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. @arg latlon: Latitude (C{degrees}) or an (ellipsoidal) geodetic C{LatLon} point. @kwarg lon: Optional longitude (C{degrees}) or C{None}. @kwarg datum: Optional datum to use this UTM coordinate, overriding B{C{latlon}}'s datum (C{Datum}). @kwarg falsed: False both easting and northing (C{bool}). @kwarg Utm: Optional class to return the UTM coordinate (L{Utm}) or C{None}. @kwarg Ups: Optional class to return the UPS coordinate (L{Ups}) or C{None}. @kwarg pole: Optional top/center of UPS (stereographic) projection (C{str}, C{'N[orth]'} or C{'S[outh]'}). @kwarg name: Optional name (C{str}). @kwarg 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
def toUtm(self, Utm=Utm): '''Convert this MGRS grid reference to a UTM coordinate. @kwarg Utm: Optional class to return the UTM coordinate (L{Utm}) or C{None}. @return: The UTM coordinate (L{Utm}) or a L{UtmUps4Tuple}C{(zone, hemipole, easting, northing)} if B{C{Utm}} is C{None}. @example: >>> m = Mgrs('31U', 'DQ', 448251, 11932) >>> u = m.toUtm() # 31 N 448251 5411932 ''' # get northing of the band bottom, extended to # include entirety of bottom-most 100 km square n = toUtm8(self._bandLat, 0, datum=self._datum).northing nb = int(n / _100km) * _100km e, n = self._en100k2m() # 100 km grid square row letters repeat every 2,000 km north; # add enough 2,000 km blocks to get into required band e += self._easting n += self._northing while n < nb: n += _2000km h = _hemi(self.bandLatitude) # if self._band < 'N' r = UtmUps4Tuple(self.zone, h, e, n) if Utm is None else \ Utm(self.zone, h, e, n, band=self.band, datum=self.datum) return self._xnamed(r)
def toUtm(self): '''Convert this C{LatLon} point to a UTM coordinate. @return: The UTM coordinate (L{Utm}). @see: Function L{toUtm8}. ''' if self._utm is None: from pygeodesy.utm import toUtm8, Utm # PYCHOK recursive import self._utm = toUtm8(self, datum=self.datum, Utm=Utm) return self._utm
def toUtm(self, zone, falsed=True, **unused): '''Convert this UPS coordinate to a UTM coordinate. @param zone: The UTM zone (C{int}). @keyword falsed: False both easting and northing (C{bool}). @return: The UTM coordinate (L{Utm}). ''' u = self._utm if u is None or u.zone != zone or falsed != u.falsed: from pygeodesy.utm import toUtm8, Utm # PYCHOK recursive import ll = self.toLatLon(LatLon=None, unfalse=True) self._utm = toUtm8(ll, Utm=Utm, falsed=falsed, name=self.name, zone=zone) return self._utm
def toUtm(latlon, lon=None, datum=None, Utm=_UTM, cmoff=True, name=NN): '''DEPRECATED, use function L{toUtm8}. @return: The UTM coordinate (B{C{Utm}}) or a 6-tuple C{(zone, easting, northing, band, convergence, scale)} if B{C{Utm}} is C{None} or B{C{cmoff}} is C{False}. ''' from pygeodesy.utm import toUtm8, Utm as _Utm U = _Utm if Utm is _UTM else Utm r = toUtm8(latlon, lon=lon, datum=datum, Utm=U, name=name, falsed=cmoff) if isinstance(r, tuple): # UtmUps8Tuple # no hemisphere/pole and datum r = r.zone, r.easting, r.northing, r.band, r.convergence, r.scale return r