def toUtm(self, Utm=Utm): '''Convert this MGRS grid reference to a UTM coordinate. @keyword Utm: Optional (sub-)class to return the UTM coordinate (L{Utm}) or C{None}. @return: The UTM coordinate (L{Utm}) or 4-tuple (C{zone, hemisphere, easting, northing}) if I{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 = toUtm(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' return (self.zone, h, e, n) if Utm is None else _xnamed( Utm(self.zone, h, e, n, band=self.band, datum=self.datum), self.name)
def toUtm(self): '''Convert this MGRS grid reference to a UTM coordinate. @return: The UTM coordinate (L{Utm}). @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 = toUtm(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 = 'S' if self._bandLat < 0 else 'N' # if self._band < 'N' return Utm(self._zone, h, e, n, band=self._band, datum=self._datum)
def toUtm(self): '''Convert this I{LatLon} point to a UTM coordinate. See function L{toUtm} in module L{utm} for details. @return: The UTM coordinate (L{Utm}). ''' if self._utm is None: from utm import toUtm # PYCHOK recursive import self._utm = toUtm(self, datum=self.datum) self._utm._latlon = self return self._utm