
    [j3J              
          S r SSKJr  SSKJr  SSKJrJr  SSKr	SSK
JrJrJr  SSKJrJrJrJrJrJr  SSKJr  SS	KJrJr  SSKr\" \5      R8                  R;                  5       S
-  rSSSSSSSSSS.	r\RA                  5        V Vs0 s H  u  pX_M	     snn r!/ SQr"SSSSSSS.r#S\" 5       ;   r$S r%\RL                  RO                  \(       + SS9r(\RL                  RO                  \(       + SS9r)\RL                  RO                  \(       + =(       d    \(       + SS9r*\RL                  RO                  \(       + SS9r+\RL                  RO                  \(       + SS9r,S r-\R\                  " SS9S 5       r/\R\                  " S S9S! 5       r0\R\                  " S \"S"9S# 5       r1\R\                  " S S$/S"9S% 5       r2\R\                  " S S9S& 5       r3\R\                  " S S9S' 5       r4\R\                  " SS9S( 5       r5\R\                  " SS9S) 5       r6\R\                  " SS9S* 5       r7\R\                  " SS9S+ 5       r8\R\                  " SS9S, 5       r9\R\                  " S S9S- 5       r:S. r;S/ r<\R\                  " S S$S0/S"9S1 5       r=\R\                  " S S9S2 5       r>\R\                  " S S9S3 5       r?\R\                  " S S9S4 5       r@\R\                  " S S9S5 5       rA\R\                  " S S9S6 5       rB\R\                  " S S9S7 5       rC\R\                  " S S9S8 5       rD\R\                  " S S9S9 5       rE\R\                  " S S9S: 5       rF\R\                  " S S9S; 5       rG\R\                  " S/ S<QS"9S= 5       rHgs  snn f )>zOModule with helper functions, fixtures, and common test data for pyogrio tests.    )BytesIO)Path)ZIP_DEFLATEDZipFileN)__gdal_version_string____version__list_drivers)
GDAL_GE_37HAS_ARROW_WRITE_APIHAS_GDAL_GEOSHAS_PYARROW
HAS_PYPROJHAS_SHAPELY)
vsi_rmtree)readwritefixtures
FlatGeobufGeoJSON
GeoJSONSeqGPKGzESRI Shapefile)	.fgb.geojson	.geojsonl	.geojsons.gpkg	.gpkg.zip.shpz.shp.zipz.shz)r   r   r   r   r      )r   r   r   r   r   r   Parquetc                     SR                  S [        [        5       R                  5       5       5       5      nS[         S[
         SU 3$ )Nz, c              3   6   #    U  H  u  pU S U S3v   M     g7f)()N ).0driver
capabilitys      Y/var/www/html/Sattelite-Image/venv/lib/python3.13/site-packages/pyogrio/tests/conftest.py	<genexpr>'pytest_report_header.<locals>.<genexpr>8   s'      "@F (!J<q!"@s   zpyogrio z
GDAL z
Supported drivers: )joinsortedr	   itemsr   r   )configdriverss     r)   pytest_report_headerr1   7   sU    ii "()=)=)?"@ G
 ;-  '( )%Y	(    zpyarrow required)reasonzpyproj requiredz&GDAL>=3.8 required for Arrow write APIz GDAL compiled with GEOS requiredzShapely >= 2.0 requiredc                 @   US:X  a!  [         (       d  [        R                  " S5        X R                  :X  a  U $ XR                   U 3-  nUR                  5       (       a  U$ [        U 5      u  pEpgUS:X  a  SUS'   SUS'   OUS;   a
  SUS'   S	US'   [        X6U40 UD6  U$ )
Nr   z&.gpkg.zip support requires GDAL >= 3.7r   Fspatial_indexUnknowngeometry_type)r   r   MultiPolygon)r
   pytestskipsuffixstemexistsr   r   )testfile_pathdst_dirextdst_pathmeta_geometry
