Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test data covering various options in the spec #134

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ on:
pull_request:

jobs:
validate-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install validator
run: |
cd validator/python
python -m pip install --no-binary geoparquet_validator .

- name: Run validator
run: |
for example in $(ls examples/*.parquet); do
echo $example;
geoparquet_validator $example || exit 1;
done
for example in $(ls test_data/*.parquet); do
echo $example;
geoparquet_validator $example || exit 1;
done


test-json-metadata:
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions test_data/data_crs_null.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"geo": {
"columns": {
"geometry": {
"crs": null,
"encoding": "WKB",
"geometry_type": "Unknown"
}
},
"primary_column": "geometry",
"version": "0.4.0"
}
}
Binary file added test_data/data_crs_null.parquet
Binary file not shown.
12 changes: 12 additions & 0 deletions test_data/data_geometry_column_name.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"geo": {
"columns": {
"geom": {
"encoding": "WKB",
"geometry_type": "Unknown"
}
},
"primary_column": "geometry",
"version": "0.4.0"
}
}
Binary file added test_data/data_geometry_column_name.parquet
Binary file not shown.
Binary file added test_data/data_geometry_type.parquet
Binary file not shown.
12 changes: 12 additions & 0 deletions test_data/data_minimal.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"geo": {
"columns": {
"geometry": {
"encoding": "WKB",
"geometry_type": "Unknown"
}
},
"primary_column": "geometry",
"version": "0.4.0"
}
}
Binary file added test_data/data_minimal.parquet
Binary file not shown.
13 changes: 13 additions & 0 deletions test_data/data_orientation.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"geo": {
"columns": {
"geometry": {
"encoding": "WKB",
"geometry_type": "Unknown",
"orientation": "counterclockwise"
}
},
"primary_column": "geometry",
"version": "0.4.0"
}
}
Binary file added test_data/data_orientation.parquet
Binary file not shown.
57 changes: 57 additions & 0 deletions test_data/generate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,63 @@
}


## Various metadata variations

# Minimum required metadata

table = pa.table(
{"col": range(3), "geometry": to_wkb(from_wkt(["POINT (1 1)", "POINT (2 2)", "POINT (3 3)"]))}
)
metadata = copy.deepcopy(metadata_template)
table = table.replace_schema_metadata({"geo": json.dumps(metadata)})
pq.write_table(table, HERE / "data_minimal.parquet")


# Geometry type

table = pa.table(
{"col": range(3), "geometry": to_wkb(from_wkt(["POINT (1 1)", "POINT (2 2)", "POINT (3 3)"]))}
)
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["geometry_types"] = ["Point"]
table = table.replace_schema_metadata({"geo": json.dumps(metadata)})
pq.write_table(table, HERE / "data_geometry_type.parquet")


# Geometry column name

table = pa.table(
{"col": range(3), "geom": to_wkb(from_wkt(["POINT (1 1)", "POINT (2 2)", "POINT (3 3)"]))}
)
metadata = copy.deepcopy(metadata_template)
metadata["primary_column"] = "geom"
metadata["columns"]["geom"] = metadata["columns"].pop("geometry")
table = table.replace_schema_metadata({"geo": json.dumps(metadata)})
pq.write_table(table, HERE / "data_geometry_column_name.parquet")


# CRS - explicit null

table = pa.table(
{"col": range(3), "geometry": to_wkb(from_wkt(["POINT (1 1)", "POINT (2 2)", "POINT (3 3)"]))}
)
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["crs"] = None
table = table.replace_schema_metadata({"geo": json.dumps(metadata)})
pq.write_table(table, HERE / "data_crs_null.parquet")


# Orientation

table = pa.table(
{"col": range(3), "geometry": to_wkb(from_wkt(["POINT (1 1)", "POINT (2 2)", "POINT (3 3)"]))}
)
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["orientation"] = "counterclockwise"
table = table.replace_schema_metadata({"geo": json.dumps(metadata)})
pq.write_table(table, HERE / "data_orientation.parquet")


## Various geometry types with WKB and native (GeoArrow-based) encodings

def write_encoding_files(geometries_wkt, geometries_geoarrow, geometry_type):
Expand Down
Loading