
     hGk                        d Z ddlZddlmZmZmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZ d Z d Z!d	 Z"d
 Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1e#e$e%e&e'e(e)e*e+e,e-e.e/e0dZ2de1iZ3d Z4d Z5d Z6d Z7d Z8d  Z9d! Z:d" Z;d# Z<d$ Z=d% Z>d& Z?d' Z@d( ZAd) ZBd* ZCd+ ZDi d,e5d-e6d.e6d/e7d0e7d1e8d2e9d3e9d4e:d5e;d6e;d7e<d8e=d9e>d:e>d;e?d<e@eAeBd=ZEeCeCeCeCeDd>ZFy)?z
This module contains mappings necessary to convert from
a CRS to a CF-1.8 compliant projection.

http://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings

    N)Datum	EllipsoidPrimeMeridian)AlbersEqualAreaConversionAzimuthalEquidistantConversion GeostationarySatelliteConversion HotineObliqueMercatorBConversion#LambertAzimuthalEqualAreaConversion"LambertConformalConic1SPConversion"LambertConformalConic2SPConversion%LambertCylindricalEqualAreaConversion*LambertCylindricalEqualAreaScaleConversionMercatorAConversionMercatorBConversionOrthographicConversionPolarStereographicAConversionPolarStereographicBConversionPoleRotationNetCDFCFConversionSinusoidalConversionStereographicConversionTransverseMercatorConversionVerticalPerspectiveConversion)CustomDatumCustomEllipsoidCustomPrimeMeridian)CRSErrorc           	      x   | j                  d      }|r|dvr	 t        j                  |      S d }| j                  d      }	 t	        |xs d| j                  d      | j                  d      | j                  d      | j                  d      	      }d }| j                  d
      }	 t        |xs d| d         }|s|rt        |xs d|xs d|xs d      S y # t        $ r Y w xY w# t        $ r |r|dvrt        j                  |      }Y |w xY w# t        $ r |r|dvrt        j                  |      }Y ~w xY w)Nhorizontal_datum_name)	undefinedunknownreference_ellipsoid_namer   semi_major_axissemi_minor_axisinverse_flatteningearth_radius)namer"   r#   r$   radiusprime_meridian_namelongitude_of_prime_meridian)r&   	longitudezWGS 84	Greenwich)r&   	ellipsoidprime_meridian)
getr   	from_namer   r   r   r   KeyErrorr   r   )	cf_params
datum_namer,   ellipsoid_namer-   r(   s         m/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/pyproj/crs/_cf1x8.py_horizontal_datum_from_paramsr5   %   sj   67Jj(@@	??:.. I]]#=>N
<#.;%MM*;<%MM*;<(}}-AB==0
	 N#--(=>J,$3 =>
 N*{+8)8[
 	

 I  		  <n4LL!++N;I<  J#6>V#V*445HINJs6   C AC( &D 	C%$C%($DD$D98D9c                     t        | t              s| S | j                  d      }t        |      dkD  r'|D cg c]  }t	        |j                                c}S | S c c}w )z=
    Attempt to convert string to list if it is a string
    ,   )
