-
Notifications
You must be signed in to change notification settings - Fork 10
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
[FR] Sparse representation of input #17
Comments
It's a good idea, let me think about it for a moment and discuss the solutions available to us here. |
I have started implementing this as I need this feature: https://github.com/SenseLabsDE/contour-rs/tree/grid pub trait Grid<V> where V: GridValue {
fn extents(&self) -> impl IntoIterator<Item = Extent>;
fn size(&self) -> (usize, usize);
fn get_point(&self, coord: Coord<i64>) -> Option<V>;
}
pub struct Extent {
pub top_left: Coord<i64>,
pub bottom_right: Coord<i64>,
} and new container types implementing said trait. One of them is
I've also done a lot of opinionated changes on that branch, which may need to be undone if you want to merge this, like removing the |
Thanks for proposing to contribute this new feature, it sounds like a very useful addition. And I'm on your side regarding the deletion of the
@hakolao Would such a generic implementation on the type of numerical values used in the input grid (thus allowing the use of grids with
I'll take a closer look at the code and at the benchmarks (current implementation vs. that of #14 vs. that of your grid branch) by the end of the week but I'd be happy to see this proposal merged, as it seems to provide a significant gain for some use cases (the dataset you were working on seems to me to be a case that can be encountered relatively often). In addition, having better management of no data values is certainly a good thing. |
My grid branch probably won't be ready by the end of the week, there are still some issues I'm figuring out
And additional benchmarks with criterion have shown a bit of a stronger performance decline compared to #14. EDIT: I implemented my solution for 2., but haven't tested it for correctness yet. It looks correct on a surface level though. |
I have a dataset where the vast majority of values are nodata values (#16).
The bounding box is substantially larger than what would be required if the data were e.g. tiled or stored in some other compressed format. This prevents me from doing calculations at the precision I'd like to, as I'm running out of memory.
I think it would be useful if contour-rs accepted grids of formats other than
Vec
. Maybe making the methods generic over some trait that providesfn get_value(x: usize, y: usize) -> Option<V>
could work? Such a trait could also help solving #16, since an implementation could returnNone
for such values.Apparently there are also optimized variants of marching squares for sparse matrices, maybe it would be useful to choose a type of input that would allow to take advantage of them, e.g. https://www.diva-portal.org/smash/record.jsf?pid=diva2%3A1675180&dswid=-8922
The text was updated successfully, but these errors were encountered: