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

Set the classes attribute for sfc_GEOMETRY #195

Merged
merged 2 commits into from
Oct 3, 2023
Merged

Conversation

paleolimbot
Copy link
Owner

The change here is still not quite right yet...it's supposed to be the same length as the vector, not just the unique classes of the geometries.

May fix r-spatial/sf#2234 if done correctly!

@paleolimbot
Copy link
Owner Author

@edzer Is there somewhere that attr(some_sfc, "classes") is documented? The issue is that wk is generating it improperly (which I should fix). If I understand it correctly, it should be a character vector with the same length as some_sfc as a cache of class(some_sfc[[i]]) for i in seq_along(some_sfc)?

@edzer
Copy link

edzer commented Oct 1, 2023

Not documented (good point!) - sfc_GEOMETRY objects need to have it, and it contains the middle (second) value of the class of an sfg object:

> st_sfc(st_point(0:1), st_linestring(matrix(1:4,2))) |> attr("classes")
[1] "POINT"      "LINESTRING"

AFAICS it's only used when converting to WKB.

@codecov-commenter
Copy link

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (e244165) 99.02% compared to head (f70b650) 99.02%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
- Coverage   99.02%   99.02%   -0.01%     
==========================================
  Files          85       85              
  Lines        6044     6040       -4     
==========================================
- Hits         5985     5981       -4     
  Misses         59       59              
Files Coverage Δ
src/sfc-writer.c 98.70% <100.00%> (-0.01%) ⬇️

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

@paleolimbot paleolimbot merged commit 4e1618d into master Oct 3, 2023
@paleolimbot paleolimbot deleted the fix-classes branch October 4, 2023 01:35
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.

Error: Not compatible with STRSXP: [type=NULL]
3 participants