pyogrio 0.8.0__cp312-cp312-win_amd64.whl → 0.10.0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyogrio might be problematic. Click here for more details.
- pyogrio/__init__.py +26 -18
- pyogrio/_compat.py +7 -1
- pyogrio/_env.py +4 -6
- pyogrio/_err.c +460 -445
- pyogrio/_err.cp312-win_amd64.pyd +0 -0
- pyogrio/_geometry.c +645 -612
- pyogrio/_geometry.cp312-win_amd64.pyd +0 -0
- pyogrio/_io.c +7764 -7602
- pyogrio/_io.cp312-win_amd64.pyd +0 -0
- pyogrio/_ogr.c +601 -609
- pyogrio/_ogr.cp312-win_amd64.pyd +0 -0
- pyogrio/_version.py +3 -3
- pyogrio/_vsi.c +7570 -2514
- pyogrio/_vsi.cp312-win_amd64.pyd +0 -0
- pyogrio/core.py +86 -20
- pyogrio/errors.py +9 -16
- pyogrio/gdal_data/GDAL-targets.cmake +1 -1
- pyogrio/gdal_data/GDALConfig.cmake +0 -1
- pyogrio/gdal_data/GDALConfigVersion.cmake +3 -3
- pyogrio/gdal_data/MM_m_idofic.csv +321 -0
- pyogrio/gdal_data/gdaltileindex.xsd +269 -0
- pyogrio/gdal_data/gdalvrt.xsd +130 -22
- pyogrio/gdal_data/ogrinfo_output.schema.json +23 -0
- pyogrio/gdal_data/ogrvrt.xsd +3 -0
- pyogrio/gdal_data/pci_datum.txt +222 -155
- pyogrio/gdal_data/pci_ellips.txt +90 -38
- pyogrio/gdal_data/vcpkg.spdx.json +21 -21
- pyogrio/gdal_data/vcpkg_abi_info.txt +27 -27
- pyogrio/geopandas.py +44 -27
- pyogrio/proj_data/proj-config-version.cmake +2 -2
- pyogrio/proj_data/proj-targets.cmake +1 -1
- pyogrio/proj_data/proj.db +0 -0
- pyogrio/proj_data/proj4-targets.cmake +1 -1
- pyogrio/proj_data/projjson.schema.json +1 -1
- pyogrio/proj_data/vcpkg.spdx.json +17 -17
- pyogrio/proj_data/vcpkg_abi_info.txt +15 -15
- pyogrio/raw.py +46 -30
- pyogrio/tests/conftest.py +206 -12
- pyogrio/tests/fixtures/README.md +32 -13
- pyogrio/tests/fixtures/curve.gpkg +0 -0
- pyogrio/tests/fixtures/{test_multisurface.gpkg → curvepolygon.gpkg} +0 -0
- pyogrio/tests/fixtures/line_zm.gpkg +0 -0
- pyogrio/tests/fixtures/multisurface.gpkg +0 -0
- pyogrio/tests/test_arrow.py +178 -24
- pyogrio/tests/test_core.py +162 -72
- pyogrio/tests/test_geopandas_io.py +341 -96
- pyogrio/tests/test_path.py +30 -17
- pyogrio/tests/test_raw_io.py +165 -54
- pyogrio/tests/test_util.py +56 -0
- pyogrio/util.py +55 -31
- pyogrio-0.10.0.dist-info/DELVEWHEEL +2 -0
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/LICENSE +1 -1
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/METADATA +37 -8
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/RECORD +74 -89
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/WHEEL +1 -1
- pyogrio.libs/{Lerc-62a2c1c74500e7815994b3e49b36750c.dll → Lerc-089e3fef3df84b17326dcddbf1dedaa4.dll} +0 -0
- pyogrio.libs/{gdal-2bfc6a9f962a8953b0640db9a272d797.dll → gdal-debee5933f0da7bb90b4bcd009023377.dll} +0 -0
- pyogrio.libs/{geos-289d7171bd083dfed1f8a90e4ae57442.dll → geos-ace4c5b5c1f569bb4213e7bbd0b0322e.dll} +0 -0
- pyogrio.libs/{geos_c-2a12859cd876719c648f1eb950b7d94c.dll → geos_c-7478ca0a86136b280d9b2d245c6f6627.dll} +0 -0
- pyogrio.libs/geotiff-c8fe8a095520a4ea4e465d27e06add3a.dll +0 -0
- pyogrio.libs/{iconv-2-f2d9304f8dc4cdd981024b520b73a099.dll → iconv-2-27352d156a5467ca5383d3951093ea5a.dll} +0 -0
- pyogrio.libs/{jpeg62-a67b2bf7fd32d34c565ae5bb6d47c224.dll → jpeg62-e56b6f95a95af498f4623b8da4cebd46.dll} +0 -0
- pyogrio.libs/{json-c-79a8df7e59952f5c5d594620e4b66c13.dll → json-c-c84940e2654a4f8468bfcf2ce992aa93.dll} +0 -0
- pyogrio.libs/libcurl-d69cfd4ad487d53d58743b6778ec85e7.dll +0 -0
- pyogrio.libs/{libexpat-fa55f107b678de136400c6d953c3cdde.dll → libexpat-6576a8d02641b6a3dbad35901ec200a7.dll} +0 -0
- pyogrio.libs/liblzma-9ee4accb476ec1ae24e924953140273d.dll +0 -0
- pyogrio.libs/{libpng16-6227e9a35c2a350ae6b0586079c10b9e.dll → libpng16-7c36142dda59f186f6bb683e8dae2bfe.dll} +0 -0
- pyogrio.libs/{msvcp140-46db46e967c8db2cb7a20fc75872a57e.dll → msvcp140-98b3e5b80de1e5e9d1703b786d795623.dll} +0 -0
- pyogrio.libs/proj-a408c5327f3fd2f5fabe8c56815beed7.dll +0 -0
- pyogrio.libs/{qhull_r-d8840f4ed1f7d452ff9a30237320bcfd.dll → qhull_r-516897f855568caab1ab1fe37912766c.dll} +0 -0
- pyogrio.libs/sqlite3-9bc109d8536d5ed9666332fec94485fc.dll +0 -0
- pyogrio.libs/{tiff-ffca1ff19d0e95dad39df0078fb037af.dll → tiff-9b3f605fffe0bccc0a964c374ee4f820.dll} +0 -0
- pyogrio.libs/{zlib1-aaba6ea052f6d3fa3d84a301e3eb3d30.dll → zlib1-e5af16a15c63f05bd82d90396807ae5b.dll} +0 -0
- pyogrio/_err.pxd +0 -4
- pyogrio/_err.pyx +0 -250
- pyogrio/_geometry.pxd +0 -4
- pyogrio/_geometry.pyx +0 -129
- pyogrio/_io.pxd +0 -0
- pyogrio/_io.pyx +0 -2738
- pyogrio/_ogr.pxd +0 -441
- pyogrio/_ogr.pyx +0 -346
- pyogrio/_vsi.pxd +0 -4
- pyogrio/_vsi.pyx +0 -140
- pyogrio/arrow_bridge.h +0 -115
- pyogrio/gdal_data/bag_template.xml +0 -201
- pyogrio/gdal_data/gmlasconf.xml +0 -169
- pyogrio/gdal_data/gmlasconf.xsd +0 -1066
- pyogrio/gdal_data/netcdf_config.xsd +0 -143
- pyogrio/gdal_data/template_tiles.mapml +0 -28
- pyogrio/tests/fixtures/test_datetime.geojson +0 -7
- pyogrio/tests/fixtures/test_datetime_tz.geojson +0 -8
- pyogrio/tests/fixtures/test_fgdb.gdb.zip +0 -0
- pyogrio/tests/fixtures/test_nested.geojson +0 -18
- pyogrio/tests/fixtures/test_ogr_types_list.geojson +0 -12
- pyogrio-0.8.0.dist-info/DELVEWHEEL +0 -2
- pyogrio.libs/geotiff-d1c0fcc3c454409ad8be61ff04a7422c.dll +0 -0
- pyogrio.libs/libcurl-7fef9869f6520a5fbdb2bc9ce4c496cc.dll +0 -0
- pyogrio.libs/liblzma-5a1f648afc3d4cf36e3aef2266d55143.dll +0 -0
- pyogrio.libs/proj-74051a73897c9fa6d7bfef4561688568.dll +0 -0
- pyogrio.libs/sqlite3-fe7a86058d1c5658d1f9106228a7fd83.dll +0 -0
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/top_level.txt +0 -0
pyogrio/tests/test_core.py
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
|
-
from numpy import
|
|
3
|
-
import pytest
|
|
4
|
+
from numpy import allclose, array_equal
|
|
4
5
|
|
|
5
6
|
from pyogrio import (
|
|
6
|
-
__gdal_version__,
|
|
7
7
|
__gdal_geos_version__,
|
|
8
|
+
__gdal_version__,
|
|
9
|
+
detect_write_driver,
|
|
10
|
+
get_gdal_config_option,
|
|
11
|
+
get_gdal_data_path,
|
|
8
12
|
list_drivers,
|
|
9
13
|
list_layers,
|
|
10
14
|
read_bounds,
|
|
11
15
|
read_info,
|
|
12
16
|
set_gdal_config_options,
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
vsi_listtree,
|
|
18
|
+
vsi_rmtree,
|
|
19
|
+
vsi_unlink,
|
|
15
20
|
)
|
|
16
|
-
from pyogrio.core import detect_write_driver
|
|
17
21
|
from pyogrio._compat import GDAL_GE_38
|
|
18
|
-
from pyogrio.errors import DataSourceError, DataLayerError
|
|
19
|
-
from pyogrio.tests.conftest import HAS_SHAPELY, prepare_testfile
|
|
20
|
-
|
|
21
22
|
from pyogrio._env import GDALEnv
|
|
23
|
+
from pyogrio.errors import DataLayerError, DataSourceError
|
|
24
|
+
from pyogrio.raw import read, write
|
|
25
|
+
from pyogrio.tests.conftest import START_FID, prepare_testfile, requires_shapely
|
|
26
|
+
|
|
27
|
+
import pytest
|
|
22
28
|
|
|
23
29
|
with GDALEnv():
|
|
24
30
|
# NOTE: this must be AFTER above imports, which init the GDAL and PROJ data
|
|
25
31
|
# search paths
|
|
26
|
-
from pyogrio._ogr import
|
|
32
|
+
from pyogrio._ogr import has_gdal_data, has_proj_data, ogr_driver_supports_write
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
try:
|
|
@@ -151,7 +157,16 @@ def test_list_drivers():
|
|
|
151
157
|
assert len(drivers) == len(expected)
|
|
152
158
|
|
|
153
159
|
|
|
154
|
-
def test_list_layers(
|
|
160
|
+
def test_list_layers(
|
|
161
|
+
naturalearth_lowres,
|
|
162
|
+
naturalearth_lowres_vsi,
|
|
163
|
+
naturalearth_lowres_vsimem,
|
|
164
|
+
line_zm_file,
|
|
165
|
+
curve_file,
|
|
166
|
+
curve_polygon_file,
|
|
167
|
+
multisurface_file,
|
|
168
|
+
no_geometry_file,
|
|
169
|
+
):
|
|
155
170
|
assert array_equal(
|
|
156
171
|
list_layers(naturalearth_lowres), [["naturalearth_lowres", "Polygon"]]
|
|
157
172
|
)
|
|
@@ -160,21 +175,27 @@ def test_list_layers(naturalearth_lowres, naturalearth_lowres_vsi, test_fgdb_vsi
|
|
|
160
175
|
list_layers(naturalearth_lowres_vsi[1]), [["naturalearth_lowres", "Polygon"]]
|
|
161
176
|
)
|
|
162
177
|
|
|
178
|
+
assert array_equal(
|
|
179
|
+
list_layers(naturalearth_lowres_vsimem),
|
|
180
|
+
[["naturalearth_lowres", "MultiPolygon"]],
|
|
181
|
+
)
|
|
182
|
+
|
|
163
183
|
# Measured 3D is downgraded to plain 3D during read
|
|
164
184
|
# Make sure this warning is raised
|
|
165
185
|
with pytest.warns(
|
|
166
186
|
UserWarning, match=r"Measured \(M\) geometry types are not supported"
|
|
167
187
|
):
|
|
168
|
-
|
|
169
|
-
# GDAL >= 3.4.0 includes 'another_relationship' layer
|
|
170
|
-
assert len(fgdb_layers) >= 7
|
|
188
|
+
assert array_equal(list_layers(line_zm_file), [["line_zm", "LineString Z"]])
|
|
171
189
|
|
|
172
|
-
|
|
173
|
-
|
|
190
|
+
# Curve / surface types are downgraded to plain types
|
|
191
|
+
assert array_equal(list_layers(curve_file), [["curve", "LineString"]])
|
|
192
|
+
assert array_equal(list_layers(curve_polygon_file), [["curvepolygon", "Polygon"]])
|
|
193
|
+
assert array_equal(
|
|
194
|
+
list_layers(multisurface_file), [["multisurface", "MultiPolygon"]]
|
|
195
|
+
)
|
|
174
196
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
assert array_equal(fgdb_layers[6], ["test_areas", "MultiPolygon Z"])
|
|
197
|
+
# Make sure that nonspatial layer has None for geometry
|
|
198
|
+
assert array_equal(list_layers(no_geometry_file), [["no_geometry", None]])
|
|
178
199
|
|
|
179
200
|
|
|
180
201
|
def test_list_layers_bytes(geojson_bytes):
|
|
@@ -184,6 +205,13 @@ def test_list_layers_bytes(geojson_bytes):
|
|
|
184
205
|
assert layers[0, 0] == "test"
|
|
185
206
|
|
|
186
207
|
|
|
208
|
+
def test_list_layers_nonseekable_bytes(nonseekable_bytes):
|
|
209
|
+
layers = list_layers(nonseekable_bytes)
|
|
210
|
+
|
|
211
|
+
assert layers.shape == (1, 2)
|
|
212
|
+
assert layers[0, 1] == "Point"
|
|
213
|
+
|
|
214
|
+
|
|
187
215
|
def test_list_layers_filelike(geojson_filelike):
|
|
188
216
|
layers = list_layers(geojson_filelike)
|
|
189
217
|
|
|
@@ -191,22 +219,18 @@ def test_list_layers_filelike(geojson_filelike):
|
|
|
191
219
|
assert layers[0, 0] == "test"
|
|
192
220
|
|
|
193
221
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
assert allclose(bounds[:, 0], [-180.0, -18.28799, 180.0, -16.02088])
|
|
202
|
-
|
|
222
|
+
@pytest.mark.parametrize(
|
|
223
|
+
"testfile",
|
|
224
|
+
["naturalearth_lowres", "naturalearth_lowres_vsimem", "naturalearth_lowres_vsi"],
|
|
225
|
+
)
|
|
226
|
+
def test_read_bounds(testfile, request):
|
|
227
|
+
path = request.getfixturevalue(testfile)
|
|
228
|
+
path = path if not isinstance(path, tuple) else path[1]
|
|
203
229
|
|
|
204
|
-
|
|
205
|
-
fids, bounds = read_bounds(naturalearth_lowres_vsi[1])
|
|
230
|
+
fids, bounds = read_bounds(path)
|
|
206
231
|
assert fids.shape == (177,)
|
|
207
232
|
assert bounds.shape == (4, 177)
|
|
208
|
-
|
|
209
|
-
assert fids[0] == 0
|
|
233
|
+
assert fids[0] == START_FID[Path(path).suffix]
|
|
210
234
|
# Fiji; wraps antimeridian
|
|
211
235
|
assert allclose(bounds[:, 0], [-180.0, -18.28799, 180.0, -16.02088])
|
|
212
236
|
|
|
@@ -218,6 +242,13 @@ def test_read_bounds_bytes(geojson_bytes):
|
|
|
218
242
|
assert allclose(bounds[:, 0], [-180.0, -18.28799, 180.0, -16.02088])
|
|
219
243
|
|
|
220
244
|
|
|
245
|
+
def test_read_bounds_nonseekable_bytes(nonseekable_bytes):
|
|
246
|
+
fids, bounds = read_bounds(nonseekable_bytes)
|
|
247
|
+
assert fids.shape == (1,)
|
|
248
|
+
assert bounds.shape == (4, 1)
|
|
249
|
+
assert allclose(bounds[:, 0], [1, 1, 1, 1])
|
|
250
|
+
|
|
251
|
+
|
|
221
252
|
def test_read_bounds_filelike(geojson_filelike):
|
|
222
253
|
fids, bounds = read_bounds(geojson_filelike)
|
|
223
254
|
assert fids.shape == (3,)
|
|
@@ -285,12 +316,9 @@ def test_read_bounds_bbox(naturalearth_lowres_all_ext):
|
|
|
285
316
|
fids, bounds = read_bounds(naturalearth_lowres_all_ext, bbox=(-85, 8, -80, 10))
|
|
286
317
|
|
|
287
318
|
assert fids.shape == (2,)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
else:
|
|
292
|
-
# fid in other formats is 0-based
|
|
293
|
-
assert array_equal(fids, [33, 34]) # PAN, CRI
|
|
319
|
+
fids_expected = np.array([33, 34]) # PAN, CRI
|
|
320
|
+
fids_expected += START_FID[naturalearth_lowres_all_ext.suffix]
|
|
321
|
+
assert array_equal(fids, fids_expected)
|
|
294
322
|
|
|
295
323
|
assert bounds.shape == (4, 2)
|
|
296
324
|
assert allclose(
|
|
@@ -302,9 +330,7 @@ def test_read_bounds_bbox(naturalearth_lowres_all_ext):
|
|
|
302
330
|
)
|
|
303
331
|
|
|
304
332
|
|
|
305
|
-
@
|
|
306
|
-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
|
|
307
|
-
)
|
|
333
|
+
@requires_shapely
|
|
308
334
|
@pytest.mark.parametrize(
|
|
309
335
|
"mask",
|
|
310
336
|
[
|
|
@@ -318,9 +344,7 @@ def test_read_bounds_mask_invalid(naturalearth_lowres, mask):
|
|
|
318
344
|
read_bounds(naturalearth_lowres, mask=mask)
|
|
319
345
|
|
|
320
346
|
|
|
321
|
-
@
|
|
322
|
-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
|
|
323
|
-
)
|
|
347
|
+
@requires_shapely
|
|
324
348
|
def test_read_bounds_bbox_mask_invalid(naturalearth_lowres):
|
|
325
349
|
with pytest.raises(ValueError, match="cannot set both 'bbox' and 'mask'"):
|
|
326
350
|
read_bounds(
|
|
@@ -328,9 +352,7 @@ def test_read_bounds_bbox_mask_invalid(naturalearth_lowres):
|
|
|
328
352
|
)
|
|
329
353
|
|
|
330
354
|
|
|
331
|
-
@
|
|
332
|
-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
|
|
333
|
-
)
|
|
355
|
+
@requires_shapely
|
|
334
356
|
@pytest.mark.parametrize(
|
|
335
357
|
"mask,expected",
|
|
336
358
|
[
|
|
@@ -361,12 +383,8 @@ def test_read_bounds_mask(naturalearth_lowres_all_ext, mask, expected):
|
|
|
361
383
|
|
|
362
384
|
fids = read_bounds(naturalearth_lowres_all_ext, mask=mask)[0]
|
|
363
385
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
assert array_equal(fids, np.array(expected) + 1)
|
|
367
|
-
else:
|
|
368
|
-
# fid in other formats is 0-based
|
|
369
|
-
assert array_equal(fids, expected)
|
|
386
|
+
fids_expected = np.array(expected) + START_FID[naturalearth_lowres_all_ext.suffix]
|
|
387
|
+
assert array_equal(fids, fids_expected)
|
|
370
388
|
|
|
371
389
|
|
|
372
390
|
@pytest.mark.skipif(
|
|
@@ -382,21 +400,15 @@ def test_read_bounds_bbox_intersects_vs_envelope_overlaps(naturalearth_lowres_al
|
|
|
382
400
|
if __gdal_geos_version__ is None:
|
|
383
401
|
# bboxes for CAN, RUS overlap but do not intersect geometries
|
|
384
402
|
assert fids.shape == (4,)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
else:
|
|
389
|
-
# fid in other formats is 0-based
|
|
390
|
-
assert array_equal(fids, [3, 4, 18, 27]) # CAN, USA, RUS, MEX
|
|
403
|
+
fids_expected = np.array([3, 4, 18, 27]) # CAN, USA, RUS, MEX
|
|
404
|
+
fids_expected += START_FID[naturalearth_lowres_all_ext.suffix]
|
|
405
|
+
assert array_equal(fids, fids_expected)
|
|
391
406
|
|
|
392
407
|
else:
|
|
393
408
|
assert fids.shape == (2,)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
else:
|
|
398
|
-
# fid in other formats is 0-based
|
|
399
|
-
assert array_equal(fids, [4, 27]) # USA, MEX
|
|
409
|
+
fids_expected = np.array([4, 27]) # USA, MEX
|
|
410
|
+
fids_expected += START_FID[naturalearth_lowres_all_ext.suffix]
|
|
411
|
+
assert array_equal(fids, fids_expected)
|
|
400
412
|
|
|
401
413
|
|
|
402
414
|
@pytest.mark.parametrize("naturalearth_lowres", [".shp", ".gpkg"], indirect=True)
|
|
@@ -426,7 +438,8 @@ def test_read_info(naturalearth_lowres):
|
|
|
426
438
|
elif naturalearth_lowres.suffix == ".shp":
|
|
427
439
|
# fid_column == "" for formats where fid is not physically stored
|
|
428
440
|
assert meta["fid_column"] == ""
|
|
429
|
-
# geometry_name == "" for formats where geometry column name cannot be
|
|
441
|
+
# geometry_name == "" for formats where geometry column name cannot be
|
|
442
|
+
# customized
|
|
430
443
|
assert meta["geometry_name"] == ""
|
|
431
444
|
assert meta["geometry_type"] == "Polygon"
|
|
432
445
|
assert meta["driver"] == "ESRI Shapefile"
|
|
@@ -435,8 +448,14 @@ def test_read_info(naturalearth_lowres):
|
|
|
435
448
|
raise ValueError(f"test not implemented for ext {naturalearth_lowres.suffix}")
|
|
436
449
|
|
|
437
450
|
|
|
438
|
-
|
|
439
|
-
|
|
451
|
+
@pytest.mark.parametrize(
|
|
452
|
+
"testfile", ["naturalearth_lowres_vsimem", "naturalearth_lowres_vsi"]
|
|
453
|
+
)
|
|
454
|
+
def test_read_info_vsi(testfile, request):
|
|
455
|
+
path = request.getfixturevalue(testfile)
|
|
456
|
+
path = path if not isinstance(path, tuple) else path[1]
|
|
457
|
+
|
|
458
|
+
meta = read_info(path)
|
|
440
459
|
|
|
441
460
|
assert meta["fields"].shape == (5,)
|
|
442
461
|
assert meta["features"] == 177
|
|
@@ -449,6 +468,13 @@ def test_read_info_bytes(geojson_bytes):
|
|
|
449
468
|
assert meta["features"] == 3
|
|
450
469
|
|
|
451
470
|
|
|
471
|
+
def test_read_info_nonseekable_bytes(nonseekable_bytes):
|
|
472
|
+
meta = read_info(nonseekable_bytes)
|
|
473
|
+
|
|
474
|
+
assert meta["fields"].shape == (0,)
|
|
475
|
+
assert meta["features"] == 1
|
|
476
|
+
|
|
477
|
+
|
|
452
478
|
def test_read_info_filelike(geojson_filelike):
|
|
453
479
|
meta = read_info(geojson_filelike)
|
|
454
480
|
|
|
@@ -483,8 +509,8 @@ def test_read_info_filelike(geojson_filelike):
|
|
|
483
509
|
),
|
|
484
510
|
],
|
|
485
511
|
)
|
|
486
|
-
def test_read_info_dataset_kwargs(
|
|
487
|
-
meta = read_info(
|
|
512
|
+
def test_read_info_dataset_kwargs(nested_geojson_file, dataset_kwargs, fields):
|
|
513
|
+
meta = read_info(nested_geojson_file, **dataset_kwargs)
|
|
488
514
|
assert meta["fields"].tolist() == fields
|
|
489
515
|
|
|
490
516
|
|
|
@@ -543,8 +569,8 @@ def test_read_info_unspecified_layer_warning(data_dir):
|
|
|
543
569
|
read_info(data_dir / "sample.osm.pbf")
|
|
544
570
|
|
|
545
571
|
|
|
546
|
-
def test_read_info_without_geometry(
|
|
547
|
-
assert read_info(
|
|
572
|
+
def test_read_info_without_geometry(no_geometry_file):
|
|
573
|
+
assert read_info(no_geometry_file)["total_bounds"] is None
|
|
548
574
|
|
|
549
575
|
|
|
550
576
|
@pytest.mark.parametrize(
|
|
@@ -586,3 +612,67 @@ def test_error_handling_warning(capfd, naturalearth_lowres):
|
|
|
586
612
|
read_info(naturalearth_lowres, INVALID="YES")
|
|
587
613
|
|
|
588
614
|
assert capfd.readouterr().err == ""
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
def test_vsimem_listtree_rmtree_unlink(naturalearth_lowres):
|
|
618
|
+
"""Test all basic functionalities of file handling in /vsimem/."""
|
|
619
|
+
# Prepare test data in /vsimem
|
|
620
|
+
meta, _, geometry, field_data = read(naturalearth_lowres)
|
|
621
|
+
meta["spatial_index"] = False
|
|
622
|
+
meta["geometry_type"] = "MultiPolygon"
|
|
623
|
+
test_file_path = Path("/vsimem/pyogrio_test_naturalearth_lowres.gpkg")
|
|
624
|
+
test_dir_path = Path(f"/vsimem/pyogrio_dir_test/{naturalearth_lowres.stem}.gpkg")
|
|
625
|
+
|
|
626
|
+
write(test_file_path, geometry, field_data, **meta)
|
|
627
|
+
write(test_dir_path, geometry, field_data, **meta)
|
|
628
|
+
|
|
629
|
+
# Check if everything was created properly with listtree
|
|
630
|
+
files = vsi_listtree("/vsimem/")
|
|
631
|
+
assert test_file_path.as_posix() in files
|
|
632
|
+
assert test_dir_path.as_posix() in files
|
|
633
|
+
|
|
634
|
+
# Check listtree with pattern
|
|
635
|
+
files = vsi_listtree("/vsimem/", pattern="pyogrio_dir_test*.gpkg")
|
|
636
|
+
assert test_file_path.as_posix() not in files
|
|
637
|
+
assert test_dir_path.as_posix() in files
|
|
638
|
+
|
|
639
|
+
files = vsi_listtree("/vsimem/", pattern="pyogrio_test*.gpkg")
|
|
640
|
+
assert test_file_path.as_posix() in files
|
|
641
|
+
assert test_dir_path.as_posix() not in files
|
|
642
|
+
|
|
643
|
+
# Remove test_dir and its contents
|
|
644
|
+
vsi_rmtree(test_dir_path.parent)
|
|
645
|
+
files = vsi_listtree("/vsimem/")
|
|
646
|
+
assert test_file_path.as_posix() in files
|
|
647
|
+
assert test_dir_path.as_posix() not in files
|
|
648
|
+
|
|
649
|
+
# Remove test_file
|
|
650
|
+
vsi_unlink(test_file_path)
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
def test_vsimem_rmtree_error(naturalearth_lowres_vsimem):
|
|
654
|
+
with pytest.raises(NotADirectoryError, match="Path is not a directory"):
|
|
655
|
+
vsi_rmtree(naturalearth_lowres_vsimem)
|
|
656
|
+
|
|
657
|
+
with pytest.raises(FileNotFoundError, match="Path does not exist"):
|
|
658
|
+
vsi_rmtree("/vsimem/non-existent")
|
|
659
|
+
|
|
660
|
+
with pytest.raises(
|
|
661
|
+
OSError, match="path to in-memory file or directory is required"
|
|
662
|
+
):
|
|
663
|
+
vsi_rmtree("/vsimem")
|
|
664
|
+
with pytest.raises(
|
|
665
|
+
OSError, match="path to in-memory file or directory is required"
|
|
666
|
+
):
|
|
667
|
+
vsi_rmtree("/vsimem/")
|
|
668
|
+
|
|
669
|
+
# Verify that naturalearth_lowres_vsimem still exists.
|
|
670
|
+
assert naturalearth_lowres_vsimem.as_posix() in vsi_listtree("/vsimem")
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def test_vsimem_unlink_error(naturalearth_lowres_vsimem):
|
|
674
|
+
with pytest.raises(IsADirectoryError, match="Path is a directory"):
|
|
675
|
+
vsi_unlink(naturalearth_lowres_vsimem.parent)
|
|
676
|
+
|
|
677
|
+
with pytest.raises(FileNotFoundError, match="Path does not exist"):
|
|
678
|
+
vsi_unlink("/vsimem/non-existent.gpkg")
|