Coverage for pygeodesy/utmupsBase.py : 95%

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 the UTM, UPS, Mgrs and Epsg classes/modules. '''
_xattrs, _xinstanceof, _xkwds, \ _xsubclassof, _xzipairs _convergence_, _datum_, _easting_, _float, \ _hemipole_, _invalid_, _lat_, _lon_, _N_, \ _n_a_, _northing_, _NS_, _PLUS_, _scale_, \ _SPACE_, _SQUARE_, _zone_, _0_0, _0_5, _180_0 notOverloaded, _Pass, _xnamed Number_, Scalar, Str, Zone
# _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. '''
'''5-Tuple C{(lat, lon, datum, convergence, scale)} in C{degrees90}, C{degrees180}, L{Datum}, C{degrees} and C{float}. '''
'''(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, '_Error')
self._datum = _ellipsoidal_datum(datum) # XXX name=band
return self.toRepr(B=True)
'''Get the meridian convergence (C{degrees}) or C{None}. '''
'''Get the datum (L{Datum}). '''
'''Get the easting (C{meter}). '''
'''Get easting and northing (L{EasNor2Tuple}C{(easting, northing)}) in C{meter}s. ''' 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))
'''Get easting and northing falsed (C{bool}). '''
def falsed2(self): # PYCHOK no cover '''(INTERNAL) I{Must be overloaded}. ''' notOverloaded(self, self.falsed2)
'''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 string representation of this UTM/UPS coordinate. '''
'''(INTERNAL) Return a string representation of this UTM/UPS coordinate. ''' fstr(self.northing, prec=prec)) degDMS(self.convergence, prec=8, pos=_PLUS_), _n_a_ if self.scale is None else fstr(self.scale, prec=8))
'''2-Tuple C{(zone, hemipole)} as C{int} and C{str}, where C{zone} is C{1..60} for UTM or C{0} for UPS and C{hemipole} C{'N'|'S'} is the UTM hemisphere or the UPS pole. '''
'''5-Tuple C{(zone, hemipole, easting, northing, band)} as C{int}, C{str}, C{meter}, C{meter} and C{band} letter, where C{zone} is C{1..60} for UTM or C{0} for UPS, C{hemipole} C{'N'|'S'} is the UTM hemisphere or the UPS pole and C{band} is C{""} or the (longitudinal) UTM band C{'C'|'D'..'W'|'X'} or the (polar) UPS band C{'A'|'B'|'Y'|'Z'}. '''
'''8-Tuple C{(zone, hemipole, easting, northing, band, datum, convergence, scale)} as C{int}, C{str}, C{meter}, C{meter}, C{band} letter, C{Datum}, C{degrees} and C{scalar}, where C{zone} is C{1..60} for UTM or C{0} for UPS, C{hemipole} C{'N'|'S'} is the UTM hemisphere or the UPS pole and C{band} is C{""} or the (longitudinal) UTM band C{'C'|'D'..'W'|'X'} or the (polar) UPS band C{'A'|'B'|'Y'|'Z'}. ''' _band_, _datum_, _convergence_, _scale_) Band, _Pass, Degrees, Scalar)
'''5-Tuple C{(zone, band, hemipole, lat, lon)} as C{int}, C{str}, C{str}, C{degrees90} and C{degrees180}, where C{zone} is C{1..60} for UTM or C{0} for UPS, C{band} is C{""} or the (longitudinal) UTM band C{'C'|'D'..'W'|'X'} or (polar) UPS band C{'A'|'B'|'Y'|'Z'} and C{hemipole} C{'N'|'S'} is the UTM hemisphere or the UPS pole. '''
'''(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)
UtmUps2Tuple, UtmUps5Tuple, UtmUps8Tuple, UtmUpsLatLon5Tuple)
# **) MIT License # # Copyright (C) 2016-2020 -- 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. |