[Commits] r1626 - in sandbox/cmoullet/ux/LayerManager: examples ux/data

commits at geoext.org commits at geoext.org
Tue Dec 29 05:51:10 CET 2009


Author: cmoullet
Date: 2009-12-29 05:51:10 +0100 (Tue, 29 Dec 2009)
New Revision: 1626

Added:
   sandbox/cmoullet/ux/LayerManager/examples/README.txt
   sandbox/cmoullet/ux/LayerManager/examples/placemark_descriptive.kml
   sandbox/cmoullet/ux/LayerManager/examples/placemark_floating.kml
Modified:
   sandbox/cmoullet/ux/LayerManager/examples/
   sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch
   sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
   sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
   sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js
   sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
Log:
Extend KML support
Improve format config management


Property changes on: sandbox/cmoullet/ux/LayerManager/examples
___________________________________________________________________
Name: svn:ignore
   - line_style_export.kml
simple_placemark_export.kml

   + line_style_export.kml
placemark_descriptive_export.kml
placemark_floating_export.kml
simple_placemark_export.kml


Modified: sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch	2009-12-28 15:47:40 UTC (rev 1625)
+++ sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch	2009-12-29 04:51:10 UTC (rev 1626)
@@ -103,15 +103,18 @@
       *           Defaults to 0: do no external fetching
       */
      maxDepth: 0,
-@@ -119,6 +119,7 @@
+@@ -119,17 +119,19 @@
              splitSpace: (/\s+/),
              trimComma: (/\s*,\s*/g),
              kmlColor: (/(\w{2})(\w{2})(\w{2})(\w{2})/),
 +            color: (/(\w{2})(\w{2})(\w{2})/),
              kmlIconPalette: (/root:\/\/icons\/palette-(\d+)(\.\w+)/),
-             straightBracket: (/\$\[(.*?)\]/g)
+-            straightBracket: (/\$\[(.*?)\]/g)
++            straightBracket: (/\$\[(.*?)\]/g),
++            version: (/\b[0-9]+.[0-9]+\b/)
          };
-@@ -127,9 +128,9 @@
+         OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
+     },
  
      /**
       * APIMethod: read
@@ -124,7 +127,7 @@
       * data    - {String} or {DOMElement} data to read/parse.
       *
       * Returns:
-@@ -137,8 +138,8 @@
+@@ -137,8 +139,8 @@
       */
      read: function(data) {
          this.features = [];
@@ -135,7 +138,7 @@
  
          // Set default options 
          var options = {
-@@ -151,9 +152,9 @@
+@@ -151,9 +153,9 @@
  
      /**
       * Method: parseData
@@ -148,7 +151,7 @@
       * data    - {String} or {DOMElement} data to read/parse.
       * options - {Object} Hash of options
       *
-@@ -161,20 +162,20 @@
+@@ -161,20 +163,20 @@
       * {Array(<OpenLayers.Feature.Vector>)} List of features.
       */
      parseData: function(data, options) {
@@ -172,7 +175,7 @@
                  continue;
              }
  
-@@ -204,21 +205,21 @@
+@@ -204,21 +206,21 @@
                      break;
              }
          }
@@ -199,7 +202,7 @@
          // Fetch external links <NetworkLink> and <Link>
          // Don't do anything if we have reached our maximum depth for recursion
          if (options.depth >= this.maxDepth) {
-@@ -229,15 +230,15 @@
+@@ -229,15 +231,15 @@
          var newOptions = OpenLayers.Util.extend({}, options);
          newOptions.depth++;
  
@@ -218,7 +221,7 @@
          }
  
      },
-@@ -245,10 +246,10 @@
+@@ -245,10 +247,10 @@
      /**
       * Method: fetchLink
       * Fetches a URL and returns the result
@@ -232,7 +235,7 @@
       */
      fetchLink: function(href) {
          var request = OpenLayers.Request.GET({url: href, async: false});
-@@ -261,18 +262,18 @@
+@@ -261,18 +263,18 @@
       * Method: parseStyles
       * Looks for <Style> nodes in the data and parses them
       * Also parses <StyleMap> nodes, but only uses the 'normal' key
@@ -257,7 +260,7 @@
                  this.styles[styleName] = style;
              }
          }
