Skip to content
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

fix: allow cumulative innerBoundaryIs tags on a polygon #59

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

cfzimmerman
Copy link
Contributor

According to the Google KML docs, a Polygon is allowed to have "0 or more inner boundaries".
Source

In the current parser, the LinearRings within an innerBoundaryIs tags are assigned to the inner field of a parsed Polygon. However, if multiple innerBoundaryIs tags are present, only the last is currently assigned to the inner field of the Polygon. The proposed change appends output from innerBoundaryIs tags so that consecutive tags don't overwrite each other.

I created a small reproduction of this issue in a separate repo:

Aside:
This is my first open source contribution. If I'm missing anything, please let me know! I appreciate everyone's work on this library and am grateful for the opportunity to give back.

@pjsier
Copy link
Member

pjsier commented Dec 31, 2023

Thanks for the contribution! I'll take a closer look, but at first glance it looks good. Don't worry about the clippy error, that's not coming from you changes so we can handle that separately

Copy link
Member

@pjsier pjsier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! One small note and then this looks good to go

src/reader.rs Outdated
@@ -353,7 +353,10 @@ where
}
outer = outer_ring.remove(0);
}
b"innerBoundaryIs" => inner = self.read_boundary(b"innerBoundaryIs")?,
b"innerBoundaryIs" => {
let mut boundary = self.read_boundary(b"innerBoundaryIs")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the intermediate variable or would this be fine?

inner.append(&mut self.read_boundary(b"innerBoundaryIs")?);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point, thanks! Just made the change.

Copy link
Member

@pjsier pjsier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks again, merging now

@pjsier pjsier merged commit b51f414 into georust:main Jan 2, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants