Coverage for pygeodesy/css.py : 88%

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 -*-
L{CSSError} requiring I{Charles Karney's} U{geographiclib <https://PyPI.org/project/geographiclib/>} package to be installed.
@newfield example: Example, Examples '''
LatLon2Tuple, LatLon4Tuple, LatLonAziRk4Tuple, \ _NamedBase, nameof, _xattrs, _xnamed
# all public contants, classes and functions
'''(INTERNAL) Get/set default projection. ''' global _CassiniSoldner0 if _CassiniSoldner0 is None: _CassiniSoldner0 = CassiniSoldner(0, 0, name='Default') cs0 = _CassiniSoldner0 else:
'''A Python version of Karney's C++ class U{CassiniSoldner <https://GeographicLib.SourceForge.io/1.49/classGeographicLib_1_1CassiniSoldner.html>}. '''
'''New L{CassiniSoldner} projection.
@param lat0: Latitude of center point (C{degrees90}). @param lon0: Longitude of center point (C{degrees180}). @keyword datum: Optional, the geodesic datum (L{Datum}). @keyword name: Optional name (C{str}).
@raise ImportError: Package U{GeographicLib<https://PyPI.org/ project/geographiclib>} missing.
@example:
>>> p = CassiniSoldner(48 + 50/60.0, 2 + 20/60.0) # Paris >>> p.forward(50.9, 1.8) # Calais (-37518.854545, 230003.561828)
>>> p.reverse4(-38e3, 230e3) (50.899937, 1.793161, 89.580797, 0.999982) '''
self._datum = datum
'''(INTERNAL) Make copy with add'l, subclass attributes. ''' return _xattrs(self.classof(self.lat0, self.lon0, datum=self.datum), self, *attrs)
'''Copy this Cassini-Soldner projection.
@return: The copy (L{CassiniSoldner} or subclass thereof). ''' return self._xcopy()
def datum(self): '''Get the datum (L{Datum}). '''
def flattening(self): '''Get the geodesic's flattening (C{float}). ''' return self.geodesic.f
'''Convert an (ellipsoidal) geodetic location Cassini-Soldner easting and northing.
@param lat: Latitude of the location (C{degrees90}). @param lon: Longitude of the location (C{degrees180}).
@return: An L{EasNor2Tuple}C{(easting, northing)}. '''
'''Convert an (ellipsoidal) geodetic location Cassini-Soldner easting and northing.
@param lat: Latitude of the location (C{degrees90}). @param lon: Longitude of the location (C{degrees180}).
@return: An L{EasNorAziRk4Tuple}C{(easting, northing, azimuth, reciprocal)}. '''
z = M.AngDiff(z1, z2)[0] * 0.5 # _2sum c = -90 if abs(d) > 90 else 90 z1, z2 = c - z, c + z
# z: azimuth of easting direction # rk: reciprocal of azimuthal northing scale # rk = p._GenPosition(True, -a, g.DISTANCE)[7]
# s, c = M.sincosd(p.EquatorialAzimuth()) cb1 * self._cb0 + sb1 * self._sb0) # n = self._meridian._GenPosition(True, d, g.DISTANCE)[4]
def geodesic(self): '''Get this projection's U{Geodesic <https://GeographicLib.SourceForge.io/html/python/code.html>}, provided package U{geographiclib <https://PyPI.org/project/geographiclib>} is installed. '''
def lat0(self): '''Get the center latitude (C{degrees90}). ''' return self._latlon0.lat
def latlon0(self): '''Get the center lat- and longitude (L{LatLon2Tuple}). '''
def lon0(self): '''Get the center longitude (C{degrees180}). '''
def majoradius(self): '''Get the geodesic's major (equatorial) radius (C{float}). ''' return self.geodetic.a
'''Set the center point of this projection.
@param lat0: Latitude of center point (C{degrees90}). @param lon0: Longitude of center point (C{degrees180}). '''
'''Convert a Cassini-Soldner location to (ellipsoidal) geodetic lat- and longitude.
@param easting: Easting of the location (C{meter}). @param northing: Northing of the location (C{meter}). @keyword LatLon: Optional, ellipsoidal (sub-)class to return the location as (C{LatLon}) or C{None}.
@return: Geodetic location B{C{LatLon}} or a L{LatLon2Tuple}C{(lat, lon)} if B{C{LatLon}} is C{None}.
@raise TypeError: If B{C{LatLon}} is not ellipsoidal. ''' else: raise _IsNotError(_LLEB.__name__, LatLon=LatLon)
'''Convert a Cassini-Soldner location to (ellipsoidal) geodetic lat- and longitude.
@param easting: Easting of the location (C{meter}). @param northing: Northing of the location (C{meter}).
@return: A L{LatLonAziRk4Tuple}C{(lat, lon, azimuth, reciprocal)}. '''
# include azimuth of easting direction and reciprocal of # azimuthal northing scale (see C++ member Direct() 5/6 # <https://GeographicLib.SourceForge.io/1.49/classGeographicLib_1_1Geodesic.html>)
'''Return a string representation of this projection.
@keyword prec: Optional number of decimal, unstripped (C{int}). @keyword sep: Optional separator to join (C{str}).
@return: This projection as C{"lat0 lon0"} (C{str}). '''
'''Return a string representation of this projection.
@keyword prec: Optional number of decimals, unstripped (C{int}).
@return: This projection as C{"<classname>(lat0, lon0, ...)"} (C{str}). '''
'''Cassini-Soldner (CSS) conversion or other L{Css} issue. '''
'''Cassini-Soldner East-/Northing location. '''
'''New L{Css} Cassini-Soldner position.
@param e: Easting (C{meter}). @param n: Northing (C{meter}). @keyword h: Optional height (C{meter}). @keyword cs0: Optional, the Cassini-Soldner projection (L{CassiniSoldner}). @keyword name: Optional name (C{str}).
@return: The Cassini-Soldner location (L{Css}).
@raise CSSError: If B{C{e}} or B{C{n}} is invalid.
@raise ImportError: Package U{GeographicLib<https://PyPI.org/ project/geographiclib>} missing.
@raise TypeError: If B{C{cs0}} is not L{CassiniSoldner}.
@example:
>>> cs = Css(448251, 5411932.0001) ''' self.name = name
'''(INTERNAL) Convert to geodetic location. ''' r = self.cs0.reverse4(self.easting, self.northing) self._latlon = LatLon2Tuple(r.lat, r.lon) self._azi, self._rk = r.azimuth, r.reciprocal return r # LatLonAziRk4Tuple
'''(INTERNAL) Make copy with add'l, subclass attributes. ''' return _xattrs(self.classof(self.easting, self.northing, h=self.height, cs0=self.cs0), self, *attrs)
def azi(self): '''Get the azimuth of easting direction (C{degrees}). ''' self._reverse4()
def cs0(self): '''Get the projection (L{CassiniSoldner}). '''
'''Copy this Css location.
@return: The copy (L{Css} or subclass thereof). ''' return self._xcopy()
def easting(self): '''Get the easting (C{meter}). '''
def height(self): '''Get the height (C{meter}). '''
def latlon(self): '''Get the lat- and longitude (L{LatLon2Tuple}). ''' self._reverse4()
def northing(self): '''Get the northing (C{meter}). '''
def rk(self): '''Get the reciprocal of azimuthal northing scale (C{degrees}). ''' self._reverse4()
'''Convert this L{Css} to an (ellipsoidal) geodetic point.
@keyword LatLon: Optional, ellipsoidal (sub-)class to return the geodetic point (C{LatLon}) or C{None}. @keyword height: Optional height for the point, overriding the default height (C{meter}).
@return: The point (B{C{LatLon}}) or a L{LatLon4Tuple}C{(lat, lon, height, datum)} if B{C{LatLon}} is C{None}.
@raise TypeError: If B{C{LatLon}} or B{C{datum}} is not ellipsoidal. ''' raise _IsNotError(_LLEB.__name__, LatLon=LatLon)
LatLon(a, b, height=h, datum=d)
'''Return a string representation of this L{Css} position.
@keyword prec: Optional number of decimal, unstripped (C{int}). @keyword sep: Optional separator to join (C{str}). @keyword m: Optional height units, default C{meter} (C{str}).
@return: This position as C{"easting nothing"} C{str} in C{meter} plus C{" height"} and C{'m'} if heigth is non-zero (C{str}). ''' fStr(self.northing, prec=prec)]
'''Return a string representation of this L{Css} position.
@keyword prec: Optional number of decimals, unstripped (C{int}). @keyword fmt: Optional, enclosing backets format (C{str}). @keyword sep: Optional separator between name:values (C{str}). @keyword m: Optional unit of the height, default meter (C{str}). @keyword C: Optionally, include name of projection (C{bool}).
@return: This position as C{"[E:meter, N:meter, H:m, name:'', C:Conic.Datum]"} (C{str}). '''
'''Convert an (ellipsoidal) geodetic point to a Cassini-Soldner location.
@param latlon: Ellipsoidal point (C{LatLon}). @keyword cs0: Optional, the Cassini-Soldner projection to use (L{CassiniSoldner}). @keyword height: Optional height for the point, overriding the default height (C{meter}). @keyword Css: Optional (sub-)class to return the location (L{Css}) or C{None}. @keyword name: Optional B{C{Css}} name (C{str}).
@return: The Cassini-Soldner location (B{C{Css}}) or an L{EasNor3Tuple}C{(easting, northing, height)} if B{C{Css}} is C{None}.
@raise CSSError: Mismatch of this and the B{C{latlon}} ellipsoidal.
@raise ImportError: Package U{GeographicLib<https://PyPI.org/ project/geographiclib>} missing.
@raise TypeError: If B{C{latlon}} is not ellipsoidal. ''' raise _IsNotError(_LLEB.__name__, latlon=latlon)
raise CSSError('%s mistmatch: %r vs %r' % ('ellipsoidal', C, E))
r = EasNor3Tuple(c.easting, c.northing, h) else:
# **) 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. |