
    njoK                         S SK r S SKrS SKJrJrJr  S rS rS r\R                  4S jr
\S:X  a#  \R                  " \
" \R                  5      5        gg)    N)gdalogrosrc                 v    [        SU (       a  [        R                  O[        R                  S9  U (       a  S$ S$ )Na  
Usage: ogr_layer_algebra.py [--help] [--help-general]
                            Union|Intersection|SymDifference|Identity|Update|Clip|Erase
                            -input_ds <path> [-input_lyr <name>]
                            -method_ds <path> [-method_lyr <name>]
                            -output_ds <path> [-output_lyr name] [-overwrite]
                            [-opt <NAME>=<VALUE>]...
                            [-f <format_name>] [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]...
                            [-input_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}] [-method_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}]
                            [-nlt <geom_type>] [-a_srs <srs_def>]file   r   )printsysstderrstdoutisErrors    Y/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/osgeo_utils/ogr_layer_algebra.pyUsager   (   s0    			E #SZZ

 1Q    c                 D    U R                  5       UR                  5       :H  $ )N)lower)abs     r   EQUALr   <   s    779	!!r   c
                    U R                  XX45      n
U
c  [        SU-  [        R                  S9  g US:X  a  US:X  a  U
$ SnSnU	 Hi  nUR	                  5       R                  S5      S:X  a  U[        S5      S  nM6  UR	                  5       R                  S5      S:X  d  M[  U[        S5      S  nMk     US:X  a  UR                  5       n[        UR                  5       5       H  nUR                  U5      n[        R                  " UUR                  5       -   UR                  5       5      nU
R                  U5      S:w  d  Ma  [        SUR                  5       < S	U
R                  5       < S
3[        R                  S9  M     OUS:w  a  UR                  5       nU H  nUR!                  U5      nUS:  a1  [        SU< S	UR                  5       < S
3[        R                  S9  MK  UR                  U5      n[        R                  " UUR                  5       -   UR                  5       5      nU
R                  U5      S:w  d  M  [        SU< S	U
R                  5       < S
3[        R                  S9  M     US:X  a  UR                  5       n[        UR                  5       5       H  nUR                  U5      n[        R                  " UUR                  5       -   UR                  5       5      nU
R                  U5      S:w  d  Ma  [        SUR                  5       < S	U
R                  5       < S
3[        R                  S9  M     U
$ US:w  a  UR                  5       nU H  nUR!                  U5      nUS:  a1  [        SU< S	UR                  5       < S
3[        R                  S9  MK  UR                  U5      n[        R                  " UUR                  5       -   UR                  5       5      nU
R                  U5      S:w  d  M  [        SU< S	U
R                  5       < S
3[        R                  S9  M     U
$ )NzCannot create layer "%s"r   ALL zinput_prefix=r   zmethod_prefix=zCannot create field "z" in layer ""NONEzCannot find field ")CreateLayerr
   r   r   r   findlenGetLayerDefnrangeGetFieldCountGetFieldDefnr   	FieldDefnGetNameGetTypeCreateFieldGetFieldIndex)	output_dsoutput_lyr_namesrs	geom_typelco	input_lyrinput_fields
method_lyrmethod_fieldsopt
output_lyrinput_prefixmethod_prefixval
layer_defnidxfld_defnflds                     r   r   r   C   s    &&YLJ(?:Lu%!7LM99;O,1s?356LYY[./14$4 5 78M	  u++-
1134C!..s3H}}x//1183C3C3EH %%h/14''):+=+=+?A 5 
	++-
C**3/CQwJ..02
 !..s3H}}x//1183C3C3EH %%h/14J..02  ( ,,.
1134C!..s3H}} 0 0 22H4D4D4FH %%h/14''):+=+=+?A 5D - 
&	 ,,.
 C**3/CQwJ..02
 !..s3H}} 0 0 22H4D4D4FH %%h/14J..02 !( r   c                    SnSnS nS nS nS nS nS nS n	/ n
/ n/ nSnSnS n[         R                  nS nS n[         R                  " U 5      n U c  gSnU[        U 5      :  Ga  U U   nUS:X  a	  [	        SS9$ US:X  a  US-   [        U 5      :  a  US-   nU U   nGOUS	:X  a  US-   [        U 5      :  a  US-   nU U   nGOUS
:X  a  US-   [        U 5      :  a  US-   nU U   nGObUS:X  a  US-   [        U 5      :  a  US-   nU U   nGO>US:X  a  US-   [        U 5      :  a  US-   nU U   nGOUS:X  a  US-   [        U 5      :  a  US-   nU U   nGOUS:X  a  US-   [        U 5      :  a  US-   nU U   nGOUS:X  a]  US-   [        U 5      :  aK  US-   n[        U U   S5      (       a  SnGO[        U U   S5      (       a  SnGOU U   R                  S5      nGOoUS:X  a]  US-   [        U 5      :  aK  US-   n[        U U   S5      (       a  SnGO:[        U U   S5      (       a  SnGO"U U   R                  S5      nGOUS:X  a-  US-   [        U 5      :  a  US-   nU
R                  U U   5        GOUS:X  a-  US-   [        U 5      :  a  US-   nUR                  U U   5        GOUS:X  a-  US-   [        U 5      :  a  US-   nUR                  U U   5        GOsUS:X  Ga  US-   [        U 5      :  Ga  US-   nU U   n[        US5      (       a  [         R                  nGO,[        US5      (       a  [         R                  nGO	[        US5      (       a  [         R                  nGO[        US5      (       a  [         R                  nGO[        US5      (       a  [         R                  nGO[        US5      (       a  [         R                  nGO}[        US5      (       a  [         R                  nGOZ[        US5      (       a  [         R                  nGO7[        US5      (       a  [         R                  nGO[        US5      (       a#  [         R                  [         R                   -  nGO[        US 5      (       a  [         R"                  nGO[        US!5      (       a  [         R$                  nGO[        US"5      (       a  [         R&                  nGOw[        US#5      (       a  [         R(                  nGOT[        US$5      (       a  [         R*                  nGO1[        US%5      (       a  [         R,                  nGO[        US&5      (       a  [         R.                  nO[1        S'U-  [2        R4                  S(9  gUS):X  a  US-   [        U 5      :  a  US-   nU U   nO[        US*5      (       a  S*n	O[        US+5      (       a  S+n	O[        US,5      (       a  S,n	Oq[        US-5      (       a  S-n	O][        US.5      (       a  S.n	OI[        US/5      (       a  S/n	O5[        US05      (       a  S0n	O!US1:X  a  S2nOUS3:X  d  US4:X  a  S2nO	[	        S2S9$ US-   nU[        U 5      :  a  GM  Ub	  Ub  Ub  U	c	  [	        S2S9$ Uc  U	S5;   a  SnOSnUS:X  a  US:X  a  [1        S6[2        R4                  S(9  [         R6                  " U5      nUc  [1        S7U-  [2        R4                  S(9  gUcA  UR9                  5       nUS:w  a  [1        S8[2        R4                  S(9  gUR;                  S5      nOUR=                  U5      nUc  [1        S9U-  [2        R4                  S(9  g[         R6                  " U5      nUc  [1        S:U-  [2        R4                  S(9  gUcA  UR9                  5       nUS:w  a  [1        S;[2        R4                  S(9  gUR;                  S5      nOUR=                  U5      nUc  [1        S<U-  [2        R4                  S(9  gUbi  [        US=5      (       dW  [        US5      (       dF  [>        R@                  " 5       nURC                  U5      S:w  a  [1        S>U-  [2        R4                  S(9  gOURE                  5       nURE                  5       nUc  Ub  [1        S?[2        R4                  S(9  ORUb  Uc  [1        S@[2        R4                  S(9  O3Ub0  Ub-  URG                  U5      S:w  a  [1        SA[2        R4                  S(9  [         RH                  " SSB9   [J        RL                  " 5          [         R6                  " USSC9nS S S 5        S S S 5        WGc  [         RH                  " SSB9   [J        RL                  " 5          [         R6                  " U5      nS S S 5        S S S 5        Ub  [1        SDU-  [2        R4                  S(9  g[         RN                  " U5      nUc  [1        SEU-  [2        R4                  S(9  gURQ                  XzSF9nUc  [1        SGU-  [2        R4                  S(9  g[        URS                  5       S5      (       as  Ucp  [        [T        RV                  RY                  U5      S   SH5      (       a?  [T        RV                  RY                  [T        RV                  R[                  U5      5      S   nUc  [1        SI[2        R4                  S(9  g[]        UUUUUUUUUU5
      nUc  gGOUR_                  5       nUcQ  UR9                  5       nUS:w  a  [1        SJ[2        R4                  S(9  gUR;                  S5      nURS                  5       nOUR=                  U5      nUc  [        URS                  5       S5      (       a  [        [T        RV                  RY                  U5      S   SH5      (       ap  [        U[T        RV                  RY                  [T        RV                  R[                  U5      5      S   5      (       d"  [1        SKU< SLU< SM3[2        R4                  S(9  g[]        UUUUUUUUUU5
      nUc  gU(       a  UR9                  5       nS n[a        U5       H/  nUR;                  U5      n U c  M  U RS                  5       U:X  d  M/    O   UU:w  aF  URc                  U5      S:w  a  [1        SN[2        R4                  S(9  g[]        UUUUUUUUUU5
      nUc  g[e        UU	5      n!U(       d  U!" UUU[J        Rf                  SO9n"OU!" UUUSF9n"S nS nS nU"S:w  a  [1        SPU	-  [2        R4                  S(9  gg! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f)QNzESRI ShapefileFr   r      z--helpr   z-fz	-input_dsz
-input_lyrz
-method_dsz-method_lyrz
-output_dsz-output_lyrz-input_fieldsr   ,z-method_fieldsz-dscoz-lcoz-optz-nltGEOMETRYPOINT
LINESTRINGPOLYGONGEOMETRYCOLLECTION
MULTIPOINTMULTILINESTRINGMULTIPOLYGONGEOMETRY25DPOINT25DLINESTRING25D
POLYGON25DGEOMETRYCOLLECTION25DMULTIPOINT25DMULTILINESTRING25DMULTIPOLYGON25Dz-nlt %s: type not recognised.r   z-a_srsUnionIntersectionSymDifferenceIdentityUpdateClipErasez
-overwriteTz-qz-quiet)rR   rS   rT   zUWarning: -input_fields NONE and -method_fields NONE results in all fields being addedzCannot open input dataset : %szWInput datasource has not a single layer, so you should specify its name with -input_lyrzCannot find input layer "%s"zCannot open method dataset : %szYMethod datasource has not a single layer, so you should specify its name with -method_lyrzCannot find method layer "%s"NULLz$Failed to process SRS definition: %szBWarning: input layer has no SRS defined, but method layer has one.zEWarning: input layer has a SRS defined, but method layer has not one.zwWarning: input and method layers have SRS defined, but they are not identical. No on-the-fly reprojection will be done.)useExceptions)updatezBOutput datasource "%s" exists, but cannot be opened in update modezCannot find driver %s)optionszCannot create datasource "%s"z.SHPz-output_lyr should be specifiedzYResult datasource has not a single layer, so you should specify its name with -output_lyrzCannot create layer "z" in a shapefile called "r   z.DeleteLayer() failed when overwrite requested.)rX   callbackz%An error occurred during %s operation)4r   
wkbUnknownGeneralCmdLineProcessorr   r   r   splitappendwkbNonewkbPointwkbLineString
wkbPolygonwkbGeometryCollectionwkbMultiPointwkbMultiLineStringwkbMultiPolygon	wkb25DBitwkbPoint25DwkbLineString25DwkbPolygon25DwkbGeometryCollection25DwkbMultiPoint25DwkbMultiLineString25DwkbMultiPolygon25Dr
   r   r   OpenGetLayerCountGetLayerGetLayerByNamer   SpatialReferenceSetFromUserInputGetSpatialRefIsSameExceptionMgrr   quiet_errorsGetDriverByNameCreateDataSourcer%   ospathsplitextbasenamer   	GetDriverr!   DeleteLayergetattrTermProgress_nocb)#argvdriver_namequietinput_ds_nameinput_lyr_namemethod_ds_namemethod_lyr_nameoutput_ds_namer*   op_strdscor-   r2   	overwriter/   r1   r,   srs_namer+   iargr6   input_dscntr.   	method_dsr0   srs2r)   drvr3   iLayerpoLayeroprets#                                      r   mainr      sV   "KEMNNONOFD
C
CILMIH
C&&t,D| 	
A
c$i-1g(?''D[QUSY.AAq'KKAECI$5AA GML QUSY%6AA!!WNL QUSY%6AA!!WNM!a!ec$i&7AA"1gOL QUSY%6AA!!WNM!a!ec$i&7AA"1gOO#AD	(9AAT!Wf%%%tAw&&$#Aw}}S1$$QT):AAT!Wf%% &tAw&& % $Qc 2G^AD	 1AAKKQ F]q1us4y0AAJJtAwF]q1us4y0AAJJtAwF]q1us4y0AAq'CS&!!KK	sJ''NN	sG$$LL	sL))--	sI&&NN	s01155	sL))--	s-..22	sN++//	sM**NNS]]:	sJ''OO	sO,,00	sL))--	s34488	sO,,00	s01155	s-..22	5;#**MH_QT!2AAAwH3  F3''#F3(($F3
##F3!!F3F3  FL ID[C8OE &&EY c$i-^ 	!!>T""00"M!Mv-6"9c	
 xx&H.>SZZP$$&!8iZZ %%a(	++N;	,~=CJJO (I/.@szzR%%'!8kZZ ''*
--o>
-?cjjQ Xv&&uXv/F/F&&(C##H-2:XECJJ %%''');4+TZZ _WZZ _!1cjj6F!6K JZZ 
			.0A0A0CHH^A6	 1D	.E2D4E4E4G0I 5H2 T !ZZ
 !!+.;)K7cjjI(((F	1NBT #++-!122'bgg&&~6q96BB gg..rww/?/?/OPQRSO"3#**E 

   !!#"))+Caxo "++A.J(002O"11/BJ!#++-)9::bgg..~>qA6JJ!'(()9)9.)IJ1M 
 *N< ZZ
 (# !
 %))+CF*#,,V4&7??+<+O % }((0A5H ZZ (# !
 %	F	#BZt?U?UVZ5HII
ax5>SZZPY 1D0C	.	. 5H4G22sH   t>t,.t>u",uu",
t;	6t>>
u
u	u""
u1__main__)rz   r   osgeor   r   r   r   r   r   r   r   __name__exit r   r   <module>r      sX   @ 
 
    
("eV hh Od zHHT#((^ r   