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

Fix part_id for wk_collection_filter_geometry_start() #194

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

brownag
Copy link
Contributor

@brownag brownag commented Sep 18, 2023

Hi Dewey!

An issue seems to have popped up with wk v0.8.0. It appears wk_collection_filter_geometry_start() needs a minor change to order of operations to make sure the now-properly-incremented part_id is passed to next geometry_start()

With current CRAN version we get the following

# wk 0.8.0
p <- sf::st_as_sf(
  data.frame(x = -119.72330, y = 36.92204),
  coords = c('x', 'y'),
  crs = 4326
)
p2 <- rbind(p, p)
pm <- sf::st_combine(p2)

x <- wk::wk_collection(p2)
y <- wk::wk_collection(wk::as_wkt(p2))
z <- wk::wk_collection(pm)

x
#> Geometry set for 1 feature 
#> Geometry type: GEOMETRYCOLLECTION
#> Dimension:     XY
#> Bounding box:  xmin: -119.7233 ymin: 36.92204 xmax: -119.7233 ymax: 36.92204
#> Geodetic CRS:  WGS 84
#> GEOMETRYCOLLECTION (POINT (-119.7233 36.92204),...
y
#> <wk_wkt[1] with CRS=EPSG:4326>
#> [1] GEOMETRYCOLLECTION (POINT (-119.7233 36.92204)!!! Expected ',' or ')' but found 'POINT' at byte 46
z
#> Geometry set for 1 feature 
#> Geometry type: GEOMETRYCOLLECTION
#> Dimension:     XY
#> Bounding box:  xmin: -119.7233 ymin: 36.92204 xmax: -119.7233 ymax: 36.92204
#> Geodetic CRS:  WGS 84
#> GEOMETRYCOLLECTION (MULTIPOINT ((-119.7233 36.9...

Note the error message: !!! Expected ',' or ')' but found 'POINT' at byte 46 when creating a collection from wk_wkt object.

After the tiny fix in this PR we get:

p <- sf::st_as_sf(
  data.frame(x = -119.72330, y = 36.92204),
  coords = c('x', 'y'),
  crs = 4326
)
p2 <- rbind(p, p)
pm <- sf::st_combine(p2)

x <- wk::wk_collection(p2)
y <- wk::wk_collection(wk::as_wkt(p2))
z <- wk::wk_collection(pm)

x
#> Geometry set for 1 feature 
#> Geometry type: GEOMETRYCOLLECTION
#> Dimension:     XY
#> Bounding box:  xmin: -119.7233 ymin: 36.92204 xmax: -119.7233 ymax: 36.92204
#> Geodetic CRS:  WGS 84
#> GEOMETRYCOLLECTION (POINT (-119.7233 36.92204),...
y
#> <wk_wkt[1] with CRS=EPSG:4326>
#> [1] GEOMETRYCOLLECTION (POINT (-119.7233 36.92204), POINT (-119.7233 36.92204))
z
#> Geometry set for 1 feature 
#> Geometry type: GEOMETRYCOLLECTION
#> Dimension:     XY
#> Bounding box:  xmin: -119.7233 ymin: 36.92204 xmax: -119.7233 ymax: 36.92204
#> Geodetic CRS:  WGS 84
#> GEOMETRYCOLLECTION (MULTIPOINT ((-119.7233 36.9...

Let me know what you think!

 -  make sure the incremented part_id is passed to next geometry_start()
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (386b109) 99.02% compared to head (195154e) 99.02%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #194   +/-   ##
=======================================
  Coverage   99.02%   99.02%           
=======================================
  Files          85       85           
  Lines        6044     6044           
=======================================
  Hits         5985     5985           
  Misses         59       59           
Files Changed Coverage Δ
src/make-collection-filter.c 99.09% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@paleolimbot
Copy link
Owner

This is a great catch! Thank you!

@paleolimbot paleolimbot merged commit e244165 into paleolimbot:master Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants