-
Notifications
You must be signed in to change notification settings - Fork 199
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
Clip in BooleanOps flips some of the LineStrings in the MultiLineString #1245
Comments
Are you seeing this on geo-0.29.0, just released yesterday? There was a major change to the clip operation. Can you please provide a minimal example of the data set that produces this behavior? |
Yes this is on geo-0.29.0 I'll try and find an example |
The reversing is not unique to geo 0.29 but happens for all versions 0.29 - 0.23 |
Do you have sample input data as WKT, GeoJSON, etc? Ideally a minimally runnable script that shows this behavior |
use geo::{coord, BooleanOps, LineString, MultiLineString, Polygon};
fn main() {
// for any positive values in max coord > 3
let max = coord! {x: 6., y: 6.};
let extent = Polygon::new(
LineString::new(vec![
coord! {x: 0., y: max.y},
coord! {x: 0., y: 0.},
coord! {x: max.x, y: 0.},
coord! {x: max.x, y: max.y},
coord! {x: 0., y: max.y},
]),
vec![],
);
let lines = MultiLineString::new(vec![LineString::new(vec![
coord! {x: -1., y: max.y-1.},
coord! {x: max.x-1., y: -1.},
coord! {x: -1., y: 2.},
])]);
let expected = MultiLineString::new(vec![
LineString::new(vec![
coord! {x: 0., y: max.y-1. - max.y/max.x * 1.},
coord! {x: -1. + max.x/max.y * (max.y - 1.0), y: 0.},
]),
LineString::new(vec![
coord! {x: max.x-1. - max.x/3. * 1., y: 0.},
coord! {x: 0., y: -1. - 3./max.x * -(max.x-1.)},
]),
]);
let clipped_lines = extent.clip(&lines, false);
println!("clip extent: {:?}", extent);
println!("input: {:?}", lines);
println!("output: {:?}", clipped_lines);
println!(
"expected: {:?} (ordered as encountered along the input)",
expected
);
} Here you can see that the output differs from the expected in both the order of the segments (not important for me and guessing clip is not supposed to preserve 'internal' order anyways) and flips one of the output segments |
Yes, current algorithm does not keep original order. The current logic just traverse the graph and in fact it can be absolutly random. But it's not hard to keep it, I just haven't know that it's important. I'll try to fix it in the next version. |
Thank you for the good reproduction @oyhj1801, and thank you for taking prompt interest @NailxSharipov! |
I'm working with directed LineStrings and when I try and clip a MultiLineString to a Polygon extent some of the LineStrings get reversed.
Before clipping:
After clipping
The teeth are pointing 90 degrees to the left of the direction of the LineString.
In the upper image some LineStrings are on top of each other where two tiles overlap, after clipping all map-tiles to the intended extent, no LinesStrings overlap but some have been reversed (indicated by the teeth pointing in the opposite direction) as can be seen in the bottom image.
The text was updated successfully, but these errors were encountered: