OpenLayers OpenLayers

Ticket #927 (closed feature: fixed)

Opened 9 months ago

Last modified 8 months ago

read/write KML

Reported by: tschaub Assigned to: tschaub
Priority: minor Milestone: 2.5 Release
Component: Format.KML Version: 2.4
Keywords: Cc:
State:

Description

There is partial read and no write support in the Format.KML class currently. The KML format should inherit from the new XML format to get cross-browser write support.

Attachments

KML.js.patch (11.3 kB) - added by openlayers on 09/04/07 10:22:45.
Makes KML class extend XML class, implements the write() method (GGE compatible), uses the XML class methods for XML manipulation
test_KML.html.patch (3.7 kB) - added by openlayers on 09/05/07 06:00:14.
Tests for KML.js, working on ff2/linux, carshing on IE7 (KML.write() throws an error)
kml.patch (32.8 kB) - added by tschaub on 09/10/07 19:46:34.
Read/write KML, tests, and example
kml.2.patch (32.3 kB) - added by tschaub on 09/10/07 20:30:44.
read/write and throw a fit on bad KML

Change History

08/24/07 16:30:48 changed by tschaub

See email from Damien Corpataux.

09/04/07 10:22:45 changed by openlayers

  • attachment KML.js.patch added.

Makes KML class extend XML class, implements the write() method (GGE compatible), uses the XML class methods for XML manipulation

09/04/07 10:24:02 changed by openlayers

  • keywords set to review.

09/04/07 10:24:48 changed by openlayers

Damien Corpataux just added a patch for KML.js, for review

09/04/07 10:30:40 changed by crschmidt

  • milestone set to 2.5 Release.

Cool! I hope we can get this into 2.5...

09/05/07 06:00:14 changed by openlayers

  • attachment test_KML.html.patch added.

Tests for KML.js, working on ff2/linux, carshing on IE7 (KML.write() throws an error)

09/05/07 06:21:10 changed by openlayers

Details about submited test_KML.html.patch problem on IE7: test_Format_KML_write failure is caused by the following callstack:

exception: : object: Object doesn't support this property or method
...
KML.js:227 var kml = this.createElementNS(this.kmlns, "kml");
test_KML.html:34 var kmlOut = format.write(features);

On IE7, although working within my application, KML.write() crashes within the test suite.... loss of scope?

09/10/07 13:48:12 changed by tschaub

  • keywords deleted.

I'll tweak this for a bit. One thing to keep in mind with XML parsing - the get*NS methods are slow. They should be used conservatively. In particular, this style of code is inefficient:

if(this.getElementsByTagNameNS(xmlNode, this.kmlns, "Polygon").length != 0) { 
    var polygon = this.getElementsByTagNameNS(xmlNode, this.kmlns, "Polygon")[0]; 
    p = this.parseCoords(polygon); 
    ...

And should be replaced with

var polyList = this.getElementsByTagNameNS(xmlNode, this.kmlns, "Polygon");
if(polyList.length != 0) { 
    var polygon = polyList[0]; 
    p = this.parseCoords(polygon); 
    ...

Note that cuts the number of times the dom is traversed in half (for polygons).

09/10/07 19:46:34 changed by tschaub

  • attachment kml.patch added.

Read/write KML, tests, and example

09/10/07 19:49:27 changed by tschaub

  • keywords set to review.

Please review.

The change to Renderer.Elements is about rendering Geometry.Collection instances. In order to support all KML geometry types, we can map KML MultiGeometry to OpenLayers.Geometry.Collection.

09/10/07 20:30:44 changed by tschaub

  • attachment kml.2.patch added.

read/write and throw a fit on bad KML

09/11/07 07:25:30 changed by crschmidt

  • keywords changed from review to commit.

No complaints. Go ahead to commit.

09/11/07 11:18:43 changed by tschaub

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

(In [4219]) Full read/write support for KML. All KML 2.1 geometries supported. All OL geometries supported (closes #927).