Closed mitchelloharawild closed 10 months ago
Geometry data for h3 is a character vector, and not a recognised sf geometry (expect df data input, not sf)
This should be fine and straight-forward enough, and I think I can re-use the underlying methods for using an encoded polyline (character vector).
Computing the bounding box for the h3 hexagons may require converting the hexagons twice. Once in R/Rcpp for computing bbox, second in deck.gl to add it to the map (is this necessary?).
yeah this could be tricky...
This should be fine and straight-forward enough, and I think I can re-use the underlying methods for using an encoded polyline (character vector).
Yep, I expected this might be similar. I may be wrong here, but does the polyline always have the sfencoded
data class? For h3 something simpler might suffice (just passing through the specified h3 column?).
yeah this could be tricky...
Could we simply disable the update_view
option for add_h3_hexagon()
and think about this more later? Is the bbox
used for anything else?
but does the polyline always have the sfencoded data class
No, it also works on a standard data.frame if polyline
is defined. So we can pass the 'h3' column in a similar way
Could we simply disable the update_view option for add_h3_hexagon() and think about this more later? Is the bbox used for anything else?
yes - this is what I'm doing for add_trips()
at the moment.
Do you have any example data I can use to start testing this?
Sure, here's a small set of h3 indices:
structure(list(h3 = c("85195187fffffff", "8519424bfffffff", "851951bbfffffff",
"8519518ffffffff", "851951b7fffffff", "8519424ffffffff", "851951a7fffffff",
"851951b3fffffff", "851951a3fffffff", "8519427bfffffff", "8519426bfffffff",
"85194243fffffff", "85194247fffffff")), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -13L))
I've pushed my start to adding the layer here: https://github.com/mitchelloharawild/mapdeck/commit/9231a869487619232dd53d81538e03114352fcb6
thanks. If / when you make a PR can you request it into branch issue243 please.
Can do. I'll probably have some more questions to come as I work on this more.
I might also update the underlying mapdeck/src and spatialwidget/api code to replace the 'polyline' in the function names to something more generic, like 'string' / 'character', or something else. I'll also document it here.
So your polyline methods essentially pass the input data through to JS without additional processing? If so, using the same methods for h3 may be appropriate.
yes, exactly.
You should just be able to call rcpp_point_polyline()
in place of this code
and for the js
code you'll need to use the polyline
method (without the decode_polyline()
call).
Is there something I'm missing here?
h3 <- structure(list(h3 = c("85195187fffffff", "8519424bfffffff", "851951bbfffffff", "851951b7fffffff", "851951a7fffffff", "851951a3fffffff", "8519427bfffffff", "8519426bfffffff", "85194247fffffff")), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -13L))
mapdeck() %>%
add_h3_hexagon(h3, hexagon = "h3")
The data coming back doesn't include the h3 column, and I'm not sure what is being done in spatialwidget::api::create_polyline
.
Can you make a PR and I'll check it out?
PR #244, thanks!
As per https://github.com/SymbolixAU/mapdeck/pull/247, the basic example works and is on branch issue243
. @mitchelloharawild thanks for getting this running. Sorry it took so long to get it pulled in.
I've merged this in to master
What do you want the feature to do? Add the H3 hexagon layer. https://github.com/uber/deck.gl/blob/master/docs/layers/h3-hexagon-layer.md
Happy to help with this, I briefly tried to add support for it but the input structure for the geometry is non-standard enough that I wanted to get your opinions before going further.
Some potential nuances for supporting this layer:
bbox
, second in deck.gl to add it to the map (is this necessary?).TODO