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

Add a parser for reading and writing KML. #517

Merged
merged 3 commits into from Apr 12, 2013
Merged

Add a parser for reading and writing KML. #517

merged 3 commits into from Apr 12, 2013

Conversation

bartvde
Copy link
Member

@bartvde bartvde commented Apr 9, 2013

This adds ol.parser.ogc.KML which can be used to read and write KML documents.
NetworkLinks are retrieved asynchronously.
Current caveats of the implementation are:

  • LabelStyle not yet implemented. Missing support in renderers.
  • When using shared structures the parser needs to be configured with
    dimension 2.
  • We need a better way to disable fill, currently we use opacity as a
    workaround.
  • We cannot really roundtrip documents, since some of the info is not
    preserved in the ol structures. But we can write out most of the important
    info.

This adds ol.parser.ogc.KML which can be used to read and write KML documents.
NetworkLinks are retrieved asynchronously.
Current caveats of the implementation are:

* LabelStyle not yet implemented. Missing support in renderers.
* When using shared structures the parser needs to be configured with
  dimension 2.
* We need a better way to disable fill, currently we use opacity as a
  workaround.
* We cannot really roundtrip documents, since some of the info is not
  preserved in the ol structures. But we can write out most of the important
  info.
@bartvde
Copy link
Member Author

bartvde commented Apr 9, 2013

This is now ready for review, TIA

@fredj
Copy link
Member

fredj commented Apr 9, 2013

examples/kml/*.kml should be moved to examples/data/ (see #503)

@@ -9,6 +9,9 @@ goog.require('ol.parser.Parser');
* @extends {ol.parser.Parser}
*/
ol.parser.XML = function() {
if (window.ActiveXObject) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should use goog.global instead of window. This will permit the parser to be used in environments where window is not defined, e.g. NodeJS and WebWorkers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point @twpayne will make the change

@tschaub
Copy link
Member

tschaub commented Apr 9, 2013

What do you think about this being called ol.parser.KML?

@bartvde
Copy link
Member Author

bartvde commented Apr 9, 2013

That would be better @tschaub and also crossed my mind, is there a way to alias this, or does it involve moving directories?

@tschaub
Copy link
Member

tschaub commented Apr 9, 2013

does it involve moving directories?

I would just put it in src/ol/parser.

@@ -119,7 +119,7 @@ ol.style.Icon = function(options) {
* @return {ol.style.IconLiteral} Literal shape symbolizer.
*/
ol.style.Icon.prototype.createLiteral = function(feature) {
var attrs = feature.getAttributes();
var attrs = feature && feature.getAttributes();
Copy link
Member Author

Choose a reason for hiding this comment

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

@tschaub @ahocevar I wasn't sure about this part of the change, but otherwise I cannot get a literal if I don't have a feature when writing out a style (not associated directly with a feature) in KML

Copy link
Member

Choose a reason for hiding this comment

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

You're right @bartvde - feature should be optional in createLiteral. I've created #534 to make this consistent (and I think it is fine to handle separately).

@tschaub
Copy link
Member

tschaub commented Apr 11, 2013

This looks really solid @bartvde (and was clearly a ton of work).

My only minor comment is that I think it would be nice to have some more interesting data for the example (and I'm so sick of looking at that vmap0 rendering). But we can work on improving the example later.

I'm sure @bitner would be happy to know that we're still testing with his gx:Track data.

Please merge.

@bartvde
Copy link
Member Author

bartvde commented Apr 12, 2013

Agree on the example @tschaub I only copied it over from OL2. Will work on a better example.

bartvde pushed a commit that referenced this pull request Apr 12, 2013
Add a parser for reading and writing KML (r=@tschaub,@fredj,@twpayne)
@bartvde bartvde merged commit d1d18ad into openlayers:master Apr 12, 2013
@bartvde bartvde deleted the kmlfresh3 branch April 12, 2013 06:50
@twpayne
Copy link
Contributor

twpayne commented Apr 12, 2013

@bartvde, there's a not-too-complicated KML file at https://dl.dropbox.com/u/9071691/rbx13-route.kml if that helps.

@bartvde bartvde mentioned this pull request Apr 19, 2013
afabiani pushed a commit to geosolutions-it/openlayers that referenced this pull request May 22, 2017
afabiani pushed a commit to geosolutions-it/openlayers that referenced this pull request May 22, 2017
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

4 participants