Reading and converting gx:coord/gx:Track to Geometry#74
Reading and converting gx:coord/gx:Track to Geometry#74agent10 wants to merge 4 commits intogeorust:mainfrom
Conversation
|
@pjsier sure, this is my first time dealing with KML directly but I'll try! Thx! |
|
@pjsier Updated. I added an intermediate |
pjsier
left a comment
There was a problem hiding this comment.
Sorry for the delay! A few more things I didn't mention initially
- We'll need to add this to the overall
Kmlenum. That way, it's possible to parse KML regardless of the top-level element - We also need to add
Trackas an element that can be converted directly intogeo_types::Geometry. That way it's straightforward to pull all geometry types out into something that can be used with thegeo_typeslibrary
| } | ||
| } | ||
|
|
||
| impl<T> From<Track<T>> for LineString<T> |
There was a problem hiding this comment.
Is there a use case for converting to kml::LineString over geo_types::Geometry::LineString? It seems like that's what we'd be looking for and is easier to work with
There was a problem hiding this comment.
@pjsier i'm looking into this now, and in my case I have KML files where Track is inside Placemark, similar to the example I made for unit test
But the Placemark uses kml::Geometry internally, so that's why I've initially added a conversion to kml::LineString
Yeah, I'm going to add the general conversion to geo_types::Geometry::LineString but not sure how to deal with the use case above, pls advise..
There was a problem hiding this comment.
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 geo_types::Geometry<T>::try_from for Kml::Folder, Kml::KmlDocument, and Kml::Document. Kml::Placemark is only checking geometry like you mentioned here.
I'll open a quick PR in a bit, and then you should just be able to add a branch to the segment in TryFrom that adds this specific element
There was a problem hiding this comment.
@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 Placemark is implemented
| Some(Geometry::MultiGeometry(self.read_multi_geometry(attrs)?)) | ||
| } | ||
| b"Track" => { | ||
| geometry = Some(Geometry::LineString(self.read_track(attrs)?.into())); |
There was a problem hiding this comment.
I think we should be able to reference .coords here instead of the Track itself since LineString already has a From implementation for Vec<Coord<T>>
CHANGES.mdorCHANGELOG.mdThis PR adds an initial support of
gx:coord/gx:Tracktags from KML extension.This was also partly mentioned in #62.