예제 #1
0
    def __init__(
            self,
            zone,
            hemisphere,
            easting,
            northing,
            band='',  # PYCHOK expected
            datum=Datums.WGS84,
            falsed=True,
            convergence=None,
            scale=None,
            name=''):
        '''New UTM coordinate.

           @param zone: Longitudinal UTM zone (C{int}, 1..60) or zone
                        with/-out (latitudinal) Band letter (C{str},
                        '01C'..'60X').
           @param hemisphere: Northern or southern hemisphere (C{str},
                              C{'N[orth]'} or C{'S[outh]'}).
           @param easting: Easting, see B{C{falsed}} (C{meter}).
           @param northing: Northing, see B{C{falsed}} (C{meter}).
           @keyword band: Optional, (latitudinal) band (C{str}, 'C'..'X').
           @keyword datum: Optional, this coordinate's datum (L{Datum}).
           @keyword falsed: Both B{C{easting}} and B{C{northing}} are
                            falsed (C{bool}).
           @keyword convergence: Optional meridian convergence, bearing
                                 off grid North, clockwise from true
                                 North (C{degrees}) or C{None}.
           @keyword scale: Optional grid scale factor (C{scalar}) or
                           C{None}.
           @keyword name: Optional name (C{str}).

           @raise EllipticError: No convergence.

           @raise ETMError: Invalid B{C{zone}}, B{C{hemishere}} or
                            B{C{band}}.

           @example:

           >>> import pygeodesy
           >>> u = pygeodesy.Utm(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)
예제 #2
0
    def toUtm(self, Utm=Utm):
        '''Convert this MGRS grid reference to a UTM coordinate.

           @keyword Utm: Optional Utm class to use for the UTM
                         coordinate (L{Utm}) or None.

           @return: The UTM coordinate (L{Utm}) or 4-tuple (zone,
                    hemisphere, easting, northing) if I{Utm} is 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 = 'S' if self._bandLat < 0 else 'N'  # if self._band < 'N'
        if Utm is None:
            u = self._zone, h, e, n
        else:
            u = Utm(self._zone, h, e, n, band=self._band, datum=self._datum)
        return u
예제 #3
0
    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 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'
        if Utm is None:
            r = UtmUps4Tuple(self.zone, h, e, n)
        else:
            r = Utm(self.zone, h, e, n, band=self.band, datum=self.datum)
        return self._xnamed(r)
예제 #4
0
    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)