Coverage for pygeodesy/ellipsoidalBase.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 -*-
C{LatLonEllipsoidalBase}.
Pure Python implementation of geodesy tools for ellipsoidal earth models, transcribed in part from JavaScript originals by I{(C) Chris Veness 2005-2016} and published under the same MIT Licence**, see for example U{latlon-ellipsoidal <https://www.Movable-Type.co.UK/scripts/geodesy/docs/latlon-ellipsoidal.js.html>}.
@newfield example: Example, Examples '''
'''(INTERNAL) Base class for ellipsoidal C{Cartesian}s. '''
'''Convert this cartesian point from one to an other reference frame.
@param reframe2: Reference frame to convert I{to} (L{RefFrame}). @param reframe: Reference frame to convert I{from} (L{RefFrame}). @keyword epoch: Optional epoch to observe for B{C{reframe}}, a fractional calendar year (C{scalar}).
@return: The converted point (C{Cartesian}) or this point if conversion is C{nil}.
@raise TRFError: No conversion available from B{C{reframe}} to B{C{reframe2}}.
@raise TypeError: B{C{reframe2}} or B{C{reframe}} not a L{RefFrame} or B{C{epoch}} not C{scalar}. '''
epoch is None else _2epoch(epoch)):
'''(INTERNAL) Base class for ellipsoidal C{LatLon}s. '''
epoch=None, name=''): '''Create an ellipsoidal C{LatLon} point frome the given lat-, longitude and height on the given datum and with the given reference frame and epoch.
@param lat: Latitude (C{degrees} or DMS C{[N|S]}). @param lon: Longitude (C{degrees} or DMS C{str[E|W]}). @keyword height: Optional elevation (C{meter}, the same units as the datum's half-axes). @keyword datum: Optional, ellipsoidal datum to use (L{Datum}). @keyword reframe: Optional reference frame (L{RefFrame}). @keyword epoch: Optional epoch to observe for B{C{reframe}} (C{scalar}), a non-zero, fractional calendar year. @keyword name: Optional name (string).
@raise TypeError: B{C{datum}} is not a L{datum}, B{C{reframe}} is not a L{RefFrame} or B{C{epoch}} is not C{scalar} non-zero.
@example:
>>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84 '''
'''(INTERNAL) Adjust elevation or geoidHeight with difference in Gaussian radii of curvature of given datum and NAD83.
@note: This is an arbitrary, possibly incorrect adjustment. ''' # use ratio, datum and NAD83 units may differ
self._utm = self._wm = self._3xyz = None
'''Return the antipode, the point diametrically opposite to this point.
@keyword height: Optional height of the antipode, height of this point otherwise (C{meter}).
@return: The antipodal point (C{LatLon}). ''' lla.datum = self.datum
def convergence(self): '''Get this point's UTM or UPS meridian convergence (C{degrees}) or C{None} if not converted from L{Utm} ot L{Ups}. '''
'''Convert this point to an other datum.
@param datum2: Datum to convert I{to} (L{Datum}).
@return: The converted point (ellipsoidal C{LatLon}).
@raise TypeError: The B{C{datum2}} is not a L{Datum}.
@example:
>>> p = LatLon(51.4778, -0.0016) # default Datums.WGS84 >>> p.convertDatum(Datums.OSGB36) # 51.477284°N, 000.00002°E '''
'''Convert this point to an other reference frame.
@param reframe2: Reference frame to convert I{to} (L{RefFrame}).
@return: The converted point (ellipsoidal C{LatLon}) or this point if conversion is C{nil}.
@raise TRFError: No B{C{.reframe}} or no conversion available from B{C{.reframe}} to B{C{reframe2}}.
@raise TypeError: The B{C{reframe2}} is not a L{RefFrame}.
@example:
>>> p = LatLon(51.4778, -0.0016, reframe=RefFrames.ETRF2000) # default Datums.WGS84 >>> p.convertRefFrame(RefFrames.ITRF2014) # 51.477803°N, 000.001597°W, +0.01m '''
raise TRFError('no %r.%s' % (self, 'reframe'))
epoch=self.epoch, reframe=reframe2) # ll.reframe, ll.epoch = reframe2, self.epoch else:
def datum(self): '''Get this point's datum (L{Datum}). '''
def datum(self, datum): '''Set this point's datum I{without conversion}.
@param datum: New datum (L{Datum}).
@raise TypeError: The B{C{datum}} is not a L{Datum} or not ellipsoidal. ''' raise _IsNotError('ellipsoidal', datum=datum)
'''Approximate the distance and (initial) bearing between this and an other (ellipsoidal) point based on the radii of curvature.
Suitable only for short distances up to a few hundred Km or Miles and only between non-near-polar points.
@param other: The other point (C{LatLon}).
@return: An L{Distance2Tuple}C{(distance, initial)}.
@raise TypeError: The B{C{other}} point is not C{LatLon}.
@raise ValueError: Incompatible datum ellipsoids.
@see: Method L{Ellipsoid.distance2} and U{Local, flat earth approximation<https://www.EdWilliams.org/avform.htm#flat>}. ''' other.lat, other.lon)
'''Return elevation of this point for its or the given datum.
@keyword adjust: Adjust the elevation for a B{C{datum}} other than C{NAD83}. @keyword datum: Optional datum (L{Datum}). @keyword timeout: Optional query timeout (seconds).
@return: An L{Elevation2Tuple}C{(elevation, data_source)} or C{(None, error)} in case of errors.
@note: The adjustment applied is the difference in geocentric earth radius for the B{C{datum}} used and the C{NAV83} datum upon which L{elevations.elevation2} is based.
@note: NED elevation is only available for locations within the U{Conterminous US (CONUS) <https://WikiPedia.org/wiki/Contiguous_United_States>}.
@see: Function L{elevations.elevation2} and method L{Ellipsoid.Rgeocentric} for further details and possible C{error}s. ''' timeout=timeout)
'''Return the ellipsoid of this point's datum or the given datum.
@keyword datum: Default datum (L{Datum}).
@return: The ellipsoid (L{Ellipsoid}). '''
'''Check the type and ellipsoid of this and an other point's datum.
@param other: The other point (C{LatLon}).
@return: This point's datum ellipsoid (L{Ellipsoid}).
@raise TypeError: The B{C{other}} point is not C{LatLon}.
@raise ValueError: Incompatible datum ellipsoids. '''
except AttributeError: try: # no ellipsoid method, try datum e = other.datum.ellipsoid except AttributeError: e = E # no datum, XXX assume equivalent? raise ValueError('%s %s mistmatch: %ss.%s vs %ss.%s' % ('other', c, c, e.name, c, E.name))
def epoch(self): '''Get this point's observed epoch (C{float}) or C{None}. '''
def epoch(self, epoch): '''Set or clear this point's observed epoch.
@param epoch: Observed epoch, a fractional calendar year (C{scalar}) or C{None}.
@raise TypeError: The B{C{epoch}} is not C{scalar}. '''
'''Return geoid height of this point for its or the given datum.
@keyword adjust: Adjust the geoid height for a B{C{datum}} other than C{NAD83/NADV88}. @keyword datum: Optional datum (L{Datum}). @keyword timeout: Optional query timeout (seconds).
@return: An L{GeoidHeight2Tuple}C{(height, model_name)} or C{(None, error)} in case of errors.
@note: The adjustment applied is the difference in geocentric earth radius for the given B{C{datum}} and the C{NAV83/NADV88} datum of the L{elevations.geoidHeight2}.
@note: The geoid height is only available for locations within the U{Conterminous US (CONUS) <https://WikiPedia.org/wiki/Contiguous_United_States>}.
@see: Function L{elevations.geoidHeight2} and method L{Ellipsoid.Rgeocentric} for further details and possible C{error}s. ''' model=0, timeout=timeout)
def isEllipsoidal(self): '''Check whether this C{LatLon} point is ellipsoidal (C{bool}). '''
def isSpherical(self): '''Check whether this C{LatLon} point is spherical (C{bool}). '''
'''Parse a string representing this C{LatLon} point.
The lat- and longitude must be separated by a sep[arator] character. If height is present it must follow and be separated by another sep[arator]. Lat- and longitude may be swapped, provided at least one ends with the proper compass direction.
For more details, see functions L{parse3llh} and L{parseDMS} in sub-module L{dms}.
@param strll: Lat, lon [, height] (string). @keyword height: Optional, default height (C{meter} or C{None}). @keyword datum: Optional, default datum (L{Datum}). @keyword sep: Optional separator (string).
@return: The point (L{LatLonEllipsoidalBase}).
@raise ValueError: Invalid B{C{strll}}. '''
def reframe(self): '''Get this point's reference frame (L{RefFrame}) or C{None}. '''
def reframe(self, reframe): '''Set or clear this point's reference frame.
@param reframe: Reference frame (L{RefFrame}) or C{None}.
@raise TypeError: The B{C{reframe}} is not a L{RefFrame}. ''' elif self.reframe is not None: self._reframe = None
def scale(self): '''Get this point's UTM grid or UPS point scale factor (C{float}) or C{None} if not converted from L{Utm} or L{Ups}. '''
'''DEPRECATED, use method C{toEcef}.
@return: A L{Vector3Tuple}C{(x, y, z)}. '''
'''Convert this C{LatLon} point to an ETM coordinate.
@return: The ETM coordinate (L{Etm}).
@see: Function L{toEtm8}. '''
'''Convert this C{LatLon} point to a Lambert location.
@see: Function L{toLcc} in module L{lcc}.
@return: The Lambert location (L{Lcc}). ''' name=self.name)
'''Convert this C{LatLon} point to an OSGR coordinate.
@see: Function L{toOsgr} in module L{osgr}.
@return: The OSGR coordinate (L{Osgr}). ''' name=self.name)
'''Convert this C{LatLon} point to a UPS coordinate.
@keyword pole: Optional top/center of (stereographic) projection (C{str}, 'N[orth]' or 'S[outh]'). @keyword falsed: False easting and northing (C{bool}).
@return: The UPS coordinate (L{Ups}).
@see: Function L{toUps8}. ''' pole=pole, falsed=falsed)
'''Convert this C{LatLon} point to a UTM coordinate.
@return: The UTM coordinate (L{Utm}).
@see: Function L{toUtm8}. '''
'''Convert this C{LatLon} point to a UTM or UPS coordinate.
@keyword pole: Optional top/center of UPS (stereographic) projection (C{str}, 'N[orth]' or 'S[outh]').
@return: The UTM or UPS coordinate (L{Utm} or L{Ups}).
@raise TypeError: Result in L{Utm} or L{Ups}.
@see: Function L{toUtmUps}. ''' u = self._ups else: elif isinstance(u, Ups): self._ups = u else: _TypeError(Utm, Ups, toUtmUps8=u)
'''Convert this C{LatLon} point to a WM coordinate.
@see: Function L{toWm} in module L{webmercator}.
@return: The WM coordinate (L{Wm}). '''
# **) 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. |