Coverage for pygeodesy/utmupsBase.py : 94%

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 -*-
Base class C{UtmUpsBase} and private functions and constants. '''
_xinstanceof, _xsubclassof _N_, _n_a_, _NS_, _PLUS_, _SPACE_, \ _0_0, _0_5, _180_0 notOverloaded, _xnamed
# _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}).
@return: C{'N'|'S'} for north-/southern hemisphere. '''
'''(INTERNAL) Return 4-tuple (C{lat, lon, datum, name}). ''' # if lon is not None: # raise AttributeError
'''Parse UTM/UPS zone, Band letter and hemisphere/pole letter.
@arg zone: Zone with/-out Band (C{scalar} or C{str}). @kwarg band: Optional (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}}. ''' z = int(zone) elif zone in 'AaBbYyZz': # single letter B = zone z = _UPS_ZONE
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) # XXX name=band
return self.toRepr(B=True)
'''Get the meridian convergence (C{degrees}) or C{None} if not available. '''
'''Get the datum (L{Datum}). '''
'''Get the easting (C{meter}). '''
'''Get easting and northing (L{EasNor2Tuple}C{(easting, northing)}). ''' return EasNor2Tuple(self.easting, self.northing)
'''Return easting and northing, falsed or unfalsed.
@kwarg falsed: Return easting and northing falsed (C{bool}), otherwise unfalsed.
@return: An L{EasNor2Tuple}C{(easting, northing)} in C{meter}s. ''' else: Northing(n + self.northing, Error=self._Error))
'''(INTERNAL) Cache for 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) Convert cached LatLon ''' ll.convergence, ll.scale) else: ll, '_convergence', '_scale')
'''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}. '''
'''(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) 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
raise ValueError
raise ValueError
else: # int('') raises ValueError else: raise ValueError
strUTMUPS=strUTMUPS, Error=Error)
# **) MIT License # # Copyright (C) 2016-2021 -- 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. |