field_datas           r)   prepare_testfilerF   T   s    
k**<=
"""../u55H$($7!DX
f} %_ )_	&	& %_ ._	(j1D1Or2   session)scopec                      [         $ N	_data_dirr%   r2   r)   data_dirrM   p   s    r2   functionc                 X    [        USS5      n[        [        S5      -  n[        X0U5      $ )Nparamr   +naturalearth_lowres/naturalearth_lowres.shp)getattrrL   r   rF   )tmp_pathrequestr@   r>   s       r)   naturalearth_lowresrU   u   s-    
'7F
+C%R SSMMS99r2   )rH   paramsc                 .    [        XUR                  5      $ rJ   rF   rP   rS   rU   rT   s      r)   naturalearth_lowres_all_extrZ   }       /7==IIr2   r   c                 .    [        XUR                  5      $ rJ   rX   rY   s      r)   naturalearth_lowres_geojsonr]      r[   r2   c                    XR                    S3-  n[        US[        SS9 nS H3  nUR                   SU 3nUR	                  UR
                  U-  U5        M5     SSS5        USU S	UR                    34$ ! , (       d  f       N"= f)
z4Wrap naturalearth_lowres as a zip file for VSI testsz.zipw   )modecompressioncompresslevel)dbfprjshpshxcpg.Nz/vsizip//)namer   r   r<   r   parent)rS   rU   pathoutr@   filenames         r)   naturalearth_lowres_vsirp      s     112$77D	C\	Ks6C-2231SE:HII)008;XF 7 
L
 8D6#6#;#;"<=== 
L	Ks   :A88
Bc              #      #    [        U 5      u  pp4SU R                   3n[        SU SU S35      nSUS'   SUS'   [        XcU4S	S
0UD6  Uv   [	        UR
                  5        g7f)z8Write naturalearth_lowres to a vsimem file for VSI testspyogrio_fixture_z/vsimem/rj   r   Fr5   r8   r7   layerrU   N)r   r<   r   r   r   rl   )rU   rB   rC   rD   rE   rk   rA   s          r)   naturalearth_lowres_vsimemrt      s~      %))<$=!DX16678DhtfAdV512H!D*D	(jN0ENN
Nxs   A#A%c                      [         S-  $ )Nzline_zm.gpkgrK   r%   r2   r)   line_zm_filerv      s    ~%%r2   c                      [         S-  $ )Nz
curve.gpkgrK   r%   r2   r)   
curve_filerx      s    |##r2   c                      [         S-  $ )Nzcurvepolygon.gpkgrK   r%   r2   r)   curve_polygon_filerz          ***r2   c                      [         S-  $ )Nzmultisurface.gpkgrK   r%   r2   r)   multisurface_filer}      r{   r2   c                      [         S-  $ )Nztest_gpkg_nulls.gpkgrK   r%   r2   r)   test_gpkg_nullsr      s    ---r2   c           	      Z    U S-  n[        USS [        R                  " / SQ5      /S/S9  U$ )Nztest_no_geometry.gpkgno_geometry)abccol)rs   rD   rE   fields)r   nparray)rS   ro   s     r)   no_geometry_filer      s;     11H	HH_-.w Or2   c                     SnU S-  n[        US5       nUR                  U5      nS S S 5        U$ ! , (       d  f       U$ = f)Na	  {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": {
                    "int": 1,
                    "list_int": [0, 1],
                    "list_double": [0.0, 1.0],
                    "list_string": ["string1", "string2"],
                    "list_int_with_null": [0, null],
                    "list_string_with_null": ["string1", null]
                },
                "geometry": { "type": "Point", "coordinates": [0, 2] }
            },
            {
                "type": "Feature",
                "properties": {
                    "int": 2,
                    "list_int": [2, 3],
                    "list_double": [2.0, 3.0],
                    "list_string": ["string3", "string4", ""],
                    "list_int_with_null": [2, 3],
                    "list_string_with_null": ["string3", "string4", ""]
                },
                "geometry": { "type": "Point", "coordinates": [1, 2] }
            },
            {
                "type": "Feature",
                "properties": {
                    "int": 3,
                    "list_int": [],
                    "list_double": [],
                    "list_string": [],
                    "list_int_with_null": [],
                    "list_string_with_null": []
                },
                "geometry": { "type": "Point", "coordinates": [2, 2] }
            },
            {
                "type": "Feature",
                "properties": {
                    "int": 4,
                    "list_int": null,
                    "list_double": null,
                    "list_string": null,
                    "list_int_with_null": null,
                    "list_string_with_null": null
                },
                "geometry": { "type": "Point", "coordinates": [2, 2] }
            },
            {
                "type": "Feature",
                "properties": {
                    "int": 5,
                    "list_int": null,
                    "list_double": null,
                    "list_string": [""],
                    "list_int_with_null": null,
                    "list_string_with_null": [""]
                },
                "geometry": { "type": "Point", "coordinates": [2, 2] }
            }
        ]
    }ztest_ogr_types_list.geojsonr_   openr   )rS   list_geojsonro   frC   s        r)   list_field_values_geojson_filer      sN    @	LD 77H	h	GGL! 
 O 
	 O   0
?c                     [         S-  n U R                  5       (       a  U $  SSKnSSKJn  SSKnUR                  UR                  UR                  [        R                  " S5      5      5      / S	QSS
/SS// SS/SS/SS// SS/SS// SQ/ SS//SS/SS// SS/SS// SQ/ SS//S.5      nUR                  XP5        U $ ! [
         a  n[        SU  SU S35      eSnAff = f)a5  Return the path to a Parquet file with list values in a property.

Because in the CI environments pyarrow.parquet is typically not available, we save
the file in the test data directory instead of always creating it from scratch.

The code to create it is here though, in case it needs to be recreated later.
zlist_field_values_file.parquetr   Nparquet
test file & does not exist, but error importing: ri   )r`      )r   r         r`   r   r   r   g        g      ?g       @g      @string1string2)string3string4 r   )rD   intlist_intlist_doublelist_stringlist_int_with_nulllist_string_with_nullrL   r=   pyarrowr   shapelyImportErrorRuntimeErrortableto_wkbpointsr   oneswrite_table)fixture_pathpapqr   exr   s         r)   list_field_values_parquet_filer     s(    ??L
) HHw~~bggfo'FG"Q!QT48 #Jc
BdCI&* %&t9q!fb$"ED!*&	
E. NN5'=  
&LRDPQR
 	

s   B? ?
C 	CC .parquetc                 n    UR                   S:X  a  [        U 5      $ UR                   S:X  a
  [        5       $ g )Nr   r   )rP   r   r   )rS   rT   s     r)   list_field_values_filesr   K  s3    }}
"-h77	*	$-// 
%r2   c                     SnU S-  n[        US5       nUR                  U5      nS S S 5        U$ ! , (       d  f       U$ = f)Na.  {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [0, 0]
                },
                "properties": {
                    "int_col": 1,
                    "float_col": 1.5,
                    "str_col": "string",
                    "bool_col": true,
                    "null_col": null,
                    "date_col": "2020-01-01",
                    "time_col": "12:00:00",
                    "datetime_col": "2020-01-01T12:00:00",
                    "list_int_col": [1, 2, 3],
                    "list_str_col": ["a", "b", "c"],
                    "list_mixed_col": [1, "a", null, true]
                }
            }
        ]
    }ztest_many_data_types.geojsonr_   r   )rS   many_types_geojsonro   r   rC   s        r)   many_data_types_geojson_filer   S  sN    	4 88H	h	GG&' 
 O 
	 Or   c                     SnU S-  n[        US5       nUR                  U5      nS S S 5        U$ ! , (       d  f       U$ = f)Na  {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [0, 0]
                },
                "properties": {
                    "top_level": "A",
                    "intermediate_level": {
                        "bottom_level": "B"
                    }
                }
            }
        ]
    }ztest_nested.geojsonr_   r   )rS   nested_geojsonro   r   rC   s        r)   nested_geojson_filer   w  sL    	N& //H	h	GGN# 
 O 
	 Or   c           	         [         S-  nUR                  5       (       a  U$  SSKnSSKJn  SSKnUR                  UR                  UR                  [        R                  " S5      5      5      / S	QS
SS./S-  S
SS./S-  /S-  / SQ/S-  S.5      nUR                  Xa5        U$ ! [
         a  n[        SU SU S35      eSnAff = f)a7  Create a Parquet file in tmp_path with nested values in a property.

Because in the CI environments pyarrow.parquet is typically not available, we save
the file in the test data directory instead of always creating it from scratch.

The code to create it is here though, in case it needs to be recreated later.
zlist_nested_struct_file.parquetr   Nr   r   r   ri   )r   r   )r   r   r   r   r   )r   r   r   )r   r   r   )rD   col_flat
col_struct
col_nestedcol_listr   )rS   r   r   r   r   r   r   s          r)   list_nested_struct_parquet_filer     s     @@L
) HHw~~bggfo'FG!!"+,q0"#!,-12Q6"a	
E NN5'!  
&LRDPQR
 	

s   B& &
C0CCc                     SnU S-  n[        US5       nUR                  U5      nS S S 5        U$ ! , (       d  f       U$ = f)Na  {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": { "col": "2020-01-01T09:00:00.123" },
                "geometry": { "type": "Point", "coordinates": [1, 1] }
            },
            {
                "type": "Feature",
                "properties": { "col": "2020-01-01T10:00:00" },
                "geometry": { "type": "Point", "coordinates": [2, 2] }
            }
        ]
    }ztest_datetime.geojsonr_   r   )rS   datetime_geojsonro   r   rC   s        r)   datetime_filer     sN    	  11H	h	GG$% 
 O 
	 Or   c                     SnU S-  n[        US5       nUR                  U5        S S S 5        U$ ! , (       d  f       U$ = f)Na  {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": { "datetime_col": "2020-01-01T09:00:00.123-05:00" },
                "geometry": { "type": "Point", "coordinates": [1, 1] }
            },
            {
                "type": "Feature",
                "properties": { "datetime_col": "2020-01-01T10:00:00-05:00" },
                "geometry": { "type": "Point", "coordinates": [2, 2] }
            }
        ]
    }ztest_datetime_tz.geojsonr_   r   rS   datetime_tz_geojsonro   r   s       r)   datetime_tz_filer     sL    	  44H	h		#$ 
 O 
	 Or   c                     [        [        [        S5      -  SS9u  pp4U S-  n[        XSU40 UD6  [	        US5       nUR                  5       nSSS5        U$ ! , (       d  f       W$ = f)zXExtracts first 3 records from naturalearth_lowres and writes to GeoJSON,
returning bytesrQ   r   max_featurestest.geojsonrbNr   rL   r   r   r   )rS   rB   rC   rD   rE   ro   r   bytes_buffers           r)   geojson_bytesr     st     %)DFGGVW%!DX .(H	(j1D1	h	vvx 
  
	 s   A
A&c                     SnU S-  n[        US5       nUR                  U5        S S S 5        U$ ! , (       d  f       U$ = f)Na  {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": { "datetime_col": "1670-01-01T09:00:00" },
                "geometry": { "type": "Point", "coordinates": [1, 1] }
            }
        ]
    }ztest_datetime_long_ago.geojsonr_   r   r   s       r)   geojson_datetime_long_agor      sL    		 ::H	h		#$ 
 O 
	 Or   c              #      #    [        [        [        S5      -  SS9u  pp4U S-  n[        XSU4SS0UD6  [	        US5       nUv   SSS5        g! , (       d  f       g= f7f)	zcExtracts first 3 records from naturalearth_lowres and writes to GeoJSON,
returning open file handlerQ   r   r   r   rs   testr   Nr   )rS   rB   rC   rD   rE   ro   r   s          r)   geojson_fileliker     sc      %)DFGGVW%!DX .(H	(j??$?	h	 
		s   >A A	A
AAc                     SnU S-  n[        US5       nUR                  U5      nS S S 5        U$ ! , (       d  f       U$ = f)Na  <?xml version="1.0" encoding="utf-8" ?>
        <kml xmlns="http://www.opengis.net/kml/2.2">
        <Document id="root_doc">
            <Schema name="interfaces1" id="interfaces1">
                <SimpleField name="id" type="float"></SimpleField>
                <SimpleField name="formation" type="string"></SimpleField>
            </Schema>
            <Folder><name>interfaces1</name>
                <Placemark>
                    <ExtendedData><SchemaData schemaUrl="#interfaces1">
                        <SimpleData name="formation">Ton</SimpleData>
                    </SchemaData></ExtendedData>
                    <Point><coordinates>19.1501280458077,293.313485355882</coordinates></Point>
                </Placemark>
            </Folder>
        </Document>
        </kml>
    ztest.kmlr_   r   )rS   kml_dataro   r   rC   s        r)   kml_filer   $  sK    H$ *$H	h	GGH 
 O 
	 Or   c                 R     " S S[         5      nSnU" UR                  S5      5      $ )Nc                        \ rS rSrS rS rSrg)-nonseekable_bytes.<locals>.NonSeekableBytesIOiC  c                     g)NFr%   )selfs    r)   seekable6nonseekable_bytes.<locals>.NonSeekableBytesIO.seekableD  s    r2   c                     [        S5      e)Nzcannot seek)OSError)r   argskwargss      r)   seek2nonseekable_bytes.<locals>.NonSeekableBytesIO.seekG  s    -((r2   r%   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes__r%   r2   r)   NonSeekableBytesIOr   C  s    		)r2   r   z{
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": { },
                "geometry": { "type": "Point", "coordinates": [1, 1] }
            }
        ]
    }zUTF-8)r   encode)rS   r   geojsons      r)   nonseekable_bytesr   @  s+    )W )		G gnnW566r2   ))CP932u   ﾎ)CP936u   中文)CP1250u   Đ)CP1252   ÿ)CP1253u   Φ)CP1256u   شc                     U R                   $ )a  Return tuple with encoding name and very short sample text in that encoding
NOTE: it was determined through testing that code pages for MS-DOS do not
consistently work across all Python installations (in particular, fail with conda),
but ANSI code pages appear to work properly.
)rP   )rT   s    r)   encoded_textr   Y  s    . ==r2   )I__doc__ior   pathlibr   zipfiler   r   numpyr   pyogrior   r   r	   pyogrio._compatr
   r   r   r   r   r   pyogrio.corer   pyogrio.rawr   r   r9   __file__rl   resolverL   DRIVERSr.   
DRIVER_EXTALL_EXTS	START_FIDGDAL_HAS_PARQUET_DRIVERr1   markskipifrequires_pyarrow_apirequires_pyprojrequires_arrow_write_apirequires_gdal_geosrequires_shapelyrF   fixturerM   rU   rZ   r]   rp   rt   rv   rx   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r@   r'   s   00r)   <module>r     sY   U   )  F F  $ # N!!))+j8	  
 .5]]_=_kcfk_=
= 	 $|~5 	 {{))k/BT)U ++$$^<M$N!;;--.;3 .  
 [[''@ (   ;;%%+o>W%X 8 i  ! j!: ": j2J 3J j*6J 7J j!	> "	> j!  "  i & !& i $ !$ i + !+ i + !+ i . !. j! "HV1h j*j)AB0 C0 j!  " F j! "8 j!# "#L j! "2 j! "2 j! "  j! "( j! " j! "6 j!7 "70 
"#"G >s   	N