def __init__(self, zone, hemisphere, easting, northing, band='', # PYCHOK expected datum=Datums.WGS84, falsed=True, convergence=None, scale=None, name=''): '''New L{Etm} coordinate. @arg zone: Longitudinal UTM zone (C{int}, 1..60) or zone with/-out (latitudinal) Band letter (C{str}, '01C'..'60X'). @arg hemisphere: Northern or southern hemisphere (C{str}, C{'N[orth]'} or C{'S[outh]'}). @arg easting: Easting, see B{C{falsed}} (C{meter}). @arg northing: Northing, see B{C{falsed}} (C{meter}). @kwarg band: Optional, (latitudinal) band (C{str}, 'C'..'X'). @kwarg datum: Optional, this coordinate's datum (L{Datum}). @kwarg falsed: Both B{C{easting}} and B{C{northing}} are falsed (C{bool}). @kwarg convergence: Optional meridian convergence, bearing off grid North, clockwise from true North (C{degrees}) or C{None}. @kwarg scale: Optional grid scale factor (C{scalar}) or C{None}. @kwarg name: Optional name (C{str}). @raise ETMError: Invalid B{C{zone}}, B{C{hemishere}} or B{C{band}}. @example: >>> import pygeodesy >>> u = pygeodesy.Etm(31, 'N', 448251, 5411932) ''' Utm.__init__(self, zone, hemisphere, easting, northing, band=band, datum=datum, falsed=falsed, convergence=convergence, scale=scale, name=name) self.exactTM = self.datum.exactTM # ExactTransverseMercator(datum=self.datum)
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)