-
Notifications
You must be signed in to change notification settings - Fork 32
Reading and converting gx:coord/gx:Track to Geometry #74
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| /target | ||
| /Cargo.lock | ||
| .idea/* | ||
| **/*.rs.bk | ||
| rusty-tags.emacs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ use std::collections::HashMap; | |
|
|
||
| use crate::types::altitude_mode::AltitudeMode; | ||
| use crate::types::coord::{Coord, CoordType}; | ||
| use crate::types::Track; | ||
|
|
||
| /// `kml:LineString`, [10.7](http://docs.opengeospatial.org/is/12-007r2/12-007r2.html#488) in the | ||
| /// KML specification | ||
|
|
@@ -25,3 +26,15 @@ where | |
| } | ||
| } | ||
| } | ||
|
|
||
| impl<T> From<Track<T>> for LineString<T> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a use case for converting to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pjsier i'm looking into this now, and in my case I have KML files where Yeah, I'm going to add the general conversion to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thanks for flagging that! I think that also highlights a gap we can clean up here. Right now we're only parsing child elements in I'll open a quick PR in a bit, and then you should just be able to add a branch to the segment in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @agent10 on second though, I looked into this more, and it would be a much more substantial change. To keep this simple and avoid mixing the items up too much I added a comment below, and then in a separate PR I might need to rethink how |
||
| where | ||
| T: CoordType + Default, | ||
| { | ||
| fn from(track: Track<T>) -> Self { | ||
| LineString { | ||
| coords: track.coords, | ||
| ..Default::default() | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| use std::collections::HashMap; | ||
|
|
||
| use crate::types::coord::CoordType; | ||
| use crate::types::Coord; | ||
|
|
||
| /// `kml:Track`, [10.15](https://docs.ogc.org/is/12-007r2/12-007r2.html#611) in the KML | ||
| /// specification | ||
| #[derive(Clone, Debug, Default, PartialEq, Eq)] | ||
| pub struct Track<T: CoordType = f64> { | ||
| pub coords: Vec<Coord<T>>, | ||
| pub attrs: HashMap<String, String>, | ||
| } | ||
|
|
||
| impl<T> Track<T> | ||
| where | ||
| T: CoordType + Default, | ||
| { | ||
| pub fn new(coords: Vec<Coord<T>>) -> Self { | ||
| Track { | ||
| coords, | ||
| ..Default::default() | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to reference
.coordshere instead of theTrackitself sinceLineStringalready has aFromimplementation forVec<Coord<T>>