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