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

nit: README.md example should use Document(…) #1

Closed
stapelberg opened this issue Jul 20, 2017 · 3 comments
Closed

nit: README.md example should use Document(…) #1

stapelberg opened this issue Jul 20, 2017 · 3 comments

Comments

@stapelberg
Copy link

Thanks for this useful library!

I noticed that the example from README.md cannot be imported into Google Earth as-is because it nests Placemarks underneath the <kml> tag, whereas it should nest them underneath a <Document> tag.

Other examples are correct in that regard, but it would be good to fix this one, too, I think :)

@twpayne
Copy link
Owner

twpayne commented Jul 24, 2017

Thanks for the feedback!

This example is taken from the first example in the KML tutorial.

From my understanding of the KML specification, a kml containing a single top-level Placemark is allowed:

  • kml Elements: "A basic element contains 0 or 1 Feature and 0 or 1 NetworkLinkControl"
  • Feature Elements: A Feature can be a Document, Folder, NetworkLink, Placemark, GroundOverlay, PhotoOverlay, or ScreenOverlay.

Does Google Earth emit an error when importing the example?

@stapelberg
Copy link
Author

Ah, sorry, I must have modified the example to include multiple placemarks. Just tried to reproduce this, and Google Earth indeed accepts the example file as-is.

So, it would still be good to change it to be more easily extensible, I think, but it’s clearly not a bug — up to you :).

@twpayne
Copy link
Owner

twpayne commented Jul 24, 2017

Thanks for following up :)

The package is designed as a thin wrapper for generating KML documents. "Protection against generating invalid documents" and "concealment of KML complexity" are explicit non-goals. I like the 1:1 mapping between examples in the package and examples in the KML tutorial.

It would be awesome if the library were able to catch more errors at compile time (e.g. if kml.KML(kml.Placemark(), kml.Placemark()) would not compile while kml.KML(kml.Placemark(), kml.NetworkLinkControl()) did compile). However, I'm not sure that this is reasonably possible within the confines of Go's type system (assuming that each element type has a corresponding unique Go type). Given the number of distinct KML element types, any such system would likely need to be automatically generated from the KML specification somehow.

A second option would be to add a function to validate the KML structure. As this could be done at runtime, it would make fewer demands on Go's type system.

I'll open issues for both of the above, but close this issue as "working as intended" for now.

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

No branches or pull requests

2 participants