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

Parsing additional information from KML #140

Open
NickStallman opened this issue Mar 21, 2017 · 2 comments
Open

Parsing additional information from KML #140

NickStallman opened this issue Mar 21, 2017 · 2 comments

Comments

@NickStallman
Copy link

I'm unsure if this would be classified as out of scope for this project or not, however it could be useful to myself and likely others to extract additional details from KML file (and other formats).

For example I'm extracting a set of polygons, however the source file also has a 'name' tag which would be useful to my purposes.

The geometry class could simply have an attributes array added to it, and in KML.class.php: geomFromXML() it just needs to append any non-supported XML nodes to the attributes array if they can be parsed as text.
The library shouldn't make any assumption of what the fields actually are since they could differ from user to user.

@gsolak
Copy link

gsolak commented Nov 2, 2017

@NickStallman - I just now implemented geoPHP + kml + name/description.

While it would be nice for geoPHP to support KML attributes "out of the box" - the way kml is setup - it allows for meta data to exist on BOTH placemarks and "folders". Therefore geoPHP wouldn't be really able to expose all the meta data (at least not directly on the geometry objects). In which case, I would prefer to keep the two separate.

However, I did see a recent PR that included additional attributes from the KML parser. I would take a look around the recent PRs if I were you.

--

Here is how I implemented meta data on KML import:

  • Load kml file as a simplexml_load_string()
  • Loop through each folder; loop through each placemark
  • Extract meta data
  • Use geoPHP to import the geometry. You don't have to pass in a full xml file into geoPHP for it parse your kml! Passing just the polygon/point/geometry: $xmlPlacemark->asXml() works!

@NickStallman
Copy link
Author

@gsolak do you mean this PR?
#141

I did end up writing the code to handle attributes, looks like at least one other person found it useful.

It's still not in the core so this issue is still relevant.

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