dabreegster / odjitter

Disaggregate zone-based origin/destination data to specific points
Apache License 2.0
12 stars 6 forks source link

Jittering fails when input zones.geojson file contains mixxed geometry types #30

Open Robinlovelace opened 2 years ago

Robinlovelace commented 2 years ago

This was the cause of errors that were driving me insane, no need for a fix on the Rust side and it's an edge case that can be seen as an issue with dodgy input data my side. Still wanted to document it here while it's fresh in my head.

Input zone object that failed looked broadly like this:

Simple feature collection with 14 features and 2 fields
Geometry type: GEOMETRY
Dimension:     XY
Bounding box:  xmin: -6.918001 ymin: 53.00297 xmax: -6.71583 ymax: 53.27975
Geodetic CRS:  WGS 84
# A tibble: 14 × 3
   geo_code  social                                                                                             geometry
 * <chr>      <dbl>                                                                                       <GEOMETRY [°]>
 1 o06065     1118. MULTIPOLYGON (((-6.71583 53.16379, -6.716134 53.16175, -6.728203 53.15357, -6.731625 53.15206, -6...
 2 o06029      337. MULTIPOLYGON (((-6.828214 53.01617, -6.834301 53.0142, -6.846945 53.0165, -6.851927 53.02025, -6....
 3 o06075      865. MULTIPOLYGON (((-6.82495 53.27751, -6.821514 53.27175, -6.82003 53.27001, -6.821732 53.2688, -6.8...
 4 d35402922     1  POLYGON ((-6.747552 53.1533, -6.747565 53.15278, -6.747606 53.15226, -6.747675 53.15174, -6.74777...

Note MULTIPOLYGON objects suddenly switch to POLYGON objects. Attached is a .zip of a reproducible example that worked post simply changing the geometry type. test-data.zip

Robinlovelace commented 2 years ago

test-data.zip And for completeness, in the unlikely event anyone other than me actually wants to try to run this, here's the inputs that fail with this cryptic error message:

thread 'main' panicked at 'no entry found for key', /home/robin/.cargo/git/checkouts/odjitter-2ee039e64a6d7c8d/95ad39e/src/lib.rs:199:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
dabreegster commented 2 years ago

We should add a better error message at the line where it failed, following similar examples elsewhere