isinstancestrsplitlenfloatstrip)	input_str	val_splitsvals      r4   _try_list_if_stringrB   Q   sU     i%$I
9~09:djjl#:: ;s    Ac                 j    t        |       } 	 t        |       }d }||fS # t        $ r | \  }}Y ||fS w xY w)N)rB   r=   	TypeError)standard_parallelfirst_parallelsecond_parallels      r4   _get_standard_parallelsrH   ]   sV    +,=><01 ?**  <*;'?**<s    22c                     t        | d         \  }}t        ||xs d| j                  dd      | j                  dd      | j                  dd      | j                  dd            S )zX
    http://cfconventions.org/cf-conventions/cf-conventions.html#_albers_equal_area
    rE           latitude_of_projection_originlongitude_of_central_meridianfalse_eastingfalse_northinglatitude_first_parallellatitude_second_parallellatitude_false_originlongitude_false_origineasting_false_originnorthing_false_origin)rH   r   r.   r1   rF   rG   s      r4   _albers_conical_equal_arearW   g   sq     '>%&'#NO % .!0!7C'mm,KSQ(}}-LcR&]]?C@'mm,<cB     c           	          t        | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )[
    http://cfconventions.org/cf-conventions/cf-conventions.html#azimuthal-equidistant
    rK   rJ   longitude_of_projection_originrM   rN   latitude_natural_originlongitude_natural_originrM   rN   )r   r.   r1   s    r4   _azimuthal_equidistantr`   x   sM     * ).Ms S!*/OQT!UmmOS9 }}%5s;	 rX   c                    	 | d   }t        || d   | j                  dd      | j                  d	d      | j                  d
d      | j                  dd            S # t         $ r ddd| d   j                            }Y xw xY w)_
    http://cfconventions.org/cf-conventions/cf-conventions.html#_geostationary_projection
    sweep_angle_axisyx)re   rd   fixed_angle_axisperspective_point_heightrK   rJ   r[   rM   rN   )rc   satellite_heightr]   r^   rM   rN   )r0   lowerr   r.   )r1   rc   s     r4   _geostationaryrj      s    W$%78 ,)"#=> ).Ms S!*/OQT!UmmOS9 }}%5s;   W!$3/	:L0M0S0S0UVWs   A "B ?B c           	          t        | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )b
    http://cfconventions.org/cf-conventions/cf-conventions.html#lambert-azimuthal-equal-area
    rK   rJ   r[   rM   rN   r\   )r
   r.   r_   s    r4   _lambert_azimuthal_equal_arearm      sM     / ).Ms S!*/OQT!UmmOS9 }}%5s;	 rX   c                 H   t        | d         \  }}|Qt        ||| j                  dd      | j                  dd      | j                  dd      | j                  dd            S t        || j                  dd      | j                  dd      | j                  dd            S )	X
    http://cfconventions.org/cf-conventions/cf-conventions.html#_lambert_conformal
    rE   rK   rJ   rL   rM   rN   rO   r\   )rH   r   r.   r   rV   s      r4   _lambert_conformal_conicrp      s     '>%&'#NO "1$2%4"+--0OQT"U#,==1PRU#V!*!D"+--0@#"F
 	
 . .!*/NPS!TmmOS9 }}%5s;	 rX   c           	      ,   d| v rBt        | d   | j                  dd      | j                  dd      | j                  dd            S t        | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )	e
    http://cfconventions.org/cf-conventions/cf-conventions.html#_lambert_cylindrical_equal_area
    !scale_factor_at_projection_originrL   rJ   rM   rN   )scale_factor_natural_originr^   rM   rN   rE   rP   r^   rM   rN   )r   r.   r   r_   s    r4   _lambert_cylindrical_equal_arearv      s     +i79(12U(V%.]]/& $--=$==)93?
 	
 1 ).A3 G!*/NPS!TmmOS9 }}%5s;	 rX   c           	      N   d| v rSt        | j                  dd      | j                  dd      | j                  dd      | j                  dd      | d         S t        | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )	O
    http://cfconventions.org/cf-conventions/cf-conventions.html#_mercator
    rs   rE   rJ   r[   rM   rN   r]   r^   rM   rN   rt   ru   )r   r.   r   r_   s    r4   	_mercatorrz      s     +i7"$-MM2Es$K%.]]0#& $--=$==)93?(12U(V
 	
  ).A3 G!*/OQT!UmmOS9 }}%5s;	 rX   c                     t        | d   | d   | d   d| j                  dd      | j                  dd      | j                  dd      	      S )
W
    http://cfconventions.org/cf-conventions/cf-conventions.html#_oblique_mercator
    rK   r[   azimuth_of_central_linerJ   rs         ?rM   rN   )latitude_projection_centrelongitude_projection_centreazimuth_projection_centre!angle_from_rectified_to_skew_gridscale_factor_projection_centreeasting_projection_centrenorthing_projection_centre)r	   r.   r_   s    r4   _oblique_mercatorr      s_     ,#,-L#M$-.N$O"+,E"F*-'0}}/(
 #,--"E#,==1A3#G
 
rX   c           	          t        | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )S
    http://cfconventions.org/cf-conventions/cf-conventions.html#_orthographic
    rK   rJ   r[   rM   rN   r\   )r   r.   r_   s    r4   _orthographicr      sM     " ).Ms S!*/OQT!UmmOS9 }}%5s;	 rX   c           
          d| v r5t        | d   | d   | j                  dd      | j                  dd            S t        | d   | d   | j                  dd      | j                  dd      | j                  dd	      
      S )Y
    http://cfconventions.org/cf-conventions/cf-conventions.html#polar-stereographic
    rE   %straight_vertical_longitude_from_polerM   rJ   rN   )latitude_standard_parallellongitude_originrM   rN   rK   rs   r~   ry   )r   r.   r   r_   s    r4   _polar_stereographicr     s     i','01D'E&'NO#--=$==)93?	
 	
 ) )*I J!*+R!SmmOS9 }}%5s;$-MM/%
 rX   c                 ~    t        | j                  dd      | j                  dd      | j                  dd            S )Q
    http://cfconventions.org/cf-conventions/cf-conventions.html#_sinusoidal
    r[   rJ   rM   rN   )r^   rM   rN   )r   r.   r_   s    r4   _sinusoidalr     s>      !*/OQT!UmmOS9 }}%5s; rX   c           
          t        | j                  dd      | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )	T
    http://cfconventions.org/cf-conventions/cf-conventions.html#_stereographic
    rK   rJ   r[   rM   rN   rs   r~   ry   )r   r.   r_   s    r4   _stereographicr   #  s^     # ).Ms S!*/OQT!UmmOS9 }}%5s;$-MM/%
 rX   c           
          t        | j                  dd      | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )	Z
    http://cfconventions.org/cf-conventions/cf-conventions.html#_transverse_mercator
    rK   rJ   rL   rM   rN    scale_factor_at_central_meridianr~   ry   )r   r.   r_   s    r4   _transverse_mercatorr   2  s^     ( ).Ms S!*/NPS!TmmOS9 }}%5s;$-MM.%
 rX   c           
          t        | d   | j                  dd      | j                  dd      | j                  dd      | j                  dd            S )Z
    http://cfconventions.org/cf-conventions/cf-conventions.html#vertical-perspective
    rg   rK   rJ   r[   rM   rN   )viewpoint_heightlatitude_topocentric_originlongitude_topocentric_originrM   rN   )r   r.   r_   s    r4   _vertical_perspectiver   A  sZ     )"#=>$-MM2QSV$W%.]],c&
  mmOS9 }}%5s; rX   c                 J    t        | d   | d   | j                  dd            S )S
    http://cfconventions.org/cf-conventions/cf-conventions.html#_rotated_pole
    grid_north_pole_latitudegrid_north_pole_longitudenorth_pole_grid_longituderJ   )r   r   r   )r   r.   r_   s    r4   _rotated_latitude_longituder   P  s2     *!*+E!F"+,G"H"+--0KS"Q rX   )albers_conical_equal_areaazimuthal_equidistantgeostationarylambert_azimuthal_equal_arealambert_conformal_coniclambert_cylindrical_equal_areamercatoroblique_mercatororthographicpolar_stereographic
sinusoidalstereographictransverse_mercatorvertical_perspectiverotated_latitude_longitudec                     i }| j                   D ]9  }|j                  ||j                  j                         j	                  dd      <   ; |S )N _)paramsvaluer&   ri   replace)	operation
param_dictparams      r4   _to_dictr   q  sL    J!! G;@;;
5::##%--c378GrX   c                 R    t        |       }d|d   |d   f|d   |d   |d   |d   dS )	zY
    http://cfconventions.org/cf-conventions/cf-conventions.html#_albers_equal_area

    r   !latitude_of_1st_standard_parallel!latitude_of_2nd_standard_parallellatitude_of_false_originlongitude_of_false_origineasting_at_false_originnorthing_at_false_origingrid_mapping_namerE   rK   rL   rM   rN   r   
conversionr   s     r4   !_albers_conical_equal_area__to_cfr   x  sX    
 j!F86767
 *00J)K)/0K)L 9: !;<
 
rX   c                 @    t        |       }d|d   |d   |d   |d   dS )rZ   r   latitude_of_natural_originlongitude_of_natural_originrM   rN   r   rK   r[   rM   rN   r   r   s     r4   _azimuthal_equidistant__to_cfr     s>     j!F4)/0L)M*01N*O0 !12 rX   c                     t        |       }d}| j                  j                         j                  dd      j	                  d      rd}d||d   |j                  dd	      |d
   |d   |d   dS )rb   rd   r   r   z	(sweep_x)re   r   rh   r   rJ   r   rM   rN   )r   rc   rg   rK   r[   rM   rN   )r   method_nameri   r   endswithr.   )r   r   rc   s      r4   _geostationary__to_cfr     s     j!F##%--c37@@M,,$*+=$> *04PRU)V*01N*O0 !12
 
rX   c                 @    t        |       }d|d   |d   |d   |d   dS )rl   r   r   r   rM   rN   r   r   r   s     r4   $_lambert_azimuthal_equal_area__to_cfr     s>     j!F;)/0L)M*01N*O0 !12 rX   c                     t        |       }| j                  j                         j                  d      rd|d   |d   f|d   |d   |d   |d   d	S d|d
   |d   |d   |d   dS )ro   z(2sp)r   r   r   r   r   r   r   r   r   r   rM   rN   r   rE   rL   rM   rN   r   r   ri   r   r   s     r4   _lambert_conformal_conic__to_cfr     s     j!F##%..w7!::;:;" .44N-O-34O-P#$=>$%?@

 
	
 7#$@A)/0M)N0 !12 rX   c                 @    t        |       }d|d   |d   |d   |d   dS )rr   r   r   r   rM   rN   r   r   r   s     r4   &_lambert_cylindrical_equal_area__to_cfr     s>     j!F=#$GH)/0M)N0 !12 rX   c                     t        |       }| j                  j                         j                  dd      j	                  d      rd|d   |d   |d   |d   |d	   d
S d|d   |d   |d   |d   dS )rx   r   r   z(variant_a)r   r   r   rM   rN   scale_factor_at_natural_origin)r   rE   r[   rM   rN   rs   r   )r   rE   r[   rM   rN   )r   r   ri   r   r   r   s     r4   _mercator__to_cfr     s     j!F##%--c37@@O!+!'(D!E.45R.S#O4$%561702	
 		
 (#$GH*01N*O0 !12 rX   c                     t        |       }|d   dk7  rt        j                  d       	 |d   }	 |d   }d|d	   |d
   |||d   |d   dS # t        $ r |d   }Y ,w xY w# t        $ r |d   }Y :w xY w)r|   r   r   zDangle from rectified to skew grid parameter lost in conversion to CFazimuth_of_initial_lineazimuth_at_projection_centrescale_factor_on_initial_line!scale_factor_at_projection_centrer   latitude_of_projection_centrelongitude_of_projection_centreeasting_at_projection_centrenorthing_at_projection_centre)r   rK   r[   r}   rs   rM   rN   )r   warningswarnr0   )r   r   r}   rs   s       r4   _oblique_mercator__to_cfr     s     j!F12a7R	
I"()B"CX,23Q,R) 0)/0O)P*01Q*R#:-N >? !@A   I"()G"HI  X,23V,W)Xs"   A A AAA0/A0c                 @    t        |       }d|d   |d   |d   |d   dS )r   r   r   r   rM   rN   r   r   r   s     r4   _orthographic__to_cfr     s>     j!F+)/0L)M*01N*O0 !12 rX   c                     t        |       }| j                  j                         j                  d      rd|d   |d   |d   |d   dS d|d   |d	   |d   |d   |d
   dS )r   z(variant b)r   latitude_of_standard_parallellongitude_of_originrM   rN   )r   rE   r   rM   rN   r   r   r   )r   rK   r   rM   rN   rs   r   r   s     r4   _polar_stereographic__to_cfr   '  s     j!F##%..}=!6!'(G!H5;<Q5R#O4$%56
 	
 3)/0L)M178U1V0 !12-34T-U rX   c                 8    t        |       }d|d   |d   |d   dS )r   r   r   rM   rN   )r   r[   rM   rN   r   r   s     r4   _sinusoidal__to_cfr   >  s5     j!F)*01N*O0 !12	 rX   c                 H    t        |       }d|d   |d   |d   |d   |d   dS )r   r   r   r   rM   rN   r   )r   rK   r[   rM   rN   rs   r   r   s     r4   _stereographic__to_cfr   K  sG     j!F,)/0L)M*01N*O0 !12-34T-U rX   c                 H    t        |       }d|d   |d   |d   |d   |d   dS )r   r   r   r   rM   rN   r   )r   rK   rL   rM   rN   r   r   r   s     r4   _transverse_mercator__to_cfr   Z  sG     j!F2)/0L)M)/0M)N0 !12,23S,T rX   c                 H    t        |       }d|d   |d   |d   |d   |d   dS )r   r   r   latitude_of_topocentric_originlongitude_of_topocentric_originrM   rN   )r   rg   rK   r[   rM   rN   r   r   s     r4   _vertical_perspective__to_cfr   i  sG     j!F3$*+=$>)/0P)Q*01R*S0 !12 rX   c                 >    t        |       }d|d   |d   dz
  |d   dS )r   r   o_lat_plon_0   o_lon_pr   r   r   r   r   r   s     r4   "_rotated_latitude_longitude__to_cfr  x  s7     j!F9$*9$5%+G_s%:%+I%6 rX   c                 8    t        |       }d|d   |d   |d   dS )z
    http://cfconventions.org/cf-conventions/cf-conventions.html#_rotated_pole

    https://github.com/OSGeo/PROJ/pull/2835
    r   z/grid_north_pole_latitude_(netcdf_cf_convention)z0grid_north_pole_longitude_(netcdf_cf_convention)z0north_pole_grid_longitude_(netcdf_cf_convention)r  r   r   s     r4   _pole_rotation_netcdf__to_cfr    s@     j!F9$*=%
 &,>&
 &,>&
 rX   albers_equal_areamodified_azimuthal_equidistantr   z!geostationary_satellite_(sweep_x)z!geostationary_satellite_(sweep_y)r   zlambert_conic_conformal_(2sp)zlambert_conic_conformal_(1sp)r   zmercator_(variant_a)zmercator_(variant_b)z#hotine_oblique_mercator_(variant_b)r   zpolar_stereographic_(variant_a)zpolar_stereographic_(variant_b)r   r   )r   r   )zproj ob_tran o_proj=longlatzproj ob_tran o_proj=lonlatzproj ob_tran o_proj=latlonzproj ob_tran o_proj=latlongz$pole rotation (netcdf cf convention))G__doc__r   pyproj._crsr   r   r   pyproj.crs.coordinate_operationr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pyproj.crs.datumr   r   r   pyproj.exceptionsr   r5   rB   rH   rW   r`   rj   rm   rp   rv   rz   r   r   r   r   r   r   r   r   _GRID_MAPPING_NAME_MAP!_GEOGRAPHIC_GRID_MAPPING_NAME_MAPr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  _INVERSE_GRID_MAPPING_NAME_MAP)_INVERSE_GEOGRAPHIC_GRID_MAPPING_NAME_MAP rX   r4   <module>r     s;    7 7     * O N &)X	+"	$	0*,"	, "<3#$A7&E)!/#/1 $ !"=% !
&*428.
*":"$&C" :" ()>	"
 ()>" #$H" $%D" $%D" %&L" ," ," *+C" (" &'B" &'B"  $!"" *#"$ 78'" . $F"D"D#E,H- )rX   