mthh / contour-rs

Contour polygon creation in Rust (using marching squares algorithm)
https://crates.io/crates/contour
Apache License 2.0
52 stars 10 forks source link

[FR] Nodata value and incomplete ring support #16

Open netthier opened 6 months ago

netthier commented 6 months ago

I want to be able to generate contours that do not include lines on data/nodata borders, 'nodata' being any value either outside the grid or a specifically chosen one inside of it, commonly f32::MAX or f64::MAX, e.g. (nodata marked red): Without nodata handling: image

With nodata handling: image

This also prevents a ring forming around the whole dataset, as seen in https://github.com/mthh/contour-rs/issues/7. While I'm aware of the workaround proposed in the issue, it is not sufficiently performant for me. I started implementing this feature here: https://github.com/SenseLabsDE/contour-rs/tree/nodata, but the current version is relatively inefficient and results in slowdowns even if the feature is unused.

mthh commented 6 months ago

Yes, these are two totally valid use cases that should be supported by this library.

I think it would also be an opportunity to properly support the presence of NaN and (NEG_)INFINITY in the entry grid.