ó
ø`9Sc           @   s,   d  d l  Z  d g Z d d d „  ƒ  YZ d S(   iÿÿÿÿNt   GeodeticPointc           B   s\   e  Z d  Z d Z d Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z RS(   s@   Geodetic coordinates of a point with respect to WGS84 ellipsoid.g   @¦TXAg—Ä?XAg        c         C   s   | |  _  | |  _ | |  _ d S(   ss  Parameters:
          - 'latitide': geodetic latitude, in degrees (angle between the
            equatorial plane and a normal to the reference ellipsoid passing
            through the point, positive direction northward).
          - 'longitude': geodetic longitude, in degrees (angle between the
            meridional plane of the reference meridian and a normal to the
            reference ellipsoid passing through the point, positive direction
            eastward).
          - 'altitude': geodetic altitude, in meters (normal distance to the
            point from the reference ellipsoid, positive direction upward).N(   t   latitudet	   longitudet   altitude(   t   selfR   R   R   (    (    s   code\common\GeodeticPoint.pyt   __init__    s    		c         C   s   t  |  j |  j ƒ S(   sX   Return a copy of 'self' with the same latitude and longitude, but
        zero altitude.(   t   GeoPointR   R   (   R   (    (    s   code\common\GeodeticPoint.pyt   zeroAltitudePoint0   s    c         C   s
  t  j |  j ƒ } t  j |  j ƒ } t  j |  j d t  j | ƒ d |  j d t  j | ƒ d ƒ } |  j d t  j | ƒ | } |  j d t  j | ƒ | } | |  j	 t  j | ƒ 7} | |  j	 t  j | ƒ 7} | t  j | ƒ } | t  j | ƒ } | | | f S(   s!  Calculate geocentric cartesian coordinates of the point, in meters,
        and return them as a 3-tuple '(x, y, z)'.

        'z' axis points to the North pole, 'x' axis is aligned with the
        reference meridian, whereas 'y' axis complements the system to a
        right-handed one.i   (
   t   matht   radiansR   R   t   sqrtt   ellipsoidMajorRadiust   cost   ellipsoidMinorRadiust   sinR   (   R   t
   latRadianst   longRadianst   denominatort   xyt   zt   xt   y(    (    s   code\common\GeodeticPoint.pyt   cartesianCoords6   s    "c            sD   |  j  ƒ  ‰ | j  ƒ  ‰  t j t ‡ ‡  f d †  t d ƒ Dƒ ƒ ƒ S(   s¬   Return the distance between 'self' and 'other' points, measured
        along a straight line, in meters.

        Warning: Altitudes of both points are taken into account.c         3   s%   |  ] } ˆ  | ˆ | d  Vq d S(   i   N(    (   t   .0t   i(   t
   selfCoordst   otherCoords(    s   code\common\GeodeticPoint.pys	   <genexpr>`   s   i   (   R   R   R
   t   sumt   range(   R   t   other(    (   R   R   s   code\common\GeodeticPoint.pyt   distToPointW   s    c         C   s®   | j  ƒ  \ } } } | j  ƒ  \ } } } | | | | }	 | | | | }
 | | | | } |  j  ƒ  \ } } } | |	 | |
 | | t j |	 d |
 d | d ƒ S(   s×  Return the distance between 'self' point and a plane passing through
        'pt1', 'pt2', and Earth's center of mass, measured along the normal to
        the plane, in meters.

        The return value is positive if 'self' belongs to right-hand hemisphere
        with respect to the vector 'pt1'->'pt2' and negative otherwise.
        Exception is raised if points 'pt1' and 'pt2' coincide or are opposite
        to each other with respect to Earth's center of mass.i   (   R   R   R
   (   R   t   pt1t   pt2t   x1t   y1t   z1t   x2t   y2t   z2t   xNormt   yNormt   zNormt   x0t   y0t   z0(    (    s   code\common\GeodeticPoint.pyt   distFromLinec   s    
c         C   s4   |  j  | j k o3 |  j | j k o3 |  j | j k S(   N(   t   latitideR   R   R   (   R   R   (    (    s   code\common\GeodeticPoint.pyt   __eq__   s    c         C   s'   t  |  j ƒ t  |  j ƒ At  |  j ƒ AS(   N(   t   hashR   R   R   (   R   (    (    s   code\common\GeodeticPoint.pyt   __hash__„   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R-   R/   R1   (    (    (    s   code\common\GeodeticPoint.pyR       s   		!			(    (   R   t   __all__R    (    (    (    s   code\common\GeodeticPoint.pyt   <module>   s   	