paleolimbot / wk

Lightweight Well-Known Geometry Parsing
https://paleolimbot.github.io/wk
Other
45 stars 6 forks source link

Set the classes attribute for sfc_GEOMETRY #195

Closed paleolimbot closed 11 months ago

paleolimbot commented 11 months ago

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 https://github.com/r-spatial/sf/issues/2234 if done correctly!

paleolimbot commented 11 months ago

@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 commented 11 months ago

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 commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/paleolimbot/wk/pull/195?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Dewey+Dunnington) | Coverage Δ | | |---|---|---| | [src/sfc-writer.c](https://app.codecov.io/gh/paleolimbot/wk/pull/195?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Dewey+Dunnington#diff-c3JjL3NmYy13cml0ZXIuYw==) | `98.70% <100.00%> (-0.01%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.