1 | .. _api-zoo-format-kml: |
---|
2 | |
---|
3 | ZOO.Format.KML |
---|
4 | ============== |
---|
5 | |
---|
6 | Read/Write KML. |
---|
7 | |
---|
8 | Properties and Functions |
---|
9 | ------------------------ |
---|
10 | |
---|
11 | .. list-table:: |
---|
12 | :widths: 20 50 |
---|
13 | :header-rows: 1 |
---|
14 | |
---|
15 | * - NAME |
---|
16 | - DESCRIPTION |
---|
17 | * - :ref:`kmlns <kmlns>` |
---|
18 | - {String} KML Namespace to use. |
---|
19 | * - :ref:`foldersName <foldersName>` |
---|
20 | - {String} Name of the folders. |
---|
21 | * - :ref:`foldersDesc <foldersDesc>` |
---|
22 | - {String} Description of the folders. |
---|
23 | * - :ref:`placemarksDesc <placemarksDesc>` |
---|
24 | - {String} Name of the placemarks. |
---|
25 | * - :ref:`extractAttributes <extractAttributes>` |
---|
26 | - {Boolean} Extract attributes from KML. |
---|
27 | * - :ref:`ZOO.Format.KML <ZOO.Format.KML>` |
---|
28 | - Create a new parser for KML. |
---|
29 | * - :ref:`parseFeatures <parseFeatures>` |
---|
30 | - Loop through all Placemark nodes and parse them. |
---|
31 | * - :ref:`parseFeature <parseFeature>` |
---|
32 | - This function is the core of the KML parsing code in ZOO. |
---|
33 | * - :ref:`parseGeometry <parseGeometry>` |
---|
34 | - Properties of this object are the functions that parse geometries based on their type. |
---|
35 | * - :ref:`parseGeometry.point <parseGeometry.point>` |
---|
36 | - Given a KML node representing a point geometry, create a ZOO point geometry. |
---|
37 | * - :ref:`parseGeometry.linestring <parseGeometry.linestring>` |
---|
38 | - Given a KML node representing a linestring geometry, create a ZOO linestring geometry. |
---|
39 | * - :ref:`parseGeometry.polygon <parseGeometry.polygon>` |
---|
40 | - Given a KML node representing a polygon geometry, create a ZOO polygon geometry. |
---|
41 | * - :ref:`parseGeometry.multigeometry <parseGeometry.multigeometry>` |
---|
42 | - Given a KML node representing a multigeometry, create a ZOO geometry collection. |
---|
43 | * - :ref:`parseAttributes <parseAttributes>` |
---|
44 | - |
---|
45 | * - :ref:`parseExtendedData <parseExtendedData>` |
---|
46 | - Parse ExtendedData from KML. |
---|
47 | * - :ref:`write <write>` |
---|
48 | - Accept Feature Collection, and return a string. |
---|
49 | * - :ref:`createPlacemark <createPlacemark>` |
---|
50 | - Creates and returns a KML placemark node representing the given feature. |
---|
51 | * - :ref:`buildGeometryNode <buildGeometryNode>` |
---|
52 | - Builds and returns a KML geometry node with the given geometry. |
---|
53 | * - :ref:`buildGeometry <buildGeometry>` |
---|
54 | - Object containing methods to do the actual geometry node building based on geometry type. |
---|
55 | * - :ref:`buildGeometry.point <buildGeometry.point>` |
---|
56 | - Given a ZOO point geometry, create a KML point. |
---|
57 | * - :ref:`buildGeometry.multipoint <buildGeometry.multipoint>` |
---|
58 | - Given a ZOO multipoint geometry, create a KML GeometryCollection. |
---|
59 | * - :ref:`buildGeometry.linestring <buildGeometry.linestring>` |
---|
60 | - Given a ZOO linestring geometry, create a KML linestring. |
---|
61 | * - :ref:`buildGeometry.multilinestring <buildGeometry.multilinestring>` |
---|
62 | - Given a ZOO multilinestring geometry, create a KML GeometryCollection. |
---|
63 | * - :ref:`buildGeometry.linearring <buildGeometry.linearring>` |
---|
64 | - Given a ZOO linearring geometry, create a KML linearring. |
---|
65 | * - :ref:`buildGeometry.polygon <buildGeometry.polygon>` |
---|
66 | - Given a ZOO polygon geometry, create a KML polygon. |
---|
67 | * - :ref:`buildGeometry.multipolygon <buildGeometry.multipolygon>` |
---|
68 | - Given a ZOO multipolygon geometry, create a KML GeometryCollection. |
---|
69 | * - :ref:`buildGeometry.collection <buildGeometry.collection>` |
---|
70 | - Given a ZOO geometry collection, create a KML MultiGeometry. |
---|
71 | * - :ref:`buildCoordinatesNode <buildCoordinatesNode>` |
---|
72 | - Builds and returns the KML coordinates node with the given geometry <coordinates>...</coordinates> |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
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 | |
---|
195 | *Parameters* |
---|
196 | |
---|
197 | ``node {E4XElement}`` A KML MultiGeometry node. |
---|
198 | |
---|
199 | *Returns* |
---|
200 | |
---|
201 | :ref:`{ZOO.Geometry.Collection} <api-zoo-geometry-collection>` A geometry collection. |
---|
202 | |
---|
203 | .. _parseAttributes: |
---|
204 | |
---|
205 | parseAttributes |
---|
206 | :: |
---|
207 | |
---|
208 | parseAttributes: function(node) |
---|
209 | |
---|
210 | *Parameters* |
---|
211 | |
---|
212 | ``node {E4XElement}`` |
---|
213 | |
---|
214 | *Returns* |
---|
215 | |
---|
216 | ``{Object}`` An attributes object. |
---|
217 | |
---|
218 | .. _parseExtendedData: |
---|
219 | |
---|
220 | parseExtendedData |
---|
221 | :: |
---|
222 | |
---|
223 | parseExtendedData: function(node) |
---|
224 | |
---|
225 | Parse ExtendedData from KML. Limited support for schemas/datatypes. See http://code.google.com/apis/kml/documentation/kmlreference.html#extendeddata |
---|
226 | for more information on extendeddata. |
---|
227 | |
---|
228 | *Parameters* |
---|
229 | |
---|
230 | ``node {E4XElement}`` |
---|
231 | |
---|
232 | *Returns* |
---|
233 | |
---|
234 | ``{Object}`` An attributes object. |
---|
235 | |
---|
236 | .. _write: |
---|
237 | |
---|
238 | write |
---|
239 | :: |
---|
240 | |
---|
241 | write: function(features) |
---|
242 | |
---|
243 | Accept Feature Collection, and return a string. |
---|
244 | |
---|
245 | *Parameters* |
---|
246 | |
---|
247 | ``features`` :ref:`{Array(ZOO.Feature)} <api-zoo-feature>` An array of features. |
---|
248 | |
---|
249 | *Returns* |
---|
250 | |
---|
251 | ``{String}`` A KML string. |
---|
252 | |
---|
253 | .. _createPlacemark: |
---|
254 | |
---|
255 | createPlacemark |
---|
256 | :: |
---|
257 | |
---|
258 | createPlacemark: function(feature) |
---|
259 | |
---|
260 | Creates and returns a KML placemark node representing the given feature. |
---|
261 | |
---|
262 | *Parameters* |
---|
263 | |
---|
264 | ``feature`` :ref:`{ZOO.Feature} <api-zoo-feature>` |
---|
265 | |
---|
266 | *Returns* |
---|
267 | |
---|
268 | ``{E4XElement}`` |
---|
269 | |
---|
270 | .. _buildGeometryNode: |
---|
271 | |
---|
272 | buildGeometryNode |
---|
273 | :: |
---|
274 | |
---|
275 | buildGeometryNode: function(geometry) |
---|
276 | |
---|
277 | Builds and returns a KML geometry node with the given geometry. |
---|
278 | |
---|
279 | *Parameters* |
---|
280 | |
---|
281 | ``geometry`` :ref:`{ZOO.Geometry} <api-zoo-geometry>` |
---|
282 | |
---|
283 | *Returns* |
---|
284 | |
---|
285 | ``{E4XElement}`` |
---|
286 | |
---|
287 | .. _buildGeometry: |
---|
288 | |
---|
289 | buildGeometry |
---|
290 | Object containing methods to do the actual geometry node building based on geometry type. |
---|
291 | |
---|
292 | .. _buildGeometry.point: |
---|
293 | |
---|
294 | buildGeometry.point |
---|
295 | Given a ZOO point geometry, create a KML point. |
---|
296 | |
---|
297 | *Parameters* |
---|
298 | |
---|
299 | ``geometry`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` A point geometry. |
---|
300 | |
---|
301 | *Returns* |
---|
302 | |
---|
303 | ``{E4XElement}`` A KML point node. |
---|
304 | |
---|
305 | .. _buildGeometry.multipoint: |
---|
306 | |
---|
307 | buildGeometry.multipoint |
---|
308 | Given a ZOO multipoint geometry, create a KML GeometryCollection. |
---|
309 | |
---|
310 | *Parameters* |
---|
311 | |
---|
312 | ``geometry`` :ref:`{ZOO.Geometry.MultiPoint} <api-zoo-geometry-multipoint>` A multipoint geometry. |
---|
313 | |
---|
314 | *Returns* |
---|
315 | |
---|
316 | ``{E4XElement}`` A KML GeometryCollection node. |
---|
317 | |
---|
318 | .. _buildGeometry.linestring: |
---|
319 | |
---|
320 | buildGeometry.linestring |
---|
321 | Given a ZOO linestring geometry, create a KML linestring. |
---|
322 | |
---|
323 | *Parameters* |
---|
324 | |
---|
325 | ``geometry`` :ref:`{ZOO.Geometry.LineString} <api-zoo-geometry-linestring>` A linestring geometry. |
---|
326 | |
---|
327 | *Returns* |
---|
328 | |
---|
329 | ``{E4XElement}`` A KML linestring node. |
---|
330 | |
---|
331 | .. _buildGeometry.multilinestring: |
---|
332 | |
---|
333 | buildGeometry.multilinestring |
---|
334 | Given a ZOO multilinestring geometry, create a KML GeometryCollection. |
---|
335 | |
---|
336 | *Parameters* |
---|
337 | |
---|
338 | ``geometry`` :ref:`{ZOO.Geometry.MultiLineString} <api-zoo-geometry-multilinestring>` A multilinestring geometry. |
---|
339 | |
---|
340 | *Returns* |
---|
341 | |
---|
342 | ``{E4XElement}`` A KML GeometryCollection node. |
---|
343 | |
---|
344 | .. _buildGeometry.linearring: |
---|
345 | |
---|
346 | buildGeometry.linearring |
---|
347 | Given a ZOO linearring geometry, create a KML linearring. |
---|
348 | |
---|
349 | *Parameters* |
---|
350 | |
---|
351 | ``geometry`` :ref:`{ZOO.Geometry.LinearRing} <api-zoo-geometry-linearring>` A linearring geometry. |
---|
352 | |
---|
353 | *Returns* |
---|
354 | |
---|
355 | ``{E4XElement}`` A KML linearring node. |
---|
356 | |
---|
357 | .. _buildGeometry.polygon: |
---|
358 | |
---|
359 | buildGeometry.polygon |
---|
360 | Given a ZOO polygon geometry, create a KML polygon. |
---|
361 | |
---|
362 | *Parameters* |
---|
363 | |
---|
364 | ``geometry`` :ref:`{ZOO.Geometry.Polygon} <api-zoo-geometry-polygon>` A polygon geometry. |
---|
365 | |
---|
366 | *Returns* |
---|
367 | |
---|
368 | ``{E4XElement}`` A KML polygon node. |
---|
369 | |
---|
370 | .. _buildGeometry.multipolygon: |
---|
371 | |
---|
372 | buildGeometry.multipolygon |
---|
373 | Given a ZOO multipolygon geometry, create a KML GeometryCollection. |
---|
374 | |
---|
375 | *Parameters* |
---|
376 | |
---|
377 | ``geometry`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` A multipolygon geometry. |
---|
378 | |
---|
379 | *Returns* |
---|
380 | |
---|
381 | ``{E4XElement}`` A KML GeometryCollection node. |
---|
382 | |
---|
383 | .. _buildGeometry.collection: |
---|
384 | |
---|
385 | buildGeometry.collection |
---|
386 | Given a ZOO geometry collection, create a KML MultiGeometry. |
---|
387 | |
---|
388 | *Parameters* |
---|
389 | |
---|
390 | ``geometry`` :ref:`{ZOO.Geometry.Collection} <api-zoo-geometry-collection>` A geometry collection. |
---|
391 | |
---|
392 | *Returns* |
---|
393 | |
---|
394 | ``{E4XElement}`` A KML MultiGeometry node. |
---|
395 | |
---|
396 | .. _buildCoordinatesNode: |
---|
397 | |
---|
398 | buildCoordinatesNode |
---|
399 | :: |
---|
400 | |
---|
401 | buildCoordinatesNode: function(geometry) |
---|
402 | |
---|
403 | Builds and returns the KML coordinates node with the given geometry <coordinates>...</coordinates> |
---|
404 | |
---|
405 | *Parameters* |
---|
406 | |
---|
407 | ``geometry`` :ref:`{ZOO.Geometry} <api-zoo-geometry>` |
---|
408 | |
---|
409 | *Return* |
---|
410 | |
---|
411 | ``{E4XElement}`` |
---|
412 | |
---|
413 | |
---|