-@@ -282,21 +283,21 @@
+@@ -282,21 +284,21 @@
       * Method: parseStyle
       * Parses the children of a <Style> node and builds the style hash
       * accordingly
@@ -287,7 +290,7 @@
                  continue;
              }
  
-@@ -306,19 +307,19 @@
+@@ -306,19 +308,19 @@
                      var color = this.parseProperty(styleTypeNode, "*", "color");
                      if (color) {
                          var matches = (color.toString()).match(
@@ -312,7 +315,7 @@
                      var width = this.parseProperty(styleTypeNode, "*", "width");
                      if (width) {
                          style["strokeWidth"] = width;
-@@ -328,40 +329,40 @@
+@@ -328,40 +330,40 @@
                      var color = this.parseProperty(styleTypeNode, "*", "color");
                      if (color) {
                          var matches = (color.toString()).match(
@@ -366,7 +369,7 @@
  
                              var w = this.parseProperty(iconNode, "*", "w");
                              var h = this.parseProperty(iconNode, "*", "h");
-@@ -371,12 +372,12 @@
+@@ -371,12 +373,12 @@
                              // scale to prevent icons from being too big
                              var google = "http://maps.google.com/mapfiles/kml";
                              if (OpenLayers.String.startsWith(
@@ -381,7 +384,7 @@
                              // if only dimension is defined, make sure the
                              // other one has the same value
                              w = w || h;
-@@ -399,19 +400,19 @@
+@@ -399,19 +401,19 @@
                              // and request the appropriate icon from the 
                              // google maps website
                              var matches = href.match(this.regExes.kmlIconPalette);
@@ -406,7 +409,7 @@
                              }
  
                              style["graphicOpacity"] = 1; // fully opaque
-@@ -422,9 +423,9 @@
+@@ -422,9 +424,9 @@
  
  
                      // hotSpots define the offset for an Icon
@@ -419,7 +422,7 @@
                      if (hotSpotNode) {
                          var x = parseFloat(hotSpotNode.getAttribute("x"));
                          var y = parseFloat(hotSpotNode.getAttribute("y"));
-@@ -448,7 +449,7 @@
+@@ -448,7 +450,7 @@
                              style["graphicYOffset"] = -(y * scale) + 1;
                          }
                          else if (yUnits == "fraction") {
@@ -428,7 +431,7 @@
                          }
                      }
  
-@@ -458,10 +459,10 @@
+@@ -458,10 +460,10 @@
  
                  case "balloonstyle":
                      var balloonStyle = OpenLayers.Util.getXmlNodeValue(
@@ -441,7 +444,7 @@
                      }
                      break;
                  default:
-@@ -485,23 +486,23 @@
+@@ -485,23 +487,23 @@
       * Method: parseStyleMaps
       * Looks for <Style> nodes in the data and parses them
       * Also parses <StyleMap> nodes, but only uses the 'normal' key
@@ -472,7 +475,7 @@
                  var pair = pairs[j];
                  // Use the shortcut in the SLD format to quickly retrieve the 
                  // value of a node. Maybe it's good to have a method in 
-@@ -511,7 +512,7 @@
+@@ -511,7 +513,7 @@
  
                  if (styleUrl && key == "normal") {
                      this.styles[(options.styleBaseUrl || "") + "#" + id] =
@@ -481,7 +484,7 @@
                  }
  
                  if (styleUrl && key == "highlight") {
-@@ -528,18 +529,18 @@
+@@ -528,18 +530,18 @@
       * Method: parseFeatures
       * Loop through all Placemark nodes and parse them.
       * Will create a list of features
@@ -506,7 +509,7 @@
  
                  // Create reference to styleUrl 
                  if (this.extractStyles && feature.attributes &&
-@@ -551,14 +552,14 @@
+@@ -551,14 +553,14 @@
                      // Make sure that <Style> nodes within a placemark are 
                      // processed as well
                      var inlineStyleNode = this.getElementsByTagNameNS(featureNode,
@@ -526,7 +529,7 @@
                          }
                      }
                  }
-@@ -590,24 +591,24 @@
+@@ -590,24 +592,24 @@
          // only accept one geometry per feature - look for highest "order"
          var order = ["MultiGeometry", "Polygon", "LineString", "Point"];
          var type, nodeList, geometry, parser;
@@ -562,7 +565,7 @@
                  }
                  // stop looking for different geometry types
                  break;
-@@ -616,28 +617,28 @@
+@@ -616,28 +618,28 @@
  
          // construct feature (optionally with attributes)
          var attributes;
@@ -599,7 +602,7 @@
       *
       * Returns:
       * {Object}  - (reference to) Style hash
-@@ -651,10 +652,10 @@
+@@ -651,10 +653,10 @@
          newOptions.styleBaseUrl = styleBaseUrl;
  
          // Fetch remote Style URLs (if not fetched before) 
@@ -613,7 +616,7 @@
  
              var data = this.fetchLink(styleBaseUrl);
              if (data) {
-@@ -667,14 +668,14 @@
+@@ -667,14 +669,14 @@
          var style = OpenLayers.Util.extend({}, this.styles[styleUrl]);
          return style;
      },
@@ -630,7 +633,7 @@
          /**
           * Method: parseGeometry.point
           * Given a KML node representing a point geometry, create an OpenLayers
-@@ -688,28 +689,28 @@
+@@ -688,28 +690,28 @@
           */
          point: function(node) {
              var nodeList = this.getElementsByTagNameNS(node, this.internalns,
@@ -665,7 +668,7 @@
          /**
           * Method: parseGeometry.linestring
           * Given a KML node representing a linestring geometry, create an
-@@ -723,36 +724,36 @@
+@@ -723,36 +725,36 @@
           */
          linestring: function(node, ring) {
              var nodeList = this.getElementsByTagNameNS(node, this.internalns,
@@ -713,7 +716,7 @@
                          line = new OpenLayers.Geometry.LinearRing(points);
                      } else {
                          line = new OpenLayers.Geometry.LineString(points);
-@@ -764,7 +765,7 @@
+@@ -764,7 +766,7 @@
  
              return line;
          },
@@ -722,7 +725,7 @@
          /**
           * Method: parseGeometry.polygon
           * Given a KML node representing a polygon geometry, create an
-@@ -778,16 +779,16 @@
+@@ -778,16 +780,16 @@
           */
          polygon: function(node) {
              var nodeList = this.getElementsByTagNameNS(node, this.internalns,
@@ -744,7 +747,7 @@
                          components[i] = ring;
                      } else {
                          throw "Bad LinearRing geometry: " + i;
-@@ -796,7 +797,7 @@
+@@ -796,7 +798,7 @@
              }
              return new OpenLayers.Geometry.Polygon(components);
          },
@@ -753,7 +756,7 @@
          /**
           * Method: parseGeometry.multigeometry
           * Given a KML node representing a multigeometry, create an
-@@ -812,21 +813,21 @@
+@@ -812,21 +814,21 @@
              var child, parser;
              var parts = [];
              var children = node.childNodes;
@@ -781,7 +784,7 @@
      },
  
      /**
-@@ -840,22 +841,22 @@
+@@ -840,22 +842,22 @@
       */
      parseAttributes: function(node) {
          var attributes = {};
@@ -809,7 +812,7 @@
                      var grandchild;
                      switch (grandchildren.length) {
                          case 1:
-@@ -866,17 +867,17 @@
+@@ -866,17 +868,17 @@
                              grandchild = grandchildren[1];
                              break;
                      }
@@ -831,7 +834,7 @@
              }
          }
          return attributes;
-@@ -892,14 +893,14 @@
+@@ -892,14 +894,14 @@
          var attributes = {};
          var i, len, data, key;
          var dataNodes = node.getElementsByTagName("Data");
@@ -848,7 +851,7 @@
              var nameNode = data.getElementsByTagName("displayName");
              if (nameNode.length) {
                  ed['displayName'] = this.getChildValue(nameNode[0]);
-@@ -907,7 +908,7 @@
+@@ -907,7 +909,7 @@
              attributes[key] = ed;
          }
          var simpleDataNodes = node.getElementsByTagName("SimpleData");
@@ -857,7 +860,7 @@
              var ed = {};
              data = simpleDataNodes[i];
              key = data.getAttribute("name");
-@@ -915,10 +916,10 @@
+@@ -915,10 +917,10 @@
              ed['displayName'] = key;
              attributes[key] = ed;
          }
@@ -871,7 +874,7 @@
      /**
       * Method: parseProperty
       * Convenience method to find a node and return its value
-@@ -927,10 +928,10 @@
+@@ -927,10 +929,10 @@
       * xmlNode    - {<DOMElement>}
       * namespace  - {String} namespace of the node to find
       * tagName    - {String} name of the property to parse
@@ -884,7 +887,7 @@
      parseProperty: function(xmlNode, namespace, tagName) {
          var value;
          var nodeList = this.getElementsByTagNameNS(xmlNode, namespace, tagName);
-@@ -939,14 +940,14 @@
+@@ -939,14 +941,14 @@
          } catch(e) {
              value = null;
          }
@@ -903,7 +906,7 @@
       * Parameters:
       * features - {Array(<OpenLayers.Feature.Vector>} An array of features.
       *
-@@ -954,12 +955,15 @@
+@@ -954,12 +956,20 @@
       * {String} A KML string.
       */
      write: function(features) {
@@ -912,16 +915,22 @@
              features = [features];
          }
          var kml = this.createElementNS(this.kmlns, "kml");
-         var folder = this.createFolderXML();
+-        var folder = this.createFolderXML();
 -        for(var i=0, len=features.length; i<len; ++i) {
++        var folder = null;
++        if (this.getKmlVersion() == '2.2') {
++            folder = this.createDocumentXML();
++        } else {
++            folder = this.createFolderXML();
++        }
 +        for (var i = 0, len = features.length; i < len; ++i) {
-+            if (features[i].style) {
++            if (features[i].attributes.styleUrl) {
 +                folder.appendChild(this.createStyleXML(features[i]));
 +            }
              folder.appendChild(this.createPlacemarkXML(features[i]));
          }
          kml.appendChild(folder);
-@@ -969,89 +973,162 @@
+@@ -969,89 +979,205 @@
      /**
       * Method: createFolderXML
       * Creates and returns a KML folder node
@@ -954,6 +963,33 @@
      },
  
      /**
++     * Method: createDocumentXML
++     * Creates and returns a KML document node
++     * From 2.2 documentation: Do not put shared styles within a Folder.
++     *
++     * Returns:
++     * {DOMElement}
++     */
++    createDocumentXML: function() {
++        // Folder name
++        var documentName = this.createElementNS(this.kmlns, "name");
++        var documentNameText = this.createTextNode(this.foldersName);
++        documentName.appendChild(documentNameText);
++
++        // Folder description
++        var documentDesc = this.createElementNS(this.kmlns, "description");
++        var documentDescText = this.createTextNode(this.foldersDesc);
++        documentDesc.appendChild(documentDescText);
++
++        // Folder
++        var document = this.createElementNS(this.kmlns, "Document");
++        document.appendChild(documentName);
++        document.appendChild(documentDesc);
++
++        return document;
++    },
++
++    /**
       * Method: createPlacemarkXML
 -     * Creates and returns a KML placemark node representing the given feature. 
 -     * 
@@ -998,6 +1034,8 @@
 +            var styleUrl = (feature.attributes.styleUrl);
 +            placemarkStyleUrl.appendChild(this.createTextNode(styleUrl));
 +            placemarkNode.appendChild(placemarkStyleUrl);
++        } else if (feature.style) {
++            placemarkNode.appendChild(this.createStyleXML(feature));
 +        }
 +
 +        // Optional Placemark visibility
@@ -1038,7 +1076,7 @@
 +        }
 +
 +        // Get the line style
-+        if (feature.style.strokeColor || feature.style.strokeDashStyle || feature.style.strokeLineCap || feature.style.strokeOpacity || feature.style.strokeWidth) {
++        if ((feature.style.strokeColor && feature.style.strokeOpacity) || (feature.style.strokeWidth)) {
 +            var linestyleNode = this.createElementNS(this.kmlns, "LineStyle");
 +            // Stroke color and opacity
 +            if (feature.style.strokeColor && feature.style.strokeOpacity) {
@@ -1059,9 +1097,9 @@
 +        }
 +
 +        // Get the poly style
-+        if (feature.style.fillColor || feature.style.fillOpacity) {
++        if (feature.style.fillColor && feature.style.fillOpacity) {
 +            var polystyleNode = this.createElementNS(this.kmlns, "PolyStyle");
-+           // Stroke color and opacity
++            // Stroke color and opacity
 +            if (feature.style.fillColor && feature.style.fillOpacity) {
 +                var kmlColor = this.color2KmlColor(feature.style.fillOpacity, feature.style.fillColor.toString())
 +                var styleColor = this.createElementNS(this.kmlns, "color");
@@ -1072,6 +1110,20 @@
 +            styleNode.appendChild(polystyleNode);
 +        }
 +
++        // Get the icon style
++        if (feature.style.externalGraphic) {
++            var iconstyleNode = this.createElementNS(this.kmlns, "IconStyle");
++            var iconNode = this.createElementNS(this.kmlns, "Icon");
++
++            // Add href
++            var href = this.createElementNS(this.kmlns, "href");
++            href.appendChild(this.createTextNode(feature.style.externalGraphic));
++            iconNode.appendChild(href);
++
++            iconstyleNode.appendChild(iconNode);
++            styleNode.appendChild(iconstyleNode);
++        }
++
 +        return styleNode;
 +    },
 +
@@ -1106,7 +1158,7 @@
              node = builder.apply(this, [geometry]);
          }
          return node;
-@@ -1081,7 +1158,7 @@
+@@ -1081,7 +1207,7 @@
              kml.appendChild(this.buildCoordinatesNode(geometry));
              return kml;
          },
@@ -1115,7 +1167,7 @@
          /**
           * Method: buildGeometry.multipoint
           * Given an OpenLayers multipoint geometry, create a KML
-@@ -1112,7 +1189,7 @@
+@@ -1112,7 +1238,7 @@
              kml.appendChild(this.buildCoordinatesNode(geometry));
              return kml;
          },
@@ -1124,7 +1176,7 @@
          /**
           * Method: buildGeometry.multilinestring
           * Given an OpenLayers multilinestring geometry, create a KML
-@@ -1143,7 +1220,7 @@
+@@ -1143,7 +1269,7 @@
              kml.appendChild(this.buildCoordinatesNode(geometry));
              return kml;
          },
@@ -1133,7 +1185,7 @@
          /**
           * Method: buildGeometry.polygon
           * Given an OpenLayers polygon geometry, create a KML polygon.
-@@ -1158,17 +1235,17 @@
+@@ -1158,17 +1284,17 @@
              var kml = this.createElementNS(this.kmlns, "Polygon");
              var rings = geometry.components;
              var ringMember, ringGeom, type;
@@ -1155,7 +1207,7 @@
          /**
           * Method: buildGeometry.multipolygon
           * Given an OpenLayers multipolygon geometry, create a KML
-@@ -1197,10 +1274,10 @@
+@@ -1197,10 +1323,10 @@
          collection: function(geometry) {
              var kml = this.createElementNS(this.kmlns, "MultiGeometry");
              var child;
@@ -1169,7 +1221,7 @@
                      kml.appendChild(child);
                  }
              }
-@@ -1212,24 +1289,24 @@
+@@ -1212,24 +1338,24 @@
       * Method: buildCoordinatesNode
       * Builds and returns the KML coordinates node with the given geometry
       * <coordinates>...</coordinates>
@@ -1200,7 +1252,7 @@
                  point = points[i];
                  parts[i] = point.x + "," + point.y;
              }
-@@ -1238,12 +1315,20 @@
+@@ -1238,12 +1364,45 @@
              // Point
              path = geometry.x + "," + geometry.y;
          }
@@ -1215,6 +1267,17 @@
 +    },
  
 -    CLASS_NAME: "OpenLayers.Format.KML" 
++    /**
++     * Method: color2KmlColor
++     * Convert an opacity (from 0 to 1) and a colorcode (#ff2233) to a KML color code
++     *
++     * Parameters:
++     * opacity
++     * color_code - hexadecimal color codr
++     *
++     * Return:
++     * KML color code
++     */
 +    color2KmlColor: function(opacity, color_code) {
 +        var opacityHex = (opacity * 255).toString(16).toUpperCase();
 +        color_code = color_code.replace('#', '').toUpperCase();
@@ -1223,5 +1286,19 @@
 +        return opacityHex.toString() + matches[3].toString() + matches[2].toString() + matches[1].toString();
 +    },
 +
++    /**
++     * Method: getKmlVersion
++     * Get the KML version from the KML namespace
++     *
++     * Parameters:
++     *
++     * Return:
++     * KML version number
++     */
++    getKmlVersion: function() {
++        var matches = this.kmlns.toString().match(this.regExes.version);
++        return matches[0];
++    },
++
 +    CLASS_NAME: "OpenLayers.Format.KML"
  });

Modified: sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js	2009-12-28 15:47:40 UTC (rev 1625)
+++ sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js	2009-12-29 04:51:10 UTC (rev 1626)
@@ -52,10 +52,11 @@
         projection: map.displayProjection,
         strategies: [new OpenLayers.Strategy.Fixed()],
         protocol: new OpenLayers.Protocol.HTTP({
-            url: "sundials.kml",
+            url: "placemark_descriptive.kml",
             format: new OpenLayers.Format.KML({
                 extractStyles: true,
-                extractAttributes: true
+                extractAttributes: true,
+                kmlns: "http://www.opengis.net/kml/2.2"
             })
         })
     });

Added: sandbox/cmoullet/ux/LayerManager/examples/README.txt
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/README.txt	                        (rev 0)
+++ sandbox/cmoullet/ux/LayerManager/examples/README.txt	2009-12-29 04:51:10 UTC (rev 1626)
@@ -0,0 +1,19 @@
+KML Tests
+******************************************
+KML Interactive sampler: http://kml-samples.googlecode.com/svn/trunk/interactive/index.html
+KML Reference: http://code.google.com/intl/fr/apis/kml/documentation/kmlreference.html
+******************************************
+
+Sample data
+******************************************
+line_style.kml: ok
+placemark_descriptive.kml: CDATA not supported
+placemark_floating.kml: need support of graphicXOffset / graphicYOffset / graphicWidth / graphicHeight
+simple_placemark.kml: ok
+
+Not supported:
+read/write: altitudeMode
+read/write: tessellate
+read/write: CDATA in description
+write: graphicXOffset,graphicYOffset,graphicWidth,graphicHeight
+

Added: sandbox/cmoullet/ux/LayerManager/examples/placemark_descriptive.kml
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/placemark_descriptive.kml	                        (rev 0)
+++ sandbox/cmoullet/ux/LayerManager/examples/placemark_descriptive.kml	2009-12-29 04:51:10 UTC (rev 1626)
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2">
+  <Placemark>
+    <name>Descriptive HTML</name>
+    <visibility>1</visibility>
+    <description><![CDATA[
+Click on the blue link!<br><br>
+Placemark descriptions can be enriched by using many standard HTML tags.<br>
+For example:
+<hr>
+Styles:<br>
+<i>Italics</i>,
+<b>Bold</b>,
+<u>Underlined</u>,
+<s>Strike Out</s>,
+subscript<sub>subscript</sub>,
+superscript<sup>superscript</sup>,
+<big>Big</big>,
+<small>Small</small>,
+<tt>Typewriter</tt>,
+<em>Emphasized</em>,
+<strong>Strong</strong>,
+<code>Code</code>
+<hr>
+Fonts:<br>
+<font color="red">red by name</font>,
+<font color="#408010">leaf green by hexadecimal RGB</font>
+<br>
+<font size=1>size 1</font>,
+<font size=2>size 2</font>,
+<font size=3>size 3</font>,
+<font size=4>size 4</font>,
+<font size=5>size 5</font>,
+<font size=6>size 6</font>,
+<font size=7>size 7</font>
+<br>
+<font face=times>Times</font>,
+<font face=verdana>Verdana</font>,
+<font face=arial>Arial</font><br>
+<hr>
+Links:
+<br>
+<a href="http://earth.google.com/">Google Earth!</a>
+<br>
+ or:  Check out our website at www.google.com
+<hr>
+Alignment:<br>
+<p align=left>left</p>
+<p align=center>center</p>
+<p align=right>right</p>
+<hr>
+Ordered Lists:<br>
+<ol><li>First</li><li>Second</li><li>Third</li></ol>
+<ol type="a"><li>First</li><li>Second</li><li>Third</li></ol>
+<ol type="A"><li>First</li><li>Second</li><li>Third</li></ol>
+<hr>
+Unordered Lists:<br>
+<ul><li>A</li><li>B</li><li>C</li></ul>
+<ul type="circle"><li>A</li><li>B</li><li>C</li></ul>
+<ul type="square"><li>A</li><li>B</li><li>C</li></ul>
+<hr>
+Definitions:<br>
+<dl>
+<dt>Google:</dt><dd>The best thing since sliced bread</dd>
+</dl>
+<hr>
+Centered:<br><center>
+Time present and time past<br>
+Are both perhaps present in time future,<br>
+And time future contained in time past.<br>
+If all time is eternally present<br>
+All time is unredeemable.<br>
+</center>
+<hr>
+Block Quote:
+<br>
+<blockquote>
+We shall not cease from exploration<br>
+And the end of all our exploring<br>
+Will be to arrive where we started<br>
+And know the place for the first time.<br>
+<i>-- T.S. Eliot</i>
+</blockquote>
+<br>
+<hr>
+Headings:<br>
+<h1>Header 1</h1>
+<h2>Header 2</h2>
+<h3>Header 3</h3>
+<h3>Header 4</h4>
+<h3>Header 5</h5>
+<hr>
+Images:<br>
+<i>Remote image</i><br>
+<img src="http://kml-samples.googlecode.com/svn/trunk/resources/googleSample.png"><br>
+<i>Scaled image</i><br>
+<img src="http://kml-samples.googlecode.com/svn/trunk/resources/googleSample.png" width=100><br>
+<hr>
+Simple Tables:<br>
+<table border="1" padding="1">
+<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
+<tr><td>a</td><td>b</td><td>c</td><td>d</td><td>e</td></tr>
+</table>
+]]></description>
+    <Point>
+      <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
+    </Point>
+  </Placemark>
+</kml>
\ No newline at end of file

Added: sandbox/cmoullet/ux/LayerManager/examples/placemark_floating.kml
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/placemark_floating.kml	                        (rev 0)
+++ sandbox/cmoullet/ux/LayerManager/examples/placemark_floating.kml	2009-12-29 04:51:10 UTC (rev 1626)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2">
+  <Placemark>
+    <name>Floating placemark</name>
+    <visibility>1</visibility>
+    <description>Floats a defined distance above the ground.</description>
+    <LookAt>
+      <longitude>-122.084075</longitude>
+      <latitude>37.4220033612141</latitude>
+      <altitude>45</altitude>
+      <heading>0</heading>
+      <tilt>90</tilt>
+      <range>100</range>
+      <altitudeMode>relativeToGround</altitudeMode>
+    </LookAt>
+    <Style>
+      <IconStyle>
+        <Icon>
+          <href>http://maps.google.com/mapfiles/kml/pal4/icon28.png</href>
+        </Icon>
+      </IconStyle>
+    </Style>
+    <Point>
+      <altitudeMode>relativeToGround</altitudeMode>
+      <coordinates>-122.084075,37.4220033612141,50</coordinates>
+    </Point>
+  </Placemark>
+</kml>
\ No newline at end of file

Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Export.js	2009-12-28 15:47:40 UTC (rev 1625)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Export.js	2009-12-29 04:51:10 UTC (rev 1626)
@@ -41,28 +41,16 @@
     }
 
     if (format == 'KML') {
-        var kmlWriter = new OpenLayers.Format.KML({
-            extractStyles: true,
-            extractAttributes: true
-        });
+        var kmlWriter = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatConfig(format));
         return kmlWriter.write(exportFeatures);
     } else if (format == 'GeoJSON') {
-        var geojsonWriter = new OpenLayers.Format.GeoJSON({
-            extractStyles: true,
-            extractAttributes: true
-        });
+        var geojsonWriter = new OpenLayers.Format.GeoJSON(GeoExt.ux.data.formats.getFormatConfig(format));
         return geojsonWriter.write(exportFeatures);
     } else if (format == 'GeoRSS') {
-        var georssWriter = new OpenLayers.Format.GeoRSS({
-            extractStyles: true,
-            extractAttributes: true
-        });
+        var georssWriter = new OpenLayers.Format.GeoRSS(GeoExt.ux.data.formats.getFormatConfig(format));
         return georssWriter.write(exportFeatures);
     } else if (format == 'GML') {
-        var gmlWriter = new OpenLayers.Format.GML({
-            extractStyles: true,
-            extractAttributes: true
-        });
+        var gmlWriter = new OpenLayers.Format.GML(GeoExt.ux.data.formats.getFormatConfig(format));
         return gmlWriter.write(exportFeatures);
     } else {
         return 'Format ' + format + ' not supported. Patch welcome !';

Modified: sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js	2009-12-28 15:47:40 UTC (rev 1625)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js	2009-12-29 04:51:10 UTC (rev 1626)
@@ -9,12 +9,21 @@
 Ext.namespace("GeoExt.ux.data");
 
 GeoExt.ux.data.formats = [
-    ['KML', 'OpenLayers.Format.KML'],
-    ['GeoJSON', 'OpenLayers.Format.GeoJSON'],
-    ['GeoRSS', 'OpenLayers.Format.GeoRSS'],
-    ['GML', 'OpenLayers.Format.GML']
+    ['KML', 'OpenLayers.Format.KML', {extractStyles: true,extractAttributes: true,kmlns: "http://www.opengis.net/kml/2.2"}],
+    ['GeoJSON', 'OpenLayers.Format.GeoJSON',{}],
+    ['GeoRSS', 'OpenLayers.Format.GeoRSS',{}],
+    ['GML', 'OpenLayers.Format.GML',{}]
 ];
 
+GeoExt.ux.data.formats.getFormatConfig = function(format) {
+    for (var i = 0; i< GeoExt.ux.data.formats.length;i++) {
+        if (GeoExt.ux.data.formats[i][0] == format) {
+            return GeoExt.ux.data.formats[i][2]; 
+        }
+    }
+
+};
+
 GeoExt.ux.data.FormatStore = new Ext.data.SimpleStore({
     fields: ['shortName', 'openLayersClass', 'formatExportConfig'],
     data: GeoExt.ux.data.formats

Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Import.js	2009-12-28 15:47:40 UTC (rev 1625)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Import.js	2009-12-29 04:51:10 UTC (rev 1626)
@@ -15,10 +15,7 @@
 
     if (format && filecontent) {
         if (format == 'KML') {
-            var kmlReader = new OpenLayers.Format.KML({
-                extractStyles: true,
-                extractAttributes: true
-            });
+            var kmlReader = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatConfig(format));
             importFeatures = kmlReader.read(filecontent);
         } else {
             return 'Format ' + format + ' not supported. Patch welcome !';



More information about the Commits mailing list