示例#1
0
see U{Vector-based geodesy
<https://www.Movable-Type.co.UK/scripts/latlong-vectors.html>}.

@newfield example: Example, Examples
'''

from pygeodesy.bases import LatLonHeightBase
from pygeodesy.fmath import fsum, len2, scalar
from pygeodesy.lazily import _ALL_LAZY, _ALL_DOCS
from pygeodesy.named import Vector4Tuple, _xattrs
from pygeodesy.vector3d import Vector3d, VectorError, sumOf as _sumOf

# from math import cos, sin

# all public constants, classes and functions
__all__ = _ALL_LAZY.nvector + _ALL_DOCS('LatLonNvectorBase') + (
    'NorthPole',
    'SouthPole',  # constants
    'Nvector',  # classes
    'sumOf')  # functions
__version__ = '19.09.30'


class Nvector(Vector3d):  # XXX kept private
    '''Base class for ellipsoidal and spherical L{Nvector}.
    '''
    _h = 0  #: (INTERNAL) Height (C{meter}).
    _H = ''  #: Heigth prefix (C{str}), '↑' in JS version

    def __init__(self, x, y, z, h=0, ll=None, name=''):
        '''New n-vector normal to the earth's surface.
示例#2
0
           @return: A single interpolated height (C{float}) or a list of
                    interpolated heights (C{float}s).

           @raise HeightError: Insufficient or non-matching number of
                               B{C{lats}} and B{C{lons}}.

           @raise SciPyError: A C{SmoothSphereBivariateSpline} issue.

           @raise SciPyWarning: A C{SmoothSphereBivariateSpline} warning
                                as exception.
        '''
        return _HeightBase._height(self, lats, lons)


__all__ += _ALL_DOCS(_HeightBase)

# **) 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.
#
示例#3
0

__all__ += _ALL_DOCS(
    _Named,
    _NamedBase,  # _NamedDict,
    _NamedEnum,
    _NamedEnumItem,  # _NamedTuple,
    Bearing2Tuple,
    Bounds2Tuple,
    Bounds4Tuple,
    Destination2Tuple,
    Destination3Tuple,
    Distance2Tuple,
    Distance3Tuple,
    Distance4Tuple,
    EasNor2Tuple,
    EasNor3Tuple,
    LatLon2Tuple,
    LatLon3Tuple,
    LatLon4Tuple,
    LatLonDatum3Tuple,
    LatLonPrec3Tuple,
    LatLonPrec5Tuple,
    NearestOn3Tuple,
    PhiLam2Tuple,
    PhiLam3Tuple,
    PhiLam4Tuple,
    Points2Tuple,
    Vector3Tuple,
    Vector4Tuple)

if __name__ == '__main__':
示例#4
0
<https://www.Movable-Type.co.UK/scripts/geodesy/docs/latlon-ellipsoidal.js.html>}.

@newfield example: Example, Examples
'''

from pygeodesy.basics import EPS, IsnotError, property_doc_, \
                             property_RO, _xinstanceof
from pygeodesy.cartesianBase import CartesianBase
from pygeodesy.datum import Datum, Datums
from pygeodesy.ecef import EcefVeness
from pygeodesy.latlonBase import LatLonBase
from pygeodesy.lazily import _ALL_DOCS
from pygeodesy.named import Vector3Tuple
from pygeodesy.trf import _2epoch, RefFrame, TRFError, _reframeTransforms

__all__ = _ALL_DOCS('CartesianEllipsoidalBase', 'LatLonEllipsoidalBase')
__version__ = '20.04.15'


class CartesianEllipsoidalBase(CartesianBase):
    '''(INTERNAL) Base class for ellipsoidal C{Cartesian}s.
    '''
    _datum = Datums.WGS84  #: (INTERNAL) L{Datum}.
    _Ecef = EcefVeness  #: (INTERNAL) Preferred C{Ecef...} class, backward compatible.

    def convertRefFrame(self, reframe2, reframe, epoch=None):
        '''Convert this cartesian point from one to an other reference frame.

           @arg reframe2: Reference frame to convert I{to} (L{RefFrame}).
           @arg reframe: Reference frame to convert I{from} (L{RefFrame}).
           @kwarg epoch: Optional epoch to observe for B{C{reframe}}, a
示例#5
0
        return LatLonBase.toNvector(self, Nvector=Nvector, **Nvector_kwds)

    def toWm(self, radius=R_MA):
        '''Convert this point to a I{WM} coordinate.

           @kwarg radius: Optional earth radius (C{meter}).

           @return: The WM coordinate (L{Wm}).

           @see: Function L{toWm} in module L{webmercator} for details.
        '''
        from pygeodesy.webmercator import toWm  # PYCHOK recursive import
        return toWm(self, radius=radius)


__all__ += _ALL_DOCS(CartesianSphericalBase, LatLonSphericalBase)

# **) 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.
#
示例#6
0
# -*- coding: utf-8 -*-
u'''(INTERNAL) Base class C{UtmUpsBase} and private functions
for the UTM, UPS, Mgrs and Epsg classes/modules.
'''

from pygeodesy.ellipsoidalBase import LatLonEllipsoidalBase as _LLEB
from pygeodesy.datum import Datums
from pygeodesy.dms import degDMS, parseDMS2
from pygeodesy.fmath import fStr, isscalar, _IsNotError
from pygeodesy.lazily import _ALL_DOCS
from pygeodesy.named import EasNor2Tuple, LatLonDatum5Tuple, \
                           _NamedBase, nameof, _xattrs, _xnamed
from pygeodesy.utily import issubclassof, property_RO, _Strs, \
                           _TypeError, wrap90, wrap360

__all__ = _ALL_DOCS('UtmUpsBase')
__version__ = '20.02.22'

_MGRS_TILE = 100e3  # PYCHOK block size (C{meter})

_UTM_LAT_MAX = 84  # PYCHOK for export (C{degrees})
_UTM_LAT_MIN = -80  # PYCHOK for export (C{degrees})
_UTM_ZONE_MAX = 60  # PYCHOK for export
_UTM_ZONE_MIN = 1  # PYCHOK for export
_UTM_ZONE_OFF_MAX = 60  # PYCHOK max Central meridian offset (C{degrees})

_UPS_LAT_MAX = _UTM_LAT_MAX - 0.5  # PYCHOK includes 30' UTM overlap
_UPS_LAT_MIN = _UTM_LAT_MIN + 0.5  # PYCHOK includes 30' UTM overlap
_UPS_ZONE = _UTM_ZONE_MIN - 1  # PYCHOK for export
_UPS_ZONE_STR = '%02d' % (_UPS_ZONE, )  # PYCHOK for export
示例#7
0
            else:
                raise ValueError

        e, n = map(float, u[2:4])
        return z, h.upper(), e, n, B.upper()

    return _parseX(_UTMUPS5_,
                   strUTMUPS,
                   UPS,
                   band,
                   sep,
                   strUTMUPS=strUTMUPS,
                   Error=Error)


__all__ += _ALL_DOCS(UtmUpsBase, LatLonDatum5Tuple, 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.
#
示例#8
0
from pygeodesy.fmath import favg
from pygeodesy.formy import antipode, compassAngle, cosineLaw, \
                            equirectangular, euclidean, flatLocal, \
                            flatPolar, haversine, isantipode, \
                            latlon2n_xyz,points2, vincentys
from pygeodesy.lazily import _ALL_DOCS
from pygeodesy.named import Bounds2Tuple, LatLon2Tuple, _NamedBase, \
                            notOverloaded, PhiLam2Tuple, Vector3Tuple
from pygeodesy.units import Lat, Lon, Height, Radius, Radius_, Scalar_
from pygeodesy.vector3d import Vector3d

from math import asin, cos, degrees, radians

# XXX the following classes are listed only to get
# Epydoc to include class and method documentation
__all__ = _ALL_DOCS('LatLonBase')
__version__ = '20.04.21'


class LatLonBase(_NamedBase):
    '''(INTERNAL) Base class for C{LatLon} points on spherical or
       ellipsoidal earth models.
    '''
    _datum = None  #: (INTERNAL) L{Datum}, to be overriden.
    _Ecef = EcefKarney  #: (INTERNAL) Preferred C{Ecef...} class.
    _e9t = None  #: (INTERNAL) Cached toEcef (L{Ecef9Tuple}).
    _height = 0  #: (INTERNAL) Height (C{meter}).
    _lat = 0  #: (INTERNAL) Latitude (C{degrees}).
    _latlon = None  #: (INTERNAL) Cached (L{LatLon2Tuple}).
    _lon = 0  #: (INTERNAL) Longitude (C{degrees}).
    _name = ''  #: (INTERNAL) name (C{str}).
示例#9
0
'''

from pygeodesy.ecef import EcefVeness
from pygeodesy.fmath import fsum, hypot_, len2, scalar
from pygeodesy.latlonBase import LatLonBase
from pygeodesy.lazily import _ALL_DOCS, _2kwds
from pygeodesy.named import LatLon3Tuple, Vector3Tuple, \
                            Vector4Tuple, _xattrs
from pygeodesy.vector3d import Vector3d, VectorError, \
                               sumOf as _sumOf, _xyzhdn6
from pygeodesy.utily import property_RO

# from math import cos, sin

# all public constants, classes and functions
__all__ = _ALL_DOCS('LatLonNvectorBase') + (
    'NorthPole',
    'SouthPole',  # constants
    'NvectorBase',  # classes
    'sumOf')  # functions
__version__ = '19.10.21'


class NvectorBase(Vector3d):  # XXX kept private
    '''Base class for ellipsoidal and spherical C{Nvector}s.
    '''
    _datum = None  #: (INTERNAL) L{Datum}, overriden.
    _Ecef = EcefVeness  #: (INTERNAL) Preferred C{Ecef...} class, backward compatible.
    _e9t = None  #: (INTERNAL) Cached toCartesian (L{Ecef9Tuple}).
    _h = 0  #: (INTERNAL) Height (C{meter}).
    _H = ''  #: Heigth prefix (C{str}), '↑' in JS version
示例#10
0
<https://Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}, IEEE Trans. Pattern
Analysis Machine Intelligence (PAMI), vol 37, no 11, pp 2153-2163, Nov 2015.
'''

from pygeodesy.datum import Datum
from pygeodesy.fmath import hypot2, INF, _IsNotError
from pygeodesy.formy import euclidean_, haversine_, points2, \
                           _scaler, vincentys_
from pygeodesy.lazily import _ALL_LAZY, _ALL_DOCS
from pygeodesy.named import _Named, _NamedTuple, PhiLam2Tuple
from pygeodesy.utily import property_RO, unroll180, unrollPI

from math import radians
from random import Random

__all__ = _ALL_LAZY.hausdorff + _ALL_DOCS('Hausdorff6Tuple')
__version__ = '20.02.09'


class HausdorffError(ValueError):
    '''Hausdorff issue.
    '''
    pass


class Hausdorff6Tuple(_NamedTuple):
    '''6-Tuple C{(hd, i, j, mn, md, units)} with the U{Hausdorff
       <https://WikiPedia.org/wiki/Hausdorff_distance>} distance C{hd},
       indices C{i} and C{j}, the total count C{mn}, the C{I{mean}
       Hausdorff} distance C{md} and the name of the distance C{units}.
示例#11
0
# -*- coding: utf-8 -*-

u'''DEPRECATED, use module L{latlonBase} instead.
'''

from pygeodesy.formy import points2  # PYCHOK exported
from pygeodesy.latlonBase import LatLonBase as LatLonHeightBase  # PYCHOK exported
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY

# XXX the following classes are listed only to get
# Epydoc to include class and method documentation
__all__ = _ALL_LAZY.bases + _ALL_DOCS('LatLonHeightBase', 'points2')
__version__ = '19.10.20'

# **) 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,
示例#12
0
[6]<https://www.kr.TUWien.ac.AT/staff/eiter/et-archive/cdtr9464.pdf>}.
It is a measure of similarity between curves that takes into account the
location and ordering of the points.  Therefore, it is often a better metric
than the well-known C{Hausdorff} distance, see the L{hausdorff} module.
'''

from pygeodesy.fmath import EPS, EPS1, favg, INF, isscalar
from pygeodesy.formy import euclidean_, haversine_, _scaler, vincentys_
from pygeodesy.lazily import _ALL_LAZY, _ALL_DOCS
from pygeodesy.named import LatLon2Tuple, _LLab2Tuple, _Named, _NamedTuple
from pygeodesy.utily import points2 as _points2, unrollPI

from collections import defaultdict
from math import radians

__all__ = _ALL_LAZY.frechet + _ALL_DOCS('Frechet6Tuple')
__version__ = '19.08.30'


class FrechetError(ValueError):
    '''Fréchet issue.
    '''
    pass


def _fraction(fraction, n):
    f = 1  # int, no fractional indices
    if fraction is None:
        pass
    elif not (isscalar(fraction) and EPS < fraction < EPS1 and
              (float(n) - fraction) < n):
示例#13
0
'''

from pygeodesy.basics import property_RO, _xinstanceof, _xkwds, \
                            _xsubclassof
from pygeodesy.datum import Datums
from pygeodesy.ellipsoidalBase import LatLonEllipsoidalBase as _LLEB
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
from pygeodesy.named import EasNor2Tuple, EasNor3Tuple, \
                            LatLon2Tuple, LatLon4Tuple, \
                           _NamedBase, _NamedTuple, nameof, \
                           _xnamed  # PYCHOK indent
from pygeodesy.streprs import fstr, strs
from pygeodesy.units import Easting, Height, Lat, Lon, Northing

# all public contants, classes and functions
__all__ = _ALL_LAZY.css + _ALL_DOCS('EasNorAziRk4Tuple', 'LatLonAziRk4Tuple')
__version__ = '20.04.22'

_CassiniSoldner0 = None  # default projection


def _CassiniSoldner(cs0):
    '''(INTERNAL) Get/set default projection.
    '''
    if cs0 is None:
        global _CassiniSoldner0
        if _CassiniSoldner0 is None:
            _CassiniSoldner0 = CassiniSoldner(0, 0, name='Default')
        cs0 = _CassiniSoldner0
    else:
        _xinstanceof(CassiniSoldner, cs0=cs0)
示例#14
0
            else:
                raise ValueError

        e, n = map(float, u[2:4])
        return z, h.upper(), e, n, B.upper()

    return _parseX(_UTMUPS5_,
                   strUTMUPS,
                   UPS,
                   band,
                   sep,
                   strUTMUPS=strUTMUPS,
                   Error=Error)


__all__ += _ALL_DOCS(UtmUpsBase)

# **) 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.
#
示例#15
0
for the UTM, UPS, Mgrs and Epsg classes/modules.
'''

from pygeodesy.basics import isscalar, isstr, map1, _or, property_RO, \
                            _xattrs, _xinstanceof, _xkwds, _xsubclassof
from pygeodesy.ellipsoidalBase import LatLonEllipsoidalBase as _LLEB
from pygeodesy.datum import Datum, Datums
from pygeodesy.dms import degDMS, parseDMS2
from pygeodesy.lazily import _ALL_DOCS
from pygeodesy.named import EasNor2Tuple, _NamedBase, _NamedTuple, \
                            nameof, notOverloaded, _xnamed
from pygeodesy.streprs import fstr
from pygeodesy.units import Easting, Northing, Scalar
from pygeodesy.utily import wrap90, wrap360

__all__ = _ALL_DOCS('UtmUpsBase') + _ALL_DOCS('LatLonDatum5Tuple',
                                              'UtmUps5Tuple',
                                              'UtmUps8Tuple',
                                              'UtmUpsLatLon5Tuple')
__version__ = '20.04.22'

_MGRS_TILE = 100e3  # PYCHOK block size (C{meter})

_UTM_LAT_MAX      =  84  # PYCHOK for export (C{degrees})
_UTM_LAT_MIN      = -80  # PYCHOK for export (C{degrees})
_UTM_ZONE_MAX     =  60  # PYCHOK for export
_UTM_ZONE_MIN     =   1  # PYCHOK for export
_UTM_ZONE_OFF_MAX =  60  # PYCHOK max Central meridian offset (C{degrees})

_UPS_LAT_MAX  = _UTM_LAT_MAX - 0.5     # PYCHOK includes 30' UTM overlap
_UPS_LAT_MIN  = _UTM_LAT_MIN + 0.5     # PYCHOK includes 30' UTM overlap
示例#16
0
        # min *is* max, min- *is* maxPoint and n=1
        return Trilaterate5Tuple(*(t[0] + t[-1] + n))

    if area and pc == 3:  # all pairwise concentric ...
        r, p = min((r1, p1), (r2, p2), (r3, p3))
        # ... return smallest point twice, the smallest
        # and largest distance and n=0 for concentric
        return Trilaterate5Tuple(float(r), p, float(max(r1, r2, r3)), p, 0)

    f =  max if area else min
    t = _no_(_overlap_ if area else _intersection_)
    t = '%s (%s %.3f)' % (t, f.__name__, m)
    raise IntersectionError(area=area, eps=eps, wrap=wrap, txt=t)


__all__ += _ALL_DOCS(LatLonBase)

# **) 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.
#
示例#17
0
division = 1 / 2  # double check int division, see .datum.py, .utily.py
if not division:
    raise ImportError('%s 1/2 == %d' % ('division', division))
del division

from pygeodesy.fmath import EPS, fdot, Fsum, fsum_, hypot1, \
                            INF, map2
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
from pygeodesy.named import _Named, _NamedTuple
from pygeodesy.utily import PI, PI_2, PI_4, property_RO, \
                            sincos2, sincos2d

from math import asinh, atan, atan2, ceil, copysign, cosh, \
                 floor, sin, sqrt, tanh

__all__ = _ALL_LAZY.elliptic + _ALL_DOCS('Elliptic3Tuple')
__version__ = '20.02.06'

_TolJAC = sqrt(EPS * 0.01)
_TolRD  =  pow(EPS * 0.002, 0.125)
_TolRF  =  pow(EPS * 0.030, 0.125)
_TolRG0 = _TolJAC * 2.7
_TRIPS  =  13  # Max depth for sncndn, etc, 5-7 might be enough


class EllipticError(ValueError):
    '''Elliptic integral, function, convergence or other L{Elliptic} issue.
    '''
    pass

示例#18
0
# -*- coding: utf-8 -*-

u'''DEPRECATED, use module L{datums} or L{ellipsoids} instead.
'''
from pygeodesy.ellipsoids import *  # R_M, R_MA, R_MB, R_KM, R_NM, R_SM, R_FM, R_VM, \
from pygeodesy.ellipsoids import Curvature2Tuple  # Ellipsoid, Ellipsoids  # PYCHOK exported
from pygeodesy.datums import *  # Datum, Datums, Transform, Transforms  # PYCHOK exported
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY

__all__ = _ALL_LAZY.datums + _ALL_LAZY.ellipsoids + _ALL_DOCS(Curvature2Tuple)
__version__ = '20.08.25'

# **) 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
示例#19
0
            p = d
        else:
            raise ValueError(_no_convergence_fmt_ % (tol, ))

    if ta:  # abutting circles
        r = _latlon4(ta, h, n)
    elif len(ts) == 2:
        return _latlon4(ts[0], h, n), _latlon4(ts[1], h, n)
    elif len(ts) == 1:  # XXX assume abutting
        r = _latlon4(ts[0], h, n)
    else:
        raise _AssertionError(ts=ts)
    return r, r


__all__ += _ALL_DOCS(CartesianEllipsoidalBase, LatLonEllipsoidalBase)

# **) 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.
#
示例#20
0
    # at 166e3 due to 500km false origin)
    z = utm.zone - 1
    en = (
        _Le100k[z % 3][int(E) - 1] +
        # rows in even zones are A-V, in odd zones are F-E
        _Ln100k[z % 2][int(N) % len(_Ln100k[0])])

    if Mgrs is None:
        r = Mgrs4Tuple(utm.zone, en, e, n).to6Tuple(utm.band, utm.datum)
    else:
        kwds = _xkwds(Mgrs_kwds, band=utm.band, datum=utm.datum)
        r = Mgrs(utm.zone, en, e, n, **kwds)
    return _xnamed(r, name or utm.name)


__all__ += _ALL_DOCS(Mgrs4Tuple, Mgrs6Tuple)

# **) 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.
#
示例#21
0
文件: ecef.py 项目: mzy2240/PyGeodesy
'''

from pygeodesy.datum import Datum, Datums, Ellipsoid
from pygeodesy.fmath import cbrt, EPS, EPS1, EPS_2, fdot, fStr, fsum_, hypot1, \
                           _IsNotError, isscalar, map1
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
from pygeodesy.named import LatLon3Tuple, LatLon4Tuple, _NamedBase, _NamedTuple, \
                            Vector3Tuple, _xnamed
from pygeodesy.utily import degrees90, degrees180, property_RO, \
                            sincos2, sincos2d, _TypeError, unStr
from pygeodesy.vector3d import _xyzn4

from math import atan2, copysign, cos, degrees, hypot, sqrt

# all public contants, classes and functions
__all__ = _ALL_LAZY.ecef + _ALL_DOCS('_EcefBase', 'Ecef9Tuple')
__version__ = '20.01.22'


class EcefError(ValueError):
    '''An ECEF issue.
    '''
    pass


def _afStr(this, prec, *attrs):
    def _fStr(a):
        return '%s=%s' % (a, fStr(getattr(this, a), prec=prec))

    return tuple(map(_fStr, attrs))
示例#22
0
@newfield example: Example, Examples
'''

from pygeodesy.datum import Datum, Datums
from pygeodesy.ecef import EcefKarney
from pygeodesy.fmath import EPS, cbrt, fsum_, hypot2, _IsNotError
from pygeodesy.lazily import _ALL_DOCS
from pygeodesy.named import LatLon4Tuple, Vector4Tuple
from pygeodesy.utily import property_RO, _TypeError
from pygeodesy.vector3d import Vector3d, _xyzhdn6

from math import hypot, sqrt

# XXX the following classes are listed only to get
# Epydoc to include class and method documentation
__all__ = _ALL_DOCS('CartesianBase')
__version__ = '20.02.28'


class CartesianBase(Vector3d):
    '''(INTERNAL) Base class for ellipsoidal and spherical C{Cartesian}.
    '''
    _datum = None  #: (INTERNAL) L{Datum}, to be overriden.
    _Ecef = EcefKarney  #: (INTERNAL) Preferred C{Ecef...} class.
    _e9t = None  #: (INTERNAL) Cached toEcef (L{Ecef9Tuple}).
    _v4t = None  #: (INTERNAL) Cached toNvector (L{Vector4Tuple}).

    def __init__(self, xyz, y=None, z=None, datum=None, ll=None, name=''):
        '''New C{Cartesian...}.

           @param xyz: An L{Ecef9Tuple}, L{Vector3Tuple}, L{Vector4Tuple}
示例#23
0
    cs = _CassiniSoldner(cs0)
    cs._datumatch(latlon)

    c = cs.forward4(latlon.lat, latlon.lon)
    h = latlon.height if height is None else Height(height)

    if Css is None:
        r = EasNor3Tuple(c.easting, c.northing, h)
    else:
        r = Css(c.easting, c.northing, h=h, cs0=cs)
        r._latlon = LatLon2Tuple(latlon.lat, latlon.lon)
        r._azi, r._rk = c.azimuth, c.reciprocal
    return _xnamed(r, name or nameof(latlon))


__all__ += _ALL_DOCS(EasNorAziRk4Tuple, LatLonAziRk4Tuple)

# **) 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.
#
示例#24
0
from pygeodesy.basics import PI_2, InvalidError, IsnotError, isscalar, \
                             issubclassof, property_RO, _xinstanceof, _xkwds
from pygeodesy.datum import Datum, R_MA
from pygeodesy.dms import clipDegrees, parseDMS2
from pygeodesy.ellipsoidalBase import LatLonEllipsoidalBase as _LLEB
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
from pygeodesy.named import LatLon2Tuple, _NamedBase, _NamedTuple, \
                            nameof, PhiLam2Tuple, _xnamed
from pygeodesy.streprs import strs
from pygeodesy.units import Easting, Northing, Radius, Radius_
from pygeodesy.utily import degrees90, degrees180

from math import atan, atanh, exp, radians, sin, tanh

# all public contants, classes and functions
__all__ = _ALL_LAZY.webmercator + _ALL_DOCS('EasNorRadius3Tuple')
__version__ = '20.04.22'

# _FalseEasting  = 0   #: (INTERNAL) False Easting (C{meter}).
# _FalseNorthing = 0   #: (INTERNAL) False Northing (C{meter}).
_LatLimit = 85.051129  #: (INTERNAL) Latitudinal limit (C{degrees}).
# _LonOrigin     = 0   #: (INTERNAL) Longitude of natural origin (C{degrees}).


class EasNorRadius3Tuple(_NamedTuple):
    '''3-Tuple C{(easting, northing, radius)}, all in C{meter}.
    '''
    _Names_ = ('easting', 'northing', 'radius')


class WebMercatorError(ValueError):
示例#25
0
@see: U{SciPy<https://docs.SciPy.org/doc/scipy/reference/interpolate.html>}.
'''

from pygeodesy.basics import EPS, PI, PI2, PI_2, _bkwds, InvalidError, \
                             isscalar, len2, map1, map2, property_RO, \
                            _xinstanceof  # PYCHOK indent
from pygeodesy.datum import Datum, Datums
from pygeodesy.fmath import fidw, hypot2
from pygeodesy.formy import cosineLaw_, euclidean_, flatPolar_, \
                            haversine_, PointsError, _scaler, vincentys_
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _FOR_DOCS
from pygeodesy.named import _Named, notOverloaded
from pygeodesy.points import LatLon_
from pygeodesy.utily import radiansPI, radiansPI2, unrollPI

__all__ = _ALL_LAZY.heights + _ALL_DOCS('_HeightBase')
__version__ = '20.04.21'


class HeightError(PointsError):  # imported by .geoids
    '''Height interpolator C{Height...} or interpolation issue.
    '''
    pass


class SciPyError(HeightError):
    '''Error raised for C{SciPy} errors.
    '''
    pass

示例#26
0
I{"[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self
"signed certificate in certificate chain ..."}, review U{this post
<https://StackOverflow.com/questions/27835619/urllib-and-ssl-certificate
-verify-failed-error>} for a remedy.  From a Terminal window run:
C{"/Applications/Python X.Y/Install Certificates.command"}

@newfield example: Example, Examples
'''

from pygeodesy.basics import clips
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
from pygeodesy.named import _NamedTuple
from pygeodesy.streprs import fstr
from pygeodesy.units import Lat, Lon, Scalar

__all__ = _ALL_LAZY.elevations + _ALL_DOCS('Elevation2Tuple',
                                           'GeoidHeight2Tuple')
__version__ = '20.04.21'

try:
    _Bytes = unicode, bytearray  # PYCHOK expected
    from urllib2 import urlopen  # quote, urlcleanup
    from httplib import HTTPException as HTTPError

except (ImportError, NameError):  # Python 3+
    _Bytes = bytes, bytearray
    from urllib.request import urlopen  # urlcleanup
    # from urllib.parse import quote
    from urllib.error import HTTPError

try:
    from json import loads as _json
示例#27
0
       @arg args: Method or property positional arguments (any C{type}s).
       @arg kwds: Method or property keyword arguments (any C{type}s).
    '''
    t = _notError(inst, name, args, kwds)
    raise _AssertionError(t, txt=notOverloaded.__name__.replace(_O_, ' o'))


def _Pass(arg, **unused):  # PYCHOK no cover
    '''(INTERNAL) I{Pass-thru} class for C{_NamedTuple._Units_}.
    '''
    return arg


__all__ += _ALL_DOCS(
    _Named,
    _NamedBase,  # _NamedDict,
    _NamedEnum,
    _NamedEnumItem,
    _NamedTuple)

# **) 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
示例#28
0
           @note: The C{lat} will be in the range C{[-90..90] degrees} and C{lon}
                  in the range C{[-180..180] degrees}.  The C{scale} of the
                  projection is C{1} in I{radial} direction, C{azimuth} clockwise
                  from true North and is C{1 / reciprocal} in the direction
                  perpendicular to this.
        '''
        def _c_t(c):
            t = c > EPS
            if t:
                c = 2 * atan2(c, 2 * self._k0)
            return c, t

        return self._reverse(x, y, name, LatLon, LatLon_kwds, _c_t, False)


__all__ += _ALL_DOCS(Azimuthal7Tuple, _AzimuthalBase)

# **) 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.
#
示例#29
0
from pygeodesy.bases import LatLonHeightBase
from pygeodesy.datum import R_M, R_MA, Datum, Datums
from pygeodesy.dms import parse3llh
from pygeodesy.fmath import EPS, acos1, favg, fsum_
from pygeodesy.lazily import _ALL_DOCS
from pygeodesy.named import Bearing2Tuple
from pygeodesy.utily import PI, PI2, PI_2, degrees90, degrees180, \
                            degrees360, property_RO, sincos2d, \
                            tanPI_2_2, _TypeError, wrapPI

from math import atan2, cos, hypot, log, radians, sin

# XXX the following classes are listed only to get
# Epydoc to include class and method documentation
__all__ = _ALL_DOCS('LatLonSphericalBase')
__version__ = '19.07.09'


class LatLonSphericalBase(LatLonHeightBase):
    '''(INTERNAL) Base class for spherical C{LatLon}.
    '''
    _datum = Datums.Sphere  #: (INTERNAL) XXX TBD

    def bearingTo2(self, other, wrap=False, raiser=False):
        '''Return the initial and final bearing (forward and reverse
           azimuth) from this to an other point.

           @param other: The other point (C{LatLon}).
           @keyword wrap: Wrap and unroll longitudes (C{bool}).
           @keyword raiser: Optionally, raise L{CrossError} (C{bool}).
示例#30
0
    '''
    from pygeodesy.streprs import unstr
    return unstr(name, *args, **kwds)


def utmZoneBand2(lat, lon):
    '''DEPRECATED, use function L{utmZoneBand5}.

       @return: 2-Tuple C{(zone, band)}.
    '''
    from pygeodesy.utm import utmZoneBand5
    r = utmZoneBand5(lat, lon)  # UtmUpsLatLon5Tuple
    return r.zone, r.band


__all__ += _ALL_DOCS(UtmUps4Tuple)

# **) MIT License
#
# Copyright (C) 2018-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.
#