[348] | 1 | .. _api-zoo-format-kml: |
---|
| 2 | |
---|
| 3 | ZOO.Format.KML |
---|
| 4 | ============== |
---|
| 5 | |
---|
| 6 | Read/Write KML. |
---|
| 7 | |
---|
| 8 | Inherits from |
---|
| 9 | |
---|
| 10 | - :ref:`ZOO.Format <api-zoo-format>` |
---|
| 11 | |
---|
| 12 | Properties and Functions |
---|
| 13 | ------------------------ |
---|
| 14 | |
---|
| 15 | .. list-table:: |
---|
| 16 | :widths: 20 50 |
---|
| 17 | :header-rows: 1 |
---|
| 18 | |
---|
| 19 | * - NAME |
---|
| 20 | - DESCRIPTION |
---|
| 21 | * - :ref:`kmlns <kmlns>` |
---|
| 22 | - {String} KML Namespace to use. |
---|
| 23 | * - :ref:`foldersName <foldersName>` |
---|
| 24 | - {String} Name of the folders. |
---|
| 25 | * - :ref:`foldersDesc <foldersDesc>` |
---|
| 26 | - {String} Description of the folders. |
---|
| 27 | * - :ref:`placemarksDesc <placemarksDesc>` |
---|
| 28 | - {String} Name of the placemarks. |
---|
| 29 | * - :ref:`extractAttributes <extractAttributes>` |
---|
| 30 | - {Boolean} Extract attributes from KML. |
---|
| 31 | * - :ref:`ZOO.Format.KML <ZOO.Format.KML>` |
---|
| 32 | - Create a new parser for KML. |
---|
| 33 | * - :ref:`parseFeatures <parseFeatures>` |
---|
| 34 | - Loop through all Placemark nodes and parse them. |
---|
| 35 | * - :ref:`parseFeature <parseFeature>` |
---|
| 36 | - This function is the core of the KML parsing code in ZOO. |
---|
| 37 | * - :ref:`parseGeometry <parseGeometry>` |
---|
| 38 | - Properties of this object are the functions that parse geometries based on their type. |
---|
| 39 | * - :ref:`parseGeometry.point <parseGeometry.point>` |
---|
| 40 | - Given a KML node representing a point geometry, create a ZOO point geometry. |
---|
| 41 | * - :ref:`parseGeometry.linestring <parseGeometry.linestring>` |
---|
| 42 | - Given a KML node representing a linestring geometry, create a ZOO linestring geometry. |
---|
| 43 | * - :ref:`parseGeometry.polygon <parseGeometry.polygon>` |
---|
| 44 | - Given a KML node representing a polygon geometry, create a ZOO polygon geometry. |
---|
| 45 | * - :ref:`parseGeometry.multigeometry <parseGeometry.multigeometry>` |
---|
| 46 | - Given a KML node representing a multigeometry, create a ZOO geometry collection. |
---|
| 47 | * - :ref:`parseAttributes <parseAttributes>` |
---|
| 48 | - |
---|
| 49 | * - :ref:`parseExtendedData <parseExtendedData>` |
---|
| 50 | - Parse ExtendedData from KML. |
---|
| 51 | * - :ref:`write <write>` |
---|
| 52 | - Accept Feature Collection, and return a string. |
---|
| 53 | * - :ref:`createPlacemark <createPlacemark>` |
---|
| 54 | - Creates and returns a KML placemark node representing the given feature. |
---|
| 55 | * - :ref:`buildGeometryNode <buildGeometryNode>` |
---|
| 56 | - Builds and returns a KML geometry node with the given geometry. |
---|
| 57 | * - :ref:`buildGeometry <buildGeometry>` |
---|
| 58 | - Object containing methods to do the actual geometry node building based on geometry type. |
---|
| 59 | * - :ref:`buildGeometry.point <buildGeometry.point>` |
---|
| 60 | - Given a ZOO point geometry, create a KML point. |
---|
| 61 | * - :ref:`buildGeometry.multipoint <buildGeometry.multipoint>` |
---|
| 62 | - Given a ZOO multipoint geometry, create a KML GeometryCollection. |
---|
| 63 | * - :ref:`buildGeometry.linestring <buildGeometry.linestring>` |
---|
| 64 | - Given a ZOO linestring geometry, create a KML linestring. |
---|
| 65 | * - :ref:`buildGeometry.multilinestring <buildGeometry.multilinestring>` |
---|
| 66 | - Given a ZOO multilinestring geometry, create a KML GeometryCollection. |
---|
| 67 | * - :ref:`buildGeometry.linearring <buildGeometry.linearring>` |
---|
| 68 | - Given a ZOO linearring geometry, create a KML linearring. |
---|
| 69 | * - :ref:`buildGeometry.polygon <buildGeometry.polygon>` |
---|
| 70 | - Given a ZOO polygon geometry, create a KML polygon. |
---|
| 71 | * - :ref:`buildGeometry.multipolygon <buildGeometry.multipolygon>` |
---|
| 72 | - Given a ZOO multipolygon geometry, create a KML GeometryCollection. |
---|
| 73 | * - :ref:`buildGeometry.collection <buildGeometry.collection>` |
---|
| 74 | - Given a ZOO geometry collection, create a KML MultiGeometry. |
---|
| 75 | * - :ref:`buildCoordinatesNode <buildCoordinatesNode>` |
---|
| 76 | - Builds and returns the KML coordinates node with the given geometry <coordinates>...</coordinates> |
---|
| 77 | |
---|
| 78 | .. _kmlns: |
---|
| 79 | |
---|
| 80 | kmlns |
---|
| 81 | ``{String}`` KML Namespace to use. Defaults to 2.2 namespace. |
---|
| 82 | |
---|
| 83 | .. _foldersName: |
---|
| 84 | |
---|
| 85 | foldersName |
---|
| 86 | ``{String}`` Name of the folders. Default is "ZOO export". If set to null, no name element will be created. |
---|
| 87 | |
---|
| 88 | .. _foldersDesc: |
---|
| 89 | |
---|
| 90 | foldersDesc |
---|
| 91 | ``{String}`` Description of the folders. Default is "Exported on [date]." If set to null, no description element will be created. |
---|
| 92 | |
---|
| 93 | .. _placemarksDesc: |
---|
| 94 | |
---|
| 95 | placemarksDesc |
---|
| 96 | ``{String}`` Name of the placemarks. Default is "No description available". |
---|
| 97 | |
---|
| 98 | .. _extractAttributes: |
---|
| 99 | |
---|
| 100 | extractAttributes |
---|
| 101 | ``{Boolean}`` Extract attributes from KML. Default is true. Extracting styleUrls requires this to be set to true |
---|
| 102 | |
---|
| 103 | .. _ZOO.Format.KML: |
---|
| 104 | |
---|
| 105 | ZOO.Format.KML |
---|
| 106 | Create a new parser for KML. |
---|
| 107 | |
---|
| 108 | *Parameters* |
---|
| 109 | |
---|
| 110 | ``options {Object}`` An optional object whose properties will be set on this instance. |
---|
| 111 | |
---|
| 112 | .. _parseFeatures: |
---|
| 113 | |
---|
| 114 | parseFeatures |
---|
| 115 | :: |
---|
| 116 | |
---|
| 117 | parseFeatures: function(nodes) |
---|
| 118 | |
---|
| 119 | Loop through all Placemark nodes and parse them. Will create a list of features |
---|
| 120 | |
---|
| 121 | *Parameters* |
---|
| 122 | |
---|
| 123 | | ``nodes {Array}`` of {E4XElement} data to read/parse. |
---|
| 124 | | ``options {Object}`` Hash of options |
---|
| 125 | |
---|
| 126 | .. _parseFeature: |
---|
| 127 | |
---|
| 128 | parseFeature |
---|
| 129 | :: |
---|
| 130 | |
---|
| 131 | parseFeature: function(node) |
---|
| 132 | |
---|
| 133 | This function is the core of the KML parsing code in ZOO. It creates the geometries |
---|
| 134 | that are then attached to the returned feature, and calls parseAttributes() to get |
---|
| 135 | attribute data out. |
---|
| 136 | |
---|
| 137 | *Parameters* |
---|
| 138 | |
---|
| 139 | ``node {E4XElement}`` |
---|
| 140 | |
---|
| 141 | *Returns* |
---|
| 142 | |
---|
| 143 | :ref:`{ZOO.Feature} <api-zoo-feature>` A vector feature. |
---|
| 144 | |
---|
| 145 | .. _parseGeometry: |
---|
| 146 | |
---|
| 147 | parseGeometry |
---|
| 148 | Properties of this object are the functions that parse geometries based on their type. |
---|
| 149 | |
---|
| 150 | .. _parseGeometry.point: |
---|
| 151 | |
---|
| 152 | parseGeometry.point |
---|
| 153 | Given a KML node representing a point geometry, create a ZOO point geometry. |
---|
| 154 | |
---|
| 155 | *Parameters* |
---|
| 156 | |
---|
| 157 | ``node {E4XElement}`` A KML Point node. |
---|
| 158 | |
---|
| 159 | *Returns* |
---|
| 160 | |
---|
| 161 | :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` A point geometry. |
---|
| 162 | |
---|
| 163 | .. _parseGeometry.linestring: |
---|
| 164 | |
---|
| 165 | parseGeometry.linestring |
---|
| 166 | Given a KML node representing a linestring geometry, create a ZOO linestring geometry. |
---|
| 167 | |
---|
| 168 | *Parameters* |
---|
| 169 | |
---|
| 170 | ``node {E4XElement}`` A KML LineString node. |
---|
| 171 | |
---|
| 172 | *Returns* |
---|
| 173 | |
---|
| 174 | :ref:`{ZOO.Geometry.LineString} <api-zoo-geometry-linestring>` A linestring geometry. |
---|
| 175 | |
---|
| 176 | .. _parseGeometry.polygon: |
---|
| 177 | |
---|
| 178 | parseGeometry.polygon |
---|
| 179 | Given a KML node representing a polygon geometry, create a ZOO polygon geometry. |
---|
| 180 | |
---|
| 181 | *Parameters* |
---|
| 182 | |
---|
| 183 | ``node {E4XElement}`` A KML Polygon node. |
---|
| 184 | |
---|
| 185 | *Returns* |
---|
| 186 | |
---|
| 187 | :ref:`{ZOO.Geometry.Polygon} <api-zoo-geometry-polygon>` A polygon geometry. |
---|
| 188 | |
---|
| 189 | .. _parseGeometry.multigeometry: |
---|
| 190 | |
---|
| 191 | parseGeometry.multigeometry |
---|
| 192 | Given a KML node representing a multigeometry, create a ZOO geometry collection. |
---|
| 193 | |
---|
| 194 | *Parameters* |
---|
| 195 | |
---|
| 196 | ``node {E4XElement}`` A KML MultiGeometry node. |
---|
| 197 | |
---|
| 198 | *Returns* |
---|
| 199 | |
---|
| 200 | :ref:`{ZOO.Geometry.Collection} <api-zoo-geometry-collection>` A geometry collection. |
---|
| 201 | |
---|
| 202 | .. _parseAttributes: |
---|
| 203 | |
---|
| 204 | parseAttributes |
---|
| 205 | :: |
---|
| 206 | |
---|
| 207 | parseAttributes: function(node) |
---|
| 208 | |
---|
| 209 | *Parameters* |
---|
| 210 | |
---|
| 211 | ``node {E4XElement}`` |
---|
| 212 | |
---|
| 213 | *Returns* |
---|
| 214 | |
---|
| 215 | ``{Object}`` An attributes object. |
---|
| 216 | |
---|
| 217 | .. _parseExtendedData: |
---|
| 218 | |
---|
| 219 | parseExtendedData |
---|
| 220 | :: |
---|
| 221 | |
---|
| 222 | parseExtendedData: function(node) |
---|
| 223 | |
---|
| 224 | Parse ExtendedData from KML. Limited support for schemas/datatypes. See http://code.google.com/apis/kml/documentation/kmlreference.html#extendeddata |
---|
| 225 | for more information on extendeddata. |
---|
| 226 | |
---|
| 227 | *Parameters* |
---|
| 228 | |
---|
| 229 | ``node {E4XElement}`` |
---|
| 230 | |
---|
| 231 | *Returns* |
---|
| 232 | |
---|
| 233 | ``{Object}`` An attributes object. |
---|
| 234 | |
---|
| 235 | .. _write: |
---|
| 236 | |
---|
| 237 | write |
---|
| 238 | :: |
---|
| 239 | |
---|
| 240 | write: function(features) |
---|
| 241 | |
---|
| 242 | Accept Feature Collection, and return a string. |
---|
| 243 | |
---|
| 244 | *Parameters* |
---|
| 245 | |
---|
| 246 | ``features`` :ref:`{Array(ZOO.Feature)} <api-zoo-feature>` An array of features. |
---|
| 247 | |
---|
| 248 | *Returns* |
---|
| 249 | |
---|
| 250 | ``{String}`` A KML string. |
---|
| 251 | |
---|
| 252 | .. _createPlacemark: |
---|
| 253 | |
---|
| 254 | createPlacemark |
---|
| 255 | :: |
---|
| 256 | |
---|
| 257 | createPlacemark: function(feature) |
---|
| 258 | |
---|
| 259 | Creates and returns a KML placemark node representing the given feature. |
---|
| 260 | |
---|
| 261 | *Parameters* |
---|
| 262 | |
---|
| 263 | ``feature`` :ref:`{ZOO.Feature} <api-zoo-feature>` |
---|
| 264 | |
---|
| 265 | *Returns* |
---|
| 266 | |
---|
| 267 | ``{E4XElement}`` |
---|
| 268 | |
---|
| 269 | .. _buildGeometryNode: |
---|
| 270 | |
---|
| 271 | buildGeometryNode |
---|
| 272 | :: |
---|
| 273 | |
---|
| 274 | buildGeometryNode: function(geometry) |
---|
| 275 | |
---|
| 276 | Builds and returns a KML geometry node with the given geometry. |
---|
| 277 | |
---|
| 278 | *Parameters* |
---|
| 279 | |
---|
| 280 | ``geometry`` :ref:`{ZOO.Geometry} <api-zoo-geometry>` |
---|
| 281 | |
---|
| 282 | *Returns* |
---|
| 283 | |
---|
| 284 | ``{E4XElement}`` |
---|
| 285 | |
---|
| 286 | .. _buildGeometry: |
---|
| 287 | |
---|
| 288 | buildGeometry |
---|
| 289 | Object containing methods to do the actual geometry node building based on geometry type. |
---|
| 290 | |
---|
| 291 | .. _buildGeometry.point: |
---|
| 292 | |
---|
| 293 | buildGeometry.point |
---|
| 294 | Given a ZOO point geometry, create a KML point. |
---|
| 295 | |
---|
| 296 | *Parameters* |
---|
| 297 | |
---|
| 298 | ``geometry`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` A point geometry. |
---|
| 299 | |
---|
| 300 | *Returns* |
---|
| 301 | |
---|
| 302 | ``{E4XElement}`` A KML point node. |
---|
| 303 | |
---|
| 304 | .. _buildGeometry.multipoint: |
---|
| 305 | |
---|
| 306 | buildGeometry.multipoint |
---|
| 307 | Given a ZOO multipoint geometry, create a KML GeometryCollection. |
---|
| 308 | |
---|
| 309 | *Parameters* |
---|
| 310 | |
---|
| 311 | ``geometry`` :ref:`{ZOO.Geometry.MultiPoint} <api-zoo-geometry-multipoint>` A multipoint geometry. |
---|
| 312 | |
---|
| 313 | *Returns* |
---|
| 314 | |
---|
| 315 | ``{E4XElement}`` A KML GeometryCollection node. |
---|
| 316 | |
---|
| 317 | .. _buildGeometry.linestring: |
---|
| 318 | |
---|
| 319 | buildGeometry.linestring |
---|
| 320 | Given a ZOO linestring geometry, create a KML linestring. |
---|
| 321 | |
---|
| 322 | *Parameters* |
---|
| 323 | |
---|
| 324 | ``geometry`` :ref:`{ZOO.Geometry.LineString} <api-zoo-geometry-linestring>` A linestring geometry. |
---|
| 325 | |
---|
| 326 | *Returns* |
---|
| 327 | |
---|
| 328 | ``{E4XElement}`` A KML linestring node. |
---|
| 329 | |
---|
| 330 | .. _buildGeometry.multilinestring: |
---|
| 331 | |
---|
| 332 | buildGeometry.multilinestring |
---|
| 333 | Given a ZOO multilinestring geometry, create a KML GeometryCollection. |
---|
| 334 | |
---|
| 335 | *Parameters* |
---|
| 336 | |
---|
| 337 | ``geometry`` :ref:`{ZOO.Geometry.MultiLineString} <api-zoo-geometry-multilinestring>` A multilinestring geometry. |
---|
| 338 | |
---|
| 339 | *Returns* |
---|
| 340 | |
---|
| 341 | ``{E4XElement}`` A KML GeometryCollection node. |
---|
| 342 | |
---|
| 343 | .. _buildGeometry.linearring: |
---|
| 344 | |
---|
| 345 | buildGeometry.linearring |
---|
| 346 | Given a ZOO linearring geometry, create a KML linearring. |
---|
| 347 | |
---|
| 348 | *Parameters* |
---|
| 349 | |
---|
| 350 | ``geometry`` :ref:`{ZOO.Geometry.LinearRing} <api-zoo-geometry-linearring>` A linearring geometry. |
---|
| 351 | |
---|
| 352 | *Returns* |
---|
| 353 | |
---|
| 354 | ``{E4XElement}`` A KML linearring node. |
---|
| 355 | |
---|
| 356 | .. _buildGeometry.polygon: |
---|
| 357 | |
---|
| 358 | buildGeometry.polygon |
---|
| 359 | Given a ZOO polygon geometry, create a KML polygon. |
---|
| 360 | |
---|
| 361 | *Parameters* |
---|
| 362 | |
---|
| 363 | ``geometry`` :ref:`{ZOO.Geometry.Polygon} <api-zoo-geometry-polygon>` A polygon geometry. |
---|
| 364 | |
---|
| 365 | *Returns* |
---|
| 366 | |
---|
| 367 | ``{E4XElement}`` A KML polygon node. |
---|
| 368 | |
---|
| 369 | .. _buildGeometry.multipolygon: |
---|
| 370 | |
---|
| 371 | buildGeometry.multipolygon |
---|
| 372 | Given a ZOO multipolygon geometry, create a KML GeometryCollection. |
---|
| 373 | |
---|
| 374 | *Parameters* |
---|
| 375 | |
---|
| 376 | ``geometry`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` A multipolygon geometry. |
---|
| 377 | |
---|
| 378 | *Returns* |
---|
| 379 | |
---|
| 380 | ``{E4XElement}`` A KML GeometryCollection node. |
---|
| 381 | |
---|
| 382 | .. _buildGeometry.collection: |
---|
| 383 | |
---|
| 384 | buildGeometry.collection |
---|
| 385 | Given a ZOO geometry collection, create a KML MultiGeometry. |
---|
| 386 | |
---|
| 387 | *Parameters* |
---|
| 388 | |
---|
| 389 | ``geometry`` :ref:`{ZOO.Geometry.Collection} <api-zoo-geometry-collection>` A geometry collection. |
---|
| 390 | |
---|
| 391 | *Returns* |
---|
| 392 | |
---|
| 393 | ``{E4XElement}`` A KML MultiGeometry node. |
---|
| 394 | |
---|
| 395 | .. _buildCoordinatesNode: |
---|
| 396 | |
---|
| 397 | buildCoordinatesNode |
---|
| 398 | :: |
---|
| 399 | |
---|
| 400 | buildCoordinatesNode: function(geometry) |
---|
| 401 | |
---|
| 402 | Builds and returns the KML coordinates node with the given geometry <coordinates>...</coordinates> |
---|
| 403 | |
---|
| 404 | *Parameters* |
---|
| 405 | |
---|
| 406 | ``geometry`` :ref:`{ZOO.Geometry} <api-zoo-geometry>` |
---|
| 407 | |
---|
| 408 | *Return* |
---|
| 409 | |
---|
| 410 | ``{E4XElement}`` |
---|
| 411 | |
---|
[181] | 412 | |
---|