Coverage for pygeodesy/css.py : 97%

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 -*-
Classes L{CassiniSoldner}, L{Css} and L{CSSError} requiring I{Charles Karney}'s U{geographiclib <https://PyPI.org/project/geographiclib>} Python package to be installed. '''
_xinstanceof, _xsubclassof _easting_, _lat_, _lon_, _m_, _name_, \ _northing_, _reciprocal_, _SPACE_, \ _0_0, _0_5, _90_0 _norm2, _norm180, _sincos2d LatLon2Tuple, LatLon4Tuple, _LL4Tuple Property_RO, _update_all Lat_, Lon_, Northing, Scalar
'''(INTERNAL) Get/set default projection. ''' else:
'''Cassini-Soldner (CSS) conversion or other L{Css} issue. '''
'''Cassini-Soldner projection, a Python version of I{Karney}'s C++ class U{CassiniSoldner <https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1CassiniSoldner.html>}. '''
'''New L{CassiniSoldner} projection.
@arg lat0: Latitude of center point (C{degrees90}). @arg lon0: Longitude of center point (C{degrees180}). @kwarg datum: Optional datum or ellipsoid (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg name: Optional name (C{str}).
@raise CSSError: Invalid B{C{lat}} or B{C{lon}}.
@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) '''
'''Get the datum (L{Datum}). '''
'''Set the datum or ellipsoid (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}) or C{None} for the default. ''' _xellipsoidal(datum=_ellipsoidal_datum(datum, name=self.name))
'''Check for matching datum ellipsoids.
@raise CSSError: Ellipsoid mismatch of B{C{latlon}} and this projection. '''
'''Get the ellipsoid's equatorial radius, semi-axis (C{meter}). '''
'''Get the ellipsoid's flattening (C{float}). '''
'''Convert an (ellipsoidal) geodetic location to Cassini-Soldner easting and northing.
@arg lat: Latitude of the location (C{degrees90}). @arg lon: Longitude of the location (C{degrees180}). @kwarg name: Name inlieu of this projection's name (C{str}).
@return: An L{EasNor2Tuple}C{(easting, northing)}.
@see: Methods L{CassiniSoldner.forward4}, L{CassiniSoldner.reverse} and L{CassiniSoldner.reverse4}.
@raise CSSError: Invalid B{C{lat}} or B{C{lon}}. '''
'''Convert an (ellipsoidal) geodetic location to Cassini-Soldner easting and northing.
@arg lat: Latitude of the location (C{degrees90}). @arg lon: Longitude of the location (C{degrees180}). @kwarg name: Name inlieu of this projection's name (C{str}).
@return: An L{EasNorAziRk4Tuple}C{(easting, northing, azimuth, reciprocal)}.
@see: Method L{CassiniSoldner.forward}, L{CassiniSoldner.forward6}, L{CassiniSoldner.reverse} and L{CassiniSoldner.reverse4}.
@raise CSSError: Invalid B{C{lat}} or B{C{lon}}. ''' t.azimuth, t.reciprocal, name=t.name)
'''Convert an (ellipsoidal) geodetic location to Cassini-Soldner easting and northing.
@arg lat: Latitude of the location (C{degrees90}). @arg lon: Longitude of the location (C{degrees180}). @kwarg name: Name inlieu of this projection's name (C{str}).
@return: An L{EasNorAziRkEqu6Tuple}C{(easting, northing, azimuth, reciprocal, equatorarc, equatorazimuth)}.
@see: Method L{CassiniSoldner.forward}, L{CassiniSoldner.forward4}, L{CassiniSoldner.reverse} and L{CassiniSoldner.reverse4}.
@raise CSSError: Invalid B{C{lat}} or B{C{lon}}. '''
if e == 0: # PYCHOK no cover z = _diff182(z1, z2)[0] * _0_5 # _2sum c = _copysign(_90_0, 90 - D) # -90 if D > 90 else 90 z1, z2 = c - z, c + z
# reciprocal of azimuthal northing scale # rk = p._GenPosition(True, -a, g.DISTANCE)[7]
cb1 * self._cb0 + sb1 * self._sb0) # n = self._meridian._GenPosition(True, d, g.DISTANCE)[4] name=name or self.name)
'''Get this projection's I{wrapped,Karney} U{Geodesic <https://GeographicLib.SourceForge.io/html/python/code.html>}, provided package U{geographiclib <https://PyPI.org/project/geographiclib>} is installed, otherwise L{GeodesicExact} instance. ''' except ImportError: g = self.datum.ellipsoid.geodesicx
'''Set this projection's geodesic (C{bool}) to L{GeodesicExact} or I{wrapped Karney}'s or C{None} for the default.
@raise ImportError: Package U{geographiclib<https://PyPI.org/ project/geographiclib>} not installed or not found and C{B{exact}=False}. ''' self._geodesic = None else:
'''Return C{True} if this projection's geodesic is L{GeodesicExact}. '''
'''Get the center latitude (C{degrees90}). '''
'''Get the center lat- and longitude (L{LatLon2Tuple}C{(lat, lon)}) in (C{degrees90}, (C{degrees180}). '''
'''Set the center lat- and longitude (ellipsoidal C{LatLon}, L{LatLon2Tuple}, L{LatLon4Tuple} or a C{tuple} or C{list} with the C{lat}- and C{lon}gitude in C{degrees}).
@raise CSSError: Invalid B{C{latlon0}} or ellipsoid mismatch of B{C{latlon0}} and this projection. ''' else: except (AttributeError, TypeError, ValueError) as x: raise CSSError(latlon0=latlon0, txt=str(x))
'''Get the center longitude (C{degrees180}). '''
def majoradius(self): # PYCHOK no cover '''DEPRECATED, use property C{equatoradius}.''' return self.equatoradius
'''Set or reset the center point of this Cassini-Soldner projection.
@arg lat0: Center point latitude (C{degrees90}). @arg lon0: Center point longitude (C{degrees180}).
@raise CSSError: Invalid B{C{lat0}} or B{C{lon0}}. '''
Lon_(lon0=lon0, Error=CSSError), _0_0, g.STANDARD | g.DISTANCE_IN | g.LINE_OFF)
'''Convert a Cassini-Soldner location to (ellipsoidal) geodetic lat- and longitude.
@arg easting: Easting of the location (C{meter}). @arg northing: Northing of the location (C{meter}). @kwarg LatLon: Optional, ellipsoidal class to return the geodetic location as (C{LatLon}) or C{None}. @kwarg LatLon_kwds: Optional (C{LatLon}) keyword arguments, ignored if C{B{LatLon} is None}.
@return: Geodetic location B{C{LatLon}} or if B{C{LatLon}} is C{None}, a L{LatLon2Tuple}C{(lat, lon)}.
@raise CSSError: Ellipsoidal mismatch of B{C{LatLon}} and this projection.
@raise TypeError: Invalid B{C{LatLon}} or B{C{LatLon_kwds}}.
@see: Method L{CassiniSoldner.reverse4}, L{CassiniSoldner.forward} and L{CassiniSoldner.forward4}. ''' else:
'''Convert a Cassini-Soldner location to (ellipsoidal) geodetic lat- and longitude.
@arg easting: Easting of the location (C{meter}). @arg northing: Northing of the location (C{meter}). @kwarg name: Name inlieu of this projection's name (C{str}).
@return: A L{LatLonAziRk4Tuple}C{(lat, lon, azimuth, reciprocal)}.
@see: Method L{CassiniSoldner.reverse}, L{CassiniSoldner.forward} and L{CassiniSoldner.forward4}. ''' # include azimuth of easting direction and reciprocal of # azimuthal northing scale (see C++ member Direct() 5/6 # <https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1Geodesic.html>)
'''Return a string representation of this projection.
@kwarg prec: Number of (decimal) digits, unstripped (C{int}).
@return: This projection as C{"<classname>(lat0, lon0, ...)"} (C{str}). '''
'''Return a string representation of this projection.
@kwarg prec: Number of (decimal) digits, unstripped (C{int}). @kwarg sep: Separator to join (C{str}).
@return: This projection as C{"lat0 lon0"} (C{str}). '''
'''Cassini-Soldner East-/Northing location. '''
'''New L{Css} Cassini-Soldner position.
@arg e: Easting (C{meter}). @arg n: Northing (C{meter}). @kwarg h: Optional height (C{meter}). @kwarg cs0: Optional, the Cassini-Soldner projection (L{CassiniSoldner}). @kwarg 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 TypeError: If B{C{cs0}} is not L{CassiniSoldner}.
@raise ValueError: Invalid B{C{h}}.
@example:
>>> cs = Css(448251, 5411932.0001) '''
'''Get the azimuth of easting direction (C{degrees}). '''
'''Get the projection (L{CassiniSoldner}). '''
'''Set the I{Cassini-Soldner} projection.
@arg cs0: The projection (L{CassiniSoldner}).
@raise TypeError: Invalid B{C{cs0}}. ''' cs0 = _CS0(cs0) if cs0 != self._cs0: _update_all(self) self._cs0 = cs0
# def dup(self, name=NN, **e_n_h_cs0): # PYCHOK signature # '''Duplicate this position with some attributes modified. # # @kwarg e_n_h_cs0: Use keyword argument C{B{e}=...}, C{B{n}=...}, # C{B{h}=...} and/or C{B{cs0}=...} to override # the current C{easting}, C{northing} C{height} # or C{cs0} projectio, respectively. # ''' # def _args_kwds(e=None, n=None, **kwds): # return (e, n), kwds # # kwds = _xkwds(e_n_h_cs0, e=self.easting, n=self.northing, # h=self.height, cs0=self.cs0, # name=name or self.name) # args, kwds = _args_kwds(**kwds) # return self.__class__(*args, **kwds) # .classof
'''Get the easting (C{meter}). '''
'''Get the height (C{meter}). '''
'''Get the lat- and longitude (L{LatLon2Tuple}). '''
'''Get the northing (C{meter}). '''
'''Get the lat, lon, azimuth and reciprocal (L{LatLonAziRk4Tuple}). '''
'''Get the reciprocal of azimuthal northing scale (C{scalar}). '''
'''Convert this L{Css} to an (ellipsoidal) geodetic point.
@kwarg LatLon: Optional, ellipsoidal class to return the geodetic point (C{LatLon}) or C{None}. @kwarg height: Optional height for the point, overriding the default height (C{meter}). @kwarg LatLon_kwds: Optional, additional B{C{LatLon}} keyword arguments, ignored if C{B{LatLon} is None}.
@return: The geodetic point (B{C{LatLon}}) or if B{C{LatLon}} is C{None}, a L{LatLon4Tuple}C{(lat, lon, height, datum)}.
@raise TypeError: If B{C{LatLon}} or B{C{datum}} is not ellipsoidal or invalid B{C{height}} or B{C{LatLon_kwds}}. '''
inst=self, name=self.name)
'''Return a string representation of this L{Css} position.
@kwarg prec: Number of (decimal) digits, unstripped (C{int}). @kwarg fmt: Enclosing backets format (C{str}). @kwarg sep: Optional separator between name:values (C{str}). @kwarg m: Optional unit of the height, default meter (C{str}). @kwarg 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}). '''
'''Return a string representation of this L{Css} position.
@kwarg prec: Number of (decimal) digits, unstripped (C{int}). @kwarg sep: Optional separator to join (C{str}) or C{None} to return an unjoined C{tuple} of C{str}s. @kwarg m: 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 height is non-zero (C{str}). '''
'''4-Tuple C{(easting, northing, azimuth, reciprocal)} for the Cassini-Soldner location with C{easting} and C{northing} in C{meters} and the C{azimuth} of easting direction and C{reciprocal} of azimuthal northing scale, both in C{degrees}. '''
'''6-Tuple C{(easting, northing, azimuth, reciprocal, equatorarc, equatorazimuth)} for the Cassini-Soldner location with C{easting} and C{northing} in C{meters} and the C{azimuth} of easting direction, C{reciprocal} of azimuthal northing scale, C{equatorarc} and C{equatorazimuth}, all in C{degrees}. '''
'''4-Tuple C{(lat, lon, azimuth, reciprocal)}, all in C{degrees} where C{azimuth} is the azimuth of easting direction and C{reciprocal} the reciprocal of azimuthal northing scale. '''
'''Convert an (ellipsoidal) geodetic point to a Cassini-Soldner location.
@arg latlon: Ellipsoidal point (C{LatLon} or L{LatLon4Tuple}). @kwarg cs0: Optional, the Cassini-Soldner projection to use (L{CassiniSoldner}). @kwarg height: Optional height for the point, overriding the default height (C{meter}). @kwarg Css: Optional class to return the location (L{Css}) or C{None}. @kwarg 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: Ellipsoidal mismatch of B{C{latlon}} and B{C{cs0}}.
@raise ImportError: Package U{geographiclib<https://PyPI.org/ project/geographiclib>} not installed or not found.
@raise TypeError: If B{C{latlon}} is not ellipsoidal. '''
r = EasNor3Tuple(c.easting, c.northing, h, name=n) else:
# **) 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. |