Coverage for pygeodesy/utmupsBase.py : 98%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
for L{epsg}, L{etm}, L{mgrs}, L{ups} and L{utm}. '''
_xinstanceof, _xsubclassof _xkwds, _xkwds_not _not_, _N_, _NS_, _PLUS_, _SPACE_, _Y_, _Z_ Property_RO, property_RO, _update_all
# _UTM_BANDS = _MODS.utm._Bands
_B_: _N_90_0, _Z_: _UTM_LAT_MAX} # PYCHOK see .Mgrs.bandLatitude
# _MAX_PSEUDO_ZONE = -1 # _MIN_PSEUDO_ZONE = -4 # _UTMUPS_ZONE_MATCH = -3 # _UTMUPS_ZONE_STANDARD = -1 # _UTM = -2
'''Return the hemisphere letter.
@arg lat: Latitude (C{degrees} or C{radians}). @kwarg N: Minimal North latitude, C{0} or C{_N_}.
@return: C{'N'|'S'} for north-/southern hemisphere. '''
'''(INTERNAL) Return 4-tuple (C{lat, lon, datum, name}). ''' # if lon is not None: # raise AttributeError except AttributeError: lat, lon = parseDMS2(latlon, lon) d = datum or _WGS84
'''Parse UTM/UPS zone, Band letter and hemisphere/pole letter.
@arg zone: Zone with/-out Band (C{scalar} or C{str}). @kwarg band: Optional I{longitudinal/polar} Band letter (C{str}). @kwarg hemipole: Optional hemisphere/pole letter (C{str}). @kwarg Error: Optional error to raise, overriding the default C{ValueError}.
@return: 3-Tuple (C{zone, Band, hemisphere/pole}) as (C{int, str, 'N'|'S'}) where C{zone} is C{0} for UPS or C{1..60} for UTM and C{Band} is C{'A'..'Z'} I{NOT} checked for valid UTM/UPS bands.
@raise ValueError: Invalid B{C{zone}}, B{C{band}} or B{C{hemipole}}. '''
t = _invalid_ except (AttributeError, IndexError, TypeError, ValueError) as x: t = str(x) # no Python 3+ exception chaining raise Error(zone=zone, band=B, hemipole=hemipole, txt=t)
'''Wrap lat- and longitude and determine UTM zone.
@arg lat: Latitude (C{degrees}). @arg lon: Longitude (C{degrees}).
@return: 3-Tuple (C{zone, lat, lon}) as (C{int}, C{degrees90}, C{degrees180}) where C{zone} is C{1..60} for UTM. '''
'''(INTERNAL) Base class for L{Utm} and L{Ups} coordinates. ''' # _scale0 = _K0 # central scale factor (C{scalar})
convergence=None, scale=None): '''(INTERNAL) New L{UtmUpsBase}. ''' notOverloaded(self, callername='_Error')
self._datum = _ellipsoidal_datum(datum) # raiser=_datum_, name=band
'''(INTERNAL) Re/set the latitudinal or polar band. ''' # if not self._Bands: # notOverloaded(self, callername='_Bands') raise self._Error(band=band, txt=_not_(t))
'''Get the meridian convergence (C{degrees}) or C{None} if not available. '''
'''Get the datum (L{Datum}). '''
'''Set the (ellipsoidal) datum L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). '''
'''Get the easting (C{meter}). '''
'''Get easting and northing (L{EasNor2Tuple}C{(easting, northing)}). ''' return EasNor2Tuple(self.easting, self.northing)
'''Return easting and northing, both falsed or unfalsed.
@kwarg falsed: If C{True} return easting and northing falsed (C{bool}), otherwise unfalsed.
@return: An L{EasNor2Tuple}C{(easting, northing)} in C{meter}. ''' else: Northing(n + self.northing, Error=self._Error))
'''(INTERNAL) Cache for method L{toEpsg}. '''
'''Get easting and northing falsed (C{bool}). '''
def falsed2(self): # PYCHOK no cover '''(INTERNAL) I{Must be overloaded}, see function C{notOverloaded}. ''' notOverloaded(self)
'''Get the hemisphere (C{str}, 'N'|'S'). '''
'''(INTERNAL) Get cached C{._toLLEB} as B{C{LatLon}} instance. ''' ll.convergence, ll.scale) else: ll, '_convergence', '_scale')
'''(INTERNAL) See C{._toLLEB} methods, functions C{ups.toUps8} and C{utm._toXtm8} '''
'''Get this UTM or UPS C{un}-centered (L{Utm} or L{Ups}) to its C{lowerleft}. '''
'''(INTERNAL) Cache for method L{toMgrs}. '''
'''(INTERNAL) Cache for method L{toMgrs}, I{un}-centered. '''
'''Get the northing (C{meter}). '''
'''Get the grid scale (C{float}) or C{None}. '''
'''Get the central scale factor (C{float}). '''
def to2en(self, falsed=True): # PYCHOK no cover '''DEPRECATED, use method C{eastingnorthing2}.
@return: An L{EasNor2Tuple}C{(easting, northing)}. ''' return self.eastingnorthing2(falsed=falsed)
'''Determine the B{EPSG (European Petroleum Survey Group)} code.
@return: C{EPSG} code (C{int}).
@raise EPSGError: See L{Epsg}. '''
def _toLLEB(self, **kwds): # PYCHOK no cover '''(INTERNAL) I{Must be overloaded}. ''' notOverloaded(self, **kwds)
'''Convert this UTM/UPS coordinate to an MGRS grid reference.
@kwarg center: If C{True}, I{un}-center this UTM or UPS to its C{lowerleft} (C{bool}) or by C{B{center} meter} (C{scalar}).
@return: The MGRS grid reference (L{Mgrs}).
@see: Function L{pygeodesy.toMgrs} in module L{mgrs} for more details.
@note: If not specified, the I{latitudinal} C{band} is computed from the (geodetic) latitude and the C{datum}. ''' self._mgrs_lowerleft if center in (True,) else _toMgrs(_lowerleft(self, center))) # PYCHOK indent
'''(INTERNAL) Return a representation for this ETM/UTM/UPS coordinate. '''
'''(INTERNAL) Return a string for this ETM/UTM/UPS coordinate. ''' degDMS(self.convergence, prec=prec, pos=_PLUS_), _n_a_ if self.scale is None else fstr(self.scale, prec=prec))
'''(INTERNAL) I{Un}-center a B{C{utmups}} to its C{lowerleft} by C{B{center} meter} or by a I{guess} if B{C{center}} is C{0}. ''' e = n = -center else: (n == c and e in (c, c - 1)): else:
convergence=utmups.convergence) utmups.easting - e, utmups.northing - n, band=utmups.band, falsed=utmups.falsed, **r)
'''(INTERNAL) Parse a string representing a UTM or UPS coordinate consisting of C{"zone[band] hemisphere/pole easting northing"}.
@arg strUTMUPS: A UTM or UPS coordinate (C{str}). @kwarg band: Optional, default Band letter (C{str}). @kwarg sep: Optional, separator to split (",").
@return: 5-Tuple (C{zone, hemisphere/pole, easting, northing, band}).
@raise ParseError: Invalid B{C{strUTMUPS}}. ''' raise ValueError(_not_(_UPS_ZONE_STR))
raise ValueError(_not_(sep))
raise ValueError(_SPACE_(h, _not_(_NS_)))
else: # int('') raises ValueError else: raise ValueError(z)
strUTMUPS=strUTMUPS, Error=Error)
'''(INTERNAL) Convert a L{Utm} or L{Ups} to an L{Mgrs} instance. '''
# **) MIT License # # Copyright (C) 2016-2022 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. |