1 | .. _api-zoo-format-geojson: |
---|
2 | |
---|
3 | ZOO.Format.GeoJSON |
---|
4 | ================== |
---|
5 | |
---|
6 | Read and write GeoJSON. |
---|
7 | |
---|
8 | Properties |
---|
9 | ---------- |
---|
10 | |
---|
11 | .. list-table:: |
---|
12 | :widths: 20 50 |
---|
13 | :header-rows: 1 |
---|
14 | |
---|
15 | * - NAME |
---|
16 | - DESCRIPTION |
---|
17 | * - :ref:`ZOO.Format.GeoJSON <ZOO.Format.GeoJSON>` |
---|
18 | - Create a new parser for GeoJSON. |
---|
19 | * - :ref:`read <read>` |
---|
20 | - Deserialize a GeoJSON string. |
---|
21 | * - :ref:`isValidType <isValidType>` |
---|
22 | - Check if a GeoJSON object is a valid representative of the given type. |
---|
23 | * - :ref:`parseFeature <parseFeature>` |
---|
24 | - Convert a feature object from GeoJSON into an ZOO.Feature. |
---|
25 | * - :ref:`parseGeometry <parseGeometry>` |
---|
26 | - Convert a geometry object from GeoJSON into an ZOO.Geometry. |
---|
27 | |
---|
28 | parseCoords Properties |
---|
29 | ---------------------- |
---|
30 | |
---|
31 | .. list-table:: |
---|
32 | :widths: 20 50 |
---|
33 | :header-rows: 1 |
---|
34 | |
---|
35 | * - NAME |
---|
36 | - DESCRIPTION |
---|
37 | * - :ref:`parseCoords <parseCoords>` |
---|
38 | - Object with properties corresponding to the GeoJSON geometry types. |
---|
39 | |
---|
40 | parseCoords Functions |
---|
41 | --------------------- |
---|
42 | |
---|
43 | .. list-table:: |
---|
44 | :widths: 12 50 |
---|
45 | :header-rows: 1 |
---|
46 | |
---|
47 | * - NAME |
---|
48 | - DESCRIPTION |
---|
49 | * - :ref:`parseCoords.point <parseCoords.point>` |
---|
50 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.Point. |
---|
51 | * - :ref:`parseCoords.multipoint <parseCoords.multipoint>` |
---|
52 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.MultiPoint. |
---|
53 | * - :ref:`parseCoords.linestring <parseCoords.linestring>` |
---|
54 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.LineString. |
---|
55 | * - :ref:`parseCoords.multilinestring <parseCoords.multilinestring>` |
---|
56 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.MultiLineString. |
---|
57 | * - :ref:`parseCoords.polygon <parseCoords.polygon>` |
---|
58 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.Polygon. |
---|
59 | * - :ref:`parseCoords.multipolygon <parseCoords.multipolygon>` |
---|
60 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.MultiPolygon. |
---|
61 | * - :ref:`parseCoords.box <parseCoords.box>` |
---|
62 | - Convert a coordinate array from GeoJSON into an ZOO.Geometry.Polygon. |
---|
63 | * - :ref:`write <write>` |
---|
64 | - Serialize a feature, geometry, array of features into a GeoJSON string. |
---|
65 | * - :ref:`createCRSObject <createCRSObject>` |
---|
66 | - Create the CRS object for an object. |
---|
67 | |
---|
68 | extract Properties |
---|
69 | ------------------ |
---|
70 | |
---|
71 | .. list-table:: |
---|
72 | :widths: 20 50 |
---|
73 | :header-rows: 1 |
---|
74 | |
---|
75 | * - NAME |
---|
76 | - DESCRIPTION |
---|
77 | * - :ref:`extract <extract>` |
---|
78 | - Object with properties corresponding to the GeoJSON types. |
---|
79 | |
---|
80 | extract Functions |
---|
81 | ----------------- |
---|
82 | |
---|
83 | .. list-table:: |
---|
84 | :widths: 12 50 |
---|
85 | :header-rows: 1 |
---|
86 | |
---|
87 | * - NAME |
---|
88 | - DESCRIPTION |
---|
89 | * - :ref:`extract.feature <extract.feature>` |
---|
90 | - Return a partial GeoJSON object representing a single feature. |
---|
91 | * - :ref:`extract.geometry <extract.geometry>` |
---|
92 | - Return a GeoJSON object representing a single geometry. |
---|
93 | * - :ref:`extract.point <extract.point>` |
---|
94 | - Return an array of coordinates from a point. |
---|
95 | * - :ref:`extract.multipoint <extract.multipoint>` |
---|
96 | - Return an array of coordinates from a multipoint. |
---|
97 | * - :ref:`extract.linestring <extract.linestring>` |
---|
98 | - Return an array of coordinate arrays from a linestring. |
---|
99 | * - :ref:`extract.multilinestring <extract.multilinestring>` |
---|
100 | - Return an array of linestring arrays from a linestring. |
---|
101 | * - :ref:`extract.polygon <extract.polygon>` |
---|
102 | - Return an array of linear ring arrays from a polygon. |
---|
103 | * - :ref:`extract.multipolygon <extract.multipolygon>` |
---|
104 | - Return an array of polygon arrays from a multipolygon. |
---|
105 | * - :ref:`extract.collection <extract.collection>` |
---|
106 | - Return an array of geometries from a geometry collection. |
---|
107 | |
---|
108 | **Functions** |
---|
109 | |
---|
110 | .. _ZOO.Format.GeoJSON: |
---|
111 | |
---|
112 | ZOO.Format.GeoJSON |
---|
113 | Create a new parser for GeoJSON. |
---|
114 | |
---|
115 | |
---|
116 | *Parameters* |
---|
117 | |
---|
118 | ``options {Object}`` An optional object whose properties will be set on this instance. |
---|
119 | |
---|
120 | .. _read: |
---|
121 | |
---|
122 | read |
---|
123 | :: |
---|
124 | |
---|
125 | read: function(json,type,filter) |
---|
126 | |
---|
127 | Deserialize a GeoJSON string. |
---|
128 | |
---|
129 | *Parameters* |
---|
130 | |
---|
131 | | ``json {String}`` A GeoJSON string |
---|
132 | | ``type {String}`` Optional string that determines the structure of the output. Supported values are "Geometry", "Feature", and "FeatureCollection". If absent or null, a default of "FeatureCollection" is assumed. |
---|
133 | | ``filter {Function}`` A function which will be called for every key and value at every level of the final result. Each value will be replaced by the result of the filter function. This can be used to reform generic objects into instances of classes, or to transform date strings into Date objects. |
---|
134 | |
---|
135 | *Returns* |
---|
136 | |
---|
137 | ``{Object}`` The return depends on the value of the type argument. If type is "FeatureCollection" (the default), |
---|
138 | the return will be an array of :ref:`ZOO.Feature <api-zoo-feature>`. If type is "Geometry", the input json must |
---|
139 | represent a single geometry, and the return will be an :ref:`ZOO.Geometry <api-zoo-geometry>`. If type |
---|
140 | is "Feature", the input json must represent a single feature, and the return will be an :ref:`ZOO.Feature <api-zoo-feature>`. |
---|
141 | |
---|
142 | .. _isValidType: |
---|
143 | |
---|
144 | isValidType |
---|
145 | :: |
---|
146 | |
---|
147 | isValidType: function(obj,type) |
---|
148 | |
---|
149 | Check if a GeoJSON object is a valid representative of the given type. |
---|
150 | |
---|
151 | *Returns* |
---|
152 | |
---|
153 | ``{Boolean}`` The object is valid GeoJSON object of the given type. |
---|
154 | |
---|
155 | .. _parseFeature: |
---|
156 | |
---|
157 | parseFeature |
---|
158 | :: |
---|
159 | |
---|
160 | parseFeature: function(obj) |
---|
161 | |
---|
162 | Convert a feature object from GeoJSON into a :ref:`ZOO.Feature <api-zoo-feature>`. |
---|
163 | |
---|
164 | *Parameters* |
---|
165 | |
---|
166 | ``obj {Object}`` An object created from a GeoJSON object |
---|
167 | |
---|
168 | *Returns* |
---|
169 | |
---|
170 | :ref:`{ZOO.Feature} <api-zoo-feature>` A feature. |
---|
171 | |
---|
172 | .. _parseGeometry: |
---|
173 | |
---|
174 | parseGeometry |
---|
175 | :: |
---|
176 | |
---|
177 | parseGeometry: function(obj) |
---|
178 | |
---|
179 | Convert a geometry object from GeoJSON into a :ref:`ZOO.Geometry <api-zoo-geometry>`. |
---|
180 | |
---|
181 | *Parameters* |
---|
182 | |
---|
183 | ``obj {Object}`` An object created from a GeoJSON object |
---|
184 | |
---|
185 | *Returns* |
---|
186 | |
---|
187 | :ref:`{ZOO.Geometry} <api-zoo-geometry>` A geometry. |
---|
188 | |
---|
189 | **parseCoords Properties** |
---|
190 | |
---|
191 | .. _parseCoords: |
---|
192 | |
---|
193 | parseCoords |
---|
194 | Object with properties corresponding to the GeoJSON geometry types. Property |
---|
195 | values are functions that do the actual parsing. |
---|
196 | |
---|
197 | **parseCoords Functions** |
---|
198 | |
---|
199 | .. _parseCoords.point: |
---|
200 | |
---|
201 | parseCoords.point |
---|
202 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.Point <api-zoo-geometry-point>`. |
---|
203 | |
---|
204 | *Parameters* |
---|
205 | |
---|
206 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
207 | |
---|
208 | *Returns* |
---|
209 | |
---|
210 | :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` A geometry. |
---|
211 | |
---|
212 | .. _parseCoords.multipoint: |
---|
213 | |
---|
214 | parseCoords.multipoint |
---|
215 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.MultiPoint <api-zoo-geometry-multipoint>`. |
---|
216 | |
---|
217 | *Parameters* |
---|
218 | |
---|
219 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
220 | |
---|
221 | *Returns* |
---|
222 | |
---|
223 | :ref:`{ZOO.Geometry.MultiPoint} <api-zoo-geometry-multipoint>` A geometry. |
---|
224 | |
---|
225 | .. _parseCoords.linestring: |
---|
226 | |
---|
227 | parseCoords.linestring |
---|
228 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.LineString <api-zoo-geometry-linestring>`. |
---|
229 | |
---|
230 | *Parameters* |
---|
231 | |
---|
232 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
233 | |
---|
234 | *Returns* |
---|
235 | |
---|
236 | :ref:`{ZOO.Geometry.LineString} <api-zoo-geometry-linestring>` A geometry. |
---|
237 | |
---|
238 | .. _parseCoords.multilinestring: |
---|
239 | |
---|
240 | parseCoords.multilinestring |
---|
241 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.MultiLineString <api-zoo-geometry-multilinestring>`. |
---|
242 | |
---|
243 | *Parameters* |
---|
244 | |
---|
245 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
246 | |
---|
247 | *Returns* |
---|
248 | |
---|
249 | :ref:`{ZOO.Geometry.MultiLineString} <api-zoo-geometry-multilinestring>` A geometry. |
---|
250 | |
---|
251 | .. _parseCoords.polygon: |
---|
252 | |
---|
253 | parseCoords.polygon |
---|
254 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.Polygon <api-zoo-geometry-polygon>`. |
---|
255 | |
---|
256 | *Parameters* |
---|
257 | |
---|
258 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
259 | |
---|
260 | *Returns* |
---|
261 | |
---|
262 | :ref:`{ZOO.Geometry.Polygon} <api-zoo-geometry-polygon>` A geometry. |
---|
263 | |
---|
264 | .. _parseCoords.multipolygon: |
---|
265 | |
---|
266 | parseCoords.multipolygon |
---|
267 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.MultiPolygon <api-zoo-geometry-multipolygon>`. |
---|
268 | |
---|
269 | *Parameters* |
---|
270 | |
---|
271 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
272 | |
---|
273 | *Returns* |
---|
274 | |
---|
275 | :ref:`{ZOO.Geometry.MultiPolygon} <api-zoo-geometry-multipolygon>` A geometry. |
---|
276 | |
---|
277 | .. _parseCoords.box: |
---|
278 | |
---|
279 | parseCoords.box |
---|
280 | Convert a coordinate array from GeoJSON into a :ref:`ZOO.Geometry.Polygon <api-zoo-geometry-polygon>`. |
---|
281 | |
---|
282 | *Parameters* |
---|
283 | |
---|
284 | ``array {Object}`` The coordinates array from the GeoJSON fragment. |
---|
285 | |
---|
286 | *Returns* |
---|
287 | |
---|
288 | :ref:`{ZOO.Geometry.Polygon} <api-zoo-geometry-polygon>` A geometry. |
---|
289 | |
---|
290 | .. _write: |
---|
291 | |
---|
292 | write |
---|
293 | :: |
---|
294 | |
---|
295 | write: function(obj,pretty) |
---|
296 | |
---|
297 | Serialize a feature, geometry, array of features into a GeoJSON string. |
---|
298 | |
---|
299 | *Parameters* |
---|
300 | |
---|
301 | | ``obj {Object}`` A :ref:`{ZOO.Feature} <api-zoo-feature>`, :ref:`{ZOO.Geometry} <api-zoo-geometry>`, or an array of features. |
---|
302 | | ``pretty {Boolean}`` Structure the output with newlines and indentation. Default is false. |
---|
303 | |
---|
304 | *Returns* |
---|
305 | |
---|
306 | ``{String}`` The GeoJSON string representation of the input geometry, features, or array of features. |
---|
307 | |
---|
308 | .. _createCRSObject: |
---|
309 | |
---|
310 | createCRSObject |
---|
311 | :: |
---|
312 | |
---|
313 | createCRSObject: function(object) |
---|
314 | |
---|
315 | Create the CRS object for an object. |
---|
316 | |
---|
317 | *Parameters* |
---|
318 | |
---|
319 | ``object`` :ref:`{ZOO.Feature} <api-zoo-feature>` |
---|
320 | |
---|
321 | *Returns* |
---|
322 | |
---|
323 | ``{Object}`` An object which can be assigned to the crs property of a GeoJSON object. |
---|
324 | |
---|
325 | **extract Properties** |
---|
326 | |
---|
327 | .. _extract: |
---|
328 | |
---|
329 | extract |
---|
330 | Object with properties corresponding to the GeoJSON types. Property values are |
---|
331 | functions that do the actual value extraction. |
---|
332 | |
---|
333 | **extract Functions** |
---|
334 | |
---|
335 | .. _extract.feature: |
---|
336 | |
---|
337 | extract.feature |
---|
338 | Return a partial GeoJSON object representing a single feature. |
---|
339 | |
---|
340 | |
---|
341 | *Parameters* |
---|
342 | |
---|
343 | ``feature`` :ref:`{ZOO.Feature} <api-zoo-feature>` |
---|
344 | |
---|
345 | *Returns* |
---|
346 | |
---|
347 | ``{Object}`` An object representing the point. |
---|
348 | |
---|
349 | .. _extract.geometry: |
---|
350 | |
---|
351 | extract.geometry |
---|
352 | Return a GeoJSON object representing a single geometry. |
---|
353 | |
---|
354 | *Parameters* |
---|
355 | |
---|
356 | ``geometry`` :ref:`{ZOO.Geometry} <api-zoo-geometry>` |
---|
357 | |
---|
358 | *Returns* |
---|
359 | |
---|
360 | ``{Object}`` An object representing the geometry. |
---|
361 | |
---|
362 | .. _extract.point: |
---|
363 | |
---|
364 | extract.point |
---|
365 | Return an array of coordinates from a point. |
---|
366 | |
---|
367 | *Parameters* |
---|
368 | |
---|
369 | ``point`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` |
---|
370 | |
---|
371 | *Returns* |
---|
372 | |
---|
373 | ``{Array}`` An array of coordinates representing the point. |
---|
374 | |
---|
375 | .. _extract.multipoint: |
---|
376 | |
---|
377 | extract.multipoint |
---|
378 | Return an array of coordinates from a multipoint. |
---|
379 | |
---|
380 | *Parameters* |
---|
381 | |
---|
382 | ``multipoint`` :ref:`{ZOO.Geometry.MultiPoint} <api-zoo-geometry-multipoint>` |
---|
383 | |
---|
384 | *Returns* |
---|
385 | |
---|
386 | ``{Array}`` An array of point coordinate arrays representing the multipoint. |
---|
387 | |
---|
388 | .. _extract.linestring: |
---|
389 | |
---|
390 | extract.linestring |
---|
391 | Return an array of coordinate arrays from a linestring. |
---|
392 | |
---|
393 | *Parameters* |
---|
394 | |
---|
395 | ``linestring`` :ref:`{ZOO.Geometry.LineString} <api-zoo-geometry-linestring>` |
---|
396 | |
---|
397 | *Returns* |
---|
398 | |
---|
399 | ``{Array}`` An array of coordinate arrays representing the linestring. |
---|
400 | |
---|
401 | .. _extract.multilinestring: |
---|
402 | |
---|
403 | extract.multilinestring |
---|
404 | Return an array of linestring arrays from a linestring. |
---|
405 | |
---|
406 | *Parameters* |
---|
407 | |
---|
408 | ``multilinestring`` :ref:`{ZOO.Geometry.MultiLineString} <api-zoo-geometry-multilinestring>` |
---|
409 | |
---|
410 | *Returns* |
---|
411 | |
---|
412 | ``{Array}`` An array of linestring arrays representing the multilinestring. |
---|
413 | |
---|
414 | .. _extract.polygon: |
---|
415 | |
---|
416 | extract.polygon |
---|
417 | Return an array of linear ring arrays from a polygon. |
---|
418 | |
---|
419 | *Parameters* |
---|
420 | |
---|
421 | ``polygon`` :ref:`{ZOO.Geometry.Polygon} <api-zoo-geometry-polygon>` |
---|
422 | |
---|
423 | *Returns* |
---|
424 | |
---|
425 | ``{Array}`` An array of linear ring arrays representing the polygon. |
---|
426 | |
---|
427 | .. _extract.multipolygon: |
---|
428 | |
---|
429 | extract.multipolygon |
---|
430 | Return an array of polygon arrays from a multipolygon. |
---|
431 | |
---|
432 | *Parameters* |
---|
433 | |
---|
434 | ``multipolygon`` :ref:`{ZOO.Geometry.MultiPolygon} <api-zoo-geometry-multipolygon>` |
---|
435 | |
---|
436 | *Returns* |
---|
437 | |
---|
438 | ``{Array}`` An array of polygon arrays representing the multipolygon |
---|
439 | |
---|
440 | .. _extract.collection: |
---|
441 | |
---|
442 | extract.collection |
---|
443 | Return an array of geometries from a geometry collection. |
---|
444 | |
---|
445 | *Parameters* |
---|
446 | |
---|
447 | ``collection`` :ref:`{ZOO.Geometry.Collection} <api-zoo-geometry-collection>` |
---|
448 | |
---|
449 | *Returns* |
---|
450 | |
---|
451 | ``{Array}`` An array of geometry objects representing the geometry collection. |
---|