|
1 | 1 | import pathlib |
2 | 2 |
|
| 3 | +import geoarrow.pyarrow as ga |
3 | 4 | import pyarrow as pa |
4 | 5 | import pyarrow.compute as pc |
5 | 6 | import pytest |
@@ -84,6 +85,39 @@ def test_harmonizing(file, path, config): |
84 | 85 | ) |
85 | 86 |
|
86 | 87 |
|
| 88 | +gps_test_files = [ |
| 89 | + (filename, TESTS_DATA_PATH / "files" / filename, conf) |
| 90 | + for filename, conf in CONFIG.get("files", {}).items() |
| 91 | + if conf.get("skip", False) is not True |
| 92 | + and conf.get("type", "").startswith("gps") |
| 93 | + and (TESTS_DATA_PATH / "files" / filename).exists() |
| 94 | +] |
| 95 | + |
| 96 | + |
| 97 | +@pytest.mark.timeout(10) |
| 98 | +@pytest.mark.parametrize("file,path,config", gps_test_files) |
| 99 | +def test_geometry_encoding_wkb(file, path, config): |
| 100 | + """Test that as_table() produces WKB-encoded geometry by default.""" |
| 101 | + parser_instance = detect_file(path) |
| 102 | + table = parser_instance.as_table() |
| 103 | + assert "geometry" in table.column_names |
| 104 | + geometry_type = table.schema.field("geometry").type |
| 105 | + assert isinstance(geometry_type, ga.GeometryExtensionType) |
| 106 | + assert geometry_type.encoding == ga.Encoding.WKB |
| 107 | + |
| 108 | + |
| 109 | +@pytest.mark.timeout(10) |
| 110 | +@pytest.mark.parametrize("file,path,config", gps_test_files) |
| 111 | +def test_geometry_encoding_geoarrow(file, path, config): |
| 112 | + """Test that as_table(geometry_encoding='geoarrow') preserves native encoding.""" |
| 113 | + parser_instance = detect_file(path) |
| 114 | + table = parser_instance.as_table(geometry_encoding="geoarrow") |
| 115 | + assert "geometry" in table.column_names |
| 116 | + geometry_type = table.schema.field("geometry").type |
| 117 | + assert isinstance(geometry_type, ga.GeometryExtensionType) |
| 118 | + assert geometry_type.encoding == ga.Encoding.GEOARROW |
| 119 | + |
| 120 | + |
87 | 121 | # @pytest.mark.timeout(10) |
88 | 122 | # @pytest.mark.parametrize("file,path,file_format", testdata_success) |
89 | 123 | # def test_original_data_preserved(file, path, file_format): |
|
0 commit comments