|
2 | 2 | from pathlib import Path
|
3 | 3 | from zipfile import ZIP_DEFLATED, ZipFile
|
4 | 4 |
|
| 5 | +import numpy as np |
| 6 | + |
5 | 7 | from pyogrio import (
|
6 | 8 | __gdal_version_string__,
|
7 | 9 | __version__,
|
@@ -126,28 +128,165 @@ def naturalearth_lowres_vsi(tmp_path, naturalearth_lowres):
|
126 | 128 |
|
127 | 129 |
|
128 | 130 | @pytest.fixture(scope="session")
|
129 |
| -def test_fgdb_vsi(): |
130 |
| - return f"/vsizip/{_data_dir}/test_fgdb.gdb.zip" |
| 131 | +def line_zm_file(): |
| 132 | + return _data_dir / "line_zm.gpkg" |
131 | 133 |
|
132 | 134 |
|
133 | 135 | @pytest.fixture(scope="session")
|
134 |
| -def test_gpkg_nulls(): |
135 |
| - return _data_dir / "test_gpkg_nulls.gpkg" |
| 136 | +def curve_file(): |
| 137 | + return _data_dir / "curve.gpkg" |
136 | 138 |
|
137 | 139 |
|
138 | 140 | @pytest.fixture(scope="session")
|
139 |
| -def test_ogr_types_list(): |
140 |
| - return _data_dir / "test_ogr_types_list.geojson" |
| 141 | +def curve_polygon_file(): |
| 142 | + return _data_dir / "curvepolygon.gpkg" |
141 | 143 |
|
142 | 144 |
|
143 | 145 | @pytest.fixture(scope="session")
|
144 |
| -def test_datetime(): |
145 |
| - return _data_dir / "test_datetime.geojson" |
| 146 | +def multisurface_file(): |
| 147 | + return _data_dir / "multisurface.gpkg" |
146 | 148 |
|
147 | 149 |
|
148 | 150 | @pytest.fixture(scope="session")
|
149 |
| -def test_datetime_tz(): |
150 |
| - return _data_dir / "test_datetime_tz.geojson" |
| 151 | +def test_gpkg_nulls(): |
| 152 | + return _data_dir / "test_gpkg_nulls.gpkg" |
| 153 | + |
| 154 | + |
| 155 | +@pytest.fixture(scope="function") |
| 156 | +def no_geometry_file(tmp_path): |
| 157 | + # create a GPKG layer that does not include geometry |
| 158 | + filename = tmp_path / "test_no_geometry.gpkg" |
| 159 | + write( |
| 160 | + filename, |
| 161 | + layer="no_geometry", |
| 162 | + geometry=None, |
| 163 | + field_data=[np.array(["a", "b", "c"])], |
| 164 | + fields=["col"], |
| 165 | + ) |
| 166 | + |
| 167 | + return filename |
| 168 | + |
| 169 | + |
| 170 | +@pytest.fixture(scope="function") |
| 171 | +def list_field_values_file(tmp_path): |
| 172 | + # Create a GeoJSON file with list values in a property |
| 173 | + list_geojson = """{ |
| 174 | + "type": "FeatureCollection", |
| 175 | + "features": [ |
| 176 | + { |
| 177 | + "type": "Feature", |
| 178 | + "properties": { "int64": 1, "list_int64": [0, 1] }, |
| 179 | + "geometry": { "type": "Point", "coordinates": [0, 2] } |
| 180 | + }, |
| 181 | + { |
| 182 | + "type": "Feature", |
| 183 | + "properties": { "int64": 2, "list_int64": [2, 3] }, |
| 184 | + "geometry": { "type": "Point", "coordinates": [1, 2] } |
| 185 | + }, |
| 186 | + { |
| 187 | + "type": "Feature", |
| 188 | + "properties": { "int64": 3, "list_int64": [4, 5] }, |
| 189 | + "geometry": { "type": "Point", "coordinates": [2, 2] } |
| 190 | + }, |
| 191 | + { |
| 192 | + "type": "Feature", |
| 193 | + "properties": { "int64": 4, "list_int64": [6, 7] }, |
| 194 | + "geometry": { "type": "Point", "coordinates": [3, 2] } |
| 195 | + }, |
| 196 | + { |
| 197 | + "type": "Feature", |
| 198 | + "properties": { "int64": 5, "list_int64": [8, 9] }, |
| 199 | + "geometry": { "type": "Point", "coordinates": [4, 2] } |
| 200 | + } |
| 201 | + ] |
| 202 | + }""" |
| 203 | + |
| 204 | + filename = tmp_path / "test_ogr_types_list.geojson" |
| 205 | + with open(filename, "w") as f: |
| 206 | + _ = f.write(list_geojson) |
| 207 | + |
| 208 | + return filename |
| 209 | + |
| 210 | + |
| 211 | +@pytest.fixture(scope="function") |
| 212 | +def nested_geojson_file(tmp_path): |
| 213 | + # create GeoJSON file with nested properties |
| 214 | + nested_geojson = """{ |
| 215 | + "type": "FeatureCollection", |
| 216 | + "features": [ |
| 217 | + { |
| 218 | + "type": "Feature", |
| 219 | + "geometry": { |
| 220 | + "type": "Point", |
| 221 | + "coordinates": [0, 0] |
| 222 | + }, |
| 223 | + "properties": { |
| 224 | + "top_level": "A", |
| 225 | + "intermediate_level": { |
| 226 | + "bottom_level": "B" |
| 227 | + } |
| 228 | + } |
| 229 | + } |
| 230 | + ] |
| 231 | + }""" |
| 232 | + |
| 233 | + filename = tmp_path / "test_nested.geojson" |
| 234 | + with open(filename, "w") as f: |
| 235 | + _ = f.write(nested_geojson) |
| 236 | + |
| 237 | + return filename |
| 238 | + |
| 239 | + |
| 240 | +@pytest.fixture(scope="function") |
| 241 | +def datetime_file(tmp_path): |
| 242 | + # create GeoJSON file with millisecond precision |
| 243 | + datetime_geojson = """{ |
| 244 | + "type": "FeatureCollection", |
| 245 | + "features": [ |
| 246 | + { |
| 247 | + "type": "Feature", |
| 248 | + "properties": { "col": "2020-01-01T09:00:00.123" }, |
| 249 | + "geometry": { "type": "Point", "coordinates": [1, 1] } |
| 250 | + }, |
| 251 | + { |
| 252 | + "type": "Feature", |
| 253 | + "properties": { "col": "2020-01-01T10:00:00" }, |
| 254 | + "geometry": { "type": "Point", "coordinates": [2, 2] } |
| 255 | + } |
| 256 | + ] |
| 257 | + }""" |
| 258 | + |
| 259 | + filename = tmp_path / "test_datetime.geojson" |
| 260 | + with open(filename, "w") as f: |
| 261 | + _ = f.write(datetime_geojson) |
| 262 | + |
| 263 | + return filename |
| 264 | + |
| 265 | + |
| 266 | +@pytest.fixture(scope="function") |
| 267 | +def datetime_tz_file(tmp_path): |
| 268 | + # create GeoJSON file with datetimes with timezone |
| 269 | + datetime_tz_geojson = """{ |
| 270 | + "type": "FeatureCollection", |
| 271 | + "features": [ |
| 272 | + { |
| 273 | + "type": "Feature", |
| 274 | + "properties": { "datetime_col": "2020-01-01T09:00:00.123-05:00" }, |
| 275 | + "geometry": { "type": "Point", "coordinates": [1, 1] } |
| 276 | + }, |
| 277 | + { |
| 278 | + "type": "Feature", |
| 279 | + "properties": { "datetime_col": "2020-01-01T10:00:00-05:00" }, |
| 280 | + "geometry": { "type": "Point", "coordinates": [2, 2] } |
| 281 | + } |
| 282 | + ] |
| 283 | + }""" |
| 284 | + |
| 285 | + filename = tmp_path / "test_datetime_tz.geojson" |
| 286 | + with open(filename, "w") as f: |
| 287 | + f.write(datetime_tz_geojson) |
| 288 | + |
| 289 | + return filename |
151 | 290 |
|
152 | 291 |
|
153 | 292 | @pytest.fixture(scope="function")
|
|
0 commit comments