├── .eslintrc.js ├── .github └── workflows │ └── nodejs.yml ├── .gitignore ├── CHANGELOG.md ├── README.md ├── index.js ├── package.json ├── tap-snapshots └── test-flatten.js-TAP.test.js ├── test ├── fixture │ ├── multigeometry.input.geojson │ ├── multilinestring.input.geojson │ ├── multipoint.input.geojson │ ├── multipolygon.input.geojson │ ├── nullgeometry.input.geojson │ └── point.input.geojson ├── flatten.js ├── linestring.geojson └── point.input.geojson └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true, 4 | node: true 5 | }, 6 | extends: "eslint:recommended", 7 | parserOptions: { 8 | ecmaVersion: 2015, 9 | sourceType: "module" 10 | }, 11 | rules: { 12 | "prefer-const": ["error"] 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [18.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - name: yarn install, build, and test 21 | run: | 22 | yarn install 23 | yarn test 24 | env: 25 | CI: true 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [1.1.1](https://github.com/tmcw/geojson-flatten/compare/v1.1.0...v1.1.1) (2022-10-24) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * remove path to executable as the script was removed in [#93](https://github.com/tmcw/geojson-flatten/issues/93) ([#95](https://github.com/tmcw/geojson-flatten/issues/95)) ([9d66a3e](https://github.com/tmcw/geojson-flatten/commit/9d66a3e46b0afdf8481a95f87c3e1489ee6172fd)), closes [#94](https://github.com/tmcw/geojson-flatten/issues/94) 11 | 12 | ## [1.1.0](https://github.com/tmcw/geojson-flatten/compare/v1.0.4...v1.1.0) (2022-10-24) 13 | 14 | 15 | ### Features 16 | 17 | * Remove CLI ([#93](https://github.com/tmcw/geojson-flatten/issues/93)) ([254e2b1](https://github.com/tmcw/geojson-flatten/commit/254e2b13aa6762f435c5973c83fe1e9574efe798)) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * Remove dependabot. Fix package paths ([#92](https://github.com/tmcw/geojson-flatten/issues/92)) ([5890845](https://github.com/tmcw/geojson-flatten/commit/5890845572e926c04e8713c1306abf51cf2648f2)) 23 | 24 | ### [1.0.5](https://github.com/tmcw/geojson-flatten/compare/v1.0.4...v1.0.5) (2022-10-24) 25 | 26 | 27 | ### Bug Fixes 28 | 29 | * Remove dependabot. Fix package paths ([#92](https://github.com/tmcw/geojson-flatten/issues/92)) ([5890845](https://github.com/tmcw/geojson-flatten/commit/5890845572e926c04e8713c1306abf51cf2648f2)) 30 | 31 | ### [1.0.4](https://github.com/node-geojson/geojson-flatten/compare/v1.0.3...v1.0.4) (2020-03-17) 32 | 33 | ### [1.0.3](https://github.com/node-geojson/geojson-flatten/compare/v1.0.2...v1.0.3) (2020-02-06) 34 | 35 | 36 | ### Bug Fixes 37 | 38 | * Return array when given single feature with null geometry. ([#27](https://github.com/node-geojson/geojson-flatten/issues/27)) ([10dcc2c](https://github.com/node-geojson/geojson-flatten/commit/10dcc2c34b68f68e4ed655e755c18204007bdf99)), closes [#26](https://github.com/node-geojson/geojson-flatten/issues/26) 39 | 40 | ### [1.0.2](https://github.com/node-geojson/geojson-flatten/compare/v1.0.1...v1.0.2) (2020-01-23) 41 | 42 | 43 | ### Bug Fixes 44 | 45 | * **package:** update get-stdin to version 7.0.0 ([06bdfa3](https://github.com/node-geojson/geojson-flatten/commit/06bdfa3)) 46 | 47 | 48 | 49 | 50 | ## [1.0.1](https://github.com/node-geojson/geojson-flatten/compare/v1.0.0...v1.0.1) (2019-01-31) 51 | 52 | 53 | 54 | 55 | # [1.0.0](https://github.com/node-geojson/geojson-flatten/compare/v0.2.3...v1.0.0) (2019-01-29) 56 | 57 | 58 | 59 | 60 | ## [0.2.3](https://github.com/node-geojson/geojson-flatten/compare/v0.2.2...v0.2.3) (2019-01-29) 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # geojson-flatten 2 | 3 | Flatten MultiPoint, MultiPolygon, MultiLineString, and GeometryCollection 4 | geometries in [GeoJSON](http://geojson.org/) files into simple non-complex 5 | geometries. 6 | 7 | If a FeatureCollection is passed in, a FeatureCollection is returned. If a single Feature is passed in, an array of Features is returned. 8 | 9 | ## install 10 | 11 | ``` 12 | npm install --save geojson-flatten 13 | ``` 14 | 15 | Or download `geojson-flatten.js` for non-[browserify](http://browserify.org/) usage. 16 | 17 | ## example 18 | 19 | ```js 20 | let flatten = require('geojson-flatten'); 21 | 22 | flattened = flatten(geojsonObject); 23 | ``` 24 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | export default function flatten(gj) { 2 | switch ((gj && gj.type) || null) { 3 | case "FeatureCollection": 4 | gj.features = gj.features.reduce(function(mem, feature) { 5 | return mem.concat(flatten(feature)); 6 | }, []); 7 | return gj; 8 | case "Feature": 9 | if (!gj.geometry) return [gj]; 10 | return flatten(gj.geometry).map(function(geom) { 11 | var data = { 12 | type: "Feature", 13 | properties: JSON.parse(JSON.stringify(gj.properties)), 14 | geometry: geom 15 | }; 16 | if (gj.id !== undefined) { 17 | data.id = gj.id; 18 | } 19 | return data; 20 | }); 21 | case "MultiPoint": 22 | return gj.coordinates.map(function(_) { 23 | return { type: "Point", coordinates: _ }; 24 | }); 25 | case "MultiPolygon": 26 | return gj.coordinates.map(function(_) { 27 | return { type: "Polygon", coordinates: _ }; 28 | }); 29 | case "MultiLineString": 30 | return gj.coordinates.map(function(_) { 31 | return { type: "LineString", coordinates: _ }; 32 | }); 33 | case "GeometryCollection": 34 | return gj.geometries.map(flatten).reduce(function(memo, geoms) { 35 | return memo.concat(geoms); 36 | }, []); 37 | case "Point": 38 | case "Polygon": 39 | case "LineString": 40 | return [gj]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "geojson-flatten", 3 | "version": "1.1.1", 4 | "description": "transform geojson into single-parts", 5 | "source": "index.js", 6 | "main": "dist/index.js", 7 | "umd:main": "dist/index.umd.js", 8 | "unpkg": "dist/index.umd.js", 9 | "module": "dist/index.es.js", 10 | "files": [ 11 | "index.js", 12 | "dist", 13 | "geojson-flatten" 14 | ], 15 | "directories": { 16 | "test": "test" 17 | }, 18 | "scripts": { 19 | "test": "eslint index.js && tap test/flatten.js", 20 | "prepare": "microbundle --name geojsonFlatten", 21 | "release": "standard-version" 22 | }, 23 | "repository": { 24 | "type": "git", 25 | "url": "git://github.com/tmcw/geojson-flatten.git" 26 | }, 27 | "keywords": [ 28 | "geojson", 29 | "maps", 30 | "flatten" 31 | ], 32 | "author": "Tom MacWright", 33 | "license": "BSD-2-Clause", 34 | "bugs": { 35 | "url": "https://github.com/tmcw/geojson-flatten/issues" 36 | }, 37 | "homepage": "https://github.com/tmcw/geojson-flatten", 38 | "devDependencies": { 39 | "eslint": "^7.0.0", 40 | "microbundle": "^0.13.0", 41 | "standard-version": "^9.0.0", 42 | "tap": "^14.10.6" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tap-snapshots/test-flatten.js-TAP.test.js: -------------------------------------------------------------------------------- 1 | /* IMPORTANT 2 | * This snapshot file is auto-generated, but designed for humans. 3 | * It should be checked into source control and tracked carefully. 4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests. 5 | * Make sure to inspect the output below. Do not ignore changes! 6 | */ 7 | 'use strict' 8 | exports[`test/flatten.js TAP flatten multigeometry-single.input.geojson > multigeometry-single.input.geojson 1`] = ` 9 | Array [ 10 | Object { 11 | "geometry": Object { 12 | "coordinates": Array [ 13 | -122.4425587930444, 14 | 37.80666418607323, 15 | 0, 16 | ], 17 | "type": "Point", 18 | }, 19 | "properties": Object { 20 | "name": "SF Marina Harbor Master", 21 | }, 22 | "type": "Feature", 23 | }, 24 | Object { 25 | "geometry": Object { 26 | "coordinates": Array [ 27 | -122.4428379594768, 28 | 37.80663578323093, 29 | 0, 30 | ], 31 | "type": "Point", 32 | }, 33 | "properties": Object { 34 | "name": "SF Marina Harbor Master", 35 | }, 36 | "type": "Feature", 37 | }, 38 | Object { 39 | "geometry": Object { 40 | "coordinates": Array [ 41 | Array [ 42 | -122.4425587930444, 43 | 37.80666418607323, 44 | 0, 45 | ], 46 | Array [ 47 | -122.4428379594768, 48 | 37.80663578323093, 49 | 0, 50 | ], 51 | ], 52 | "type": "LineString", 53 | }, 54 | "properties": Object { 55 | "name": "SF Marina Harbor Master", 56 | }, 57 | "type": "Feature", 58 | }, 59 | Object { 60 | "geometry": Object { 61 | "coordinates": Array [ 62 | Array [ 63 | -122.4425509770566, 64 | 37.80662588061205, 65 | 0, 66 | ], 67 | Array [ 68 | -122.4428340530617, 69 | 37.8065999493009, 70 | 0, 71 | ], 72 | ], 73 | "type": "LineString", 74 | }, 75 | "properties": Object { 76 | "name": "SF Marina Harbor Master", 77 | }, 78 | "type": "Feature", 79 | }, 80 | ] 81 | ` 82 | 83 | exports[`test/flatten.js TAP flatten multigeometry.input.geojson > multigeometry.input.geojson 1`] = ` 84 | Object { 85 | "features": Array [ 86 | Object { 87 | "geometry": Object { 88 | "coordinates": Array [ 89 | -122.4425587930444, 90 | 37.80666418607323, 91 | 0, 92 | ], 93 | "type": "Point", 94 | }, 95 | "properties": Object { 96 | "name": "SF Marina Harbor Master", 97 | }, 98 | "type": "Feature", 99 | }, 100 | Object { 101 | "geometry": Object { 102 | "coordinates": Array [ 103 | -122.4428379594768, 104 | 37.80663578323093, 105 | 0, 106 | ], 107 | "type": "Point", 108 | }, 109 | "properties": Object { 110 | "name": "SF Marina Harbor Master", 111 | }, 112 | "type": "Feature", 113 | }, 114 | Object { 115 | "geometry": Object { 116 | "coordinates": Array [ 117 | Array [ 118 | -122.4425587930444, 119 | 37.80666418607323, 120 | 0, 121 | ], 122 | Array [ 123 | -122.4428379594768, 124 | 37.80663578323093, 125 | 0, 126 | ], 127 | ], 128 | "type": "LineString", 129 | }, 130 | "properties": Object { 131 | "name": "SF Marina Harbor Master", 132 | }, 133 | "type": "Feature", 134 | }, 135 | Object { 136 | "geometry": Object { 137 | "coordinates": Array [ 138 | Array [ 139 | -122.4425509770566, 140 | 37.80662588061205, 141 | 0, 142 | ], 143 | Array [ 144 | -122.4428340530617, 145 | 37.8065999493009, 146 | 0, 147 | ], 148 | ], 149 | "type": "LineString", 150 | }, 151 | "properties": Object { 152 | "name": "SF Marina Harbor Master", 153 | }, 154 | "type": "Feature", 155 | }, 156 | ], 157 | "type": "FeatureCollection", 158 | } 159 | ` 160 | 161 | exports[`test/flatten.js TAP flatten multilinestring-single.input.geojson > multilinestring-single.input.geojson 1`] = ` 162 | Array [ 163 | Object { 164 | "geometry": Object { 165 | "coordinates": Array [ 166 | Array [ 167 | 0, 168 | 0, 169 | ], 170 | Array [ 171 | 1, 172 | 1, 173 | ], 174 | ], 175 | "type": "LineString", 176 | }, 177 | "properties": Object { 178 | "name": "SF Marina Harbor Master", 179 | }, 180 | "type": "Feature", 181 | }, 182 | Object { 183 | "geometry": Object { 184 | "coordinates": Array [ 185 | Array [ 186 | 2, 187 | 2, 188 | ], 189 | Array [ 190 | 3, 191 | 3, 192 | ], 193 | ], 194 | "type": "LineString", 195 | }, 196 | "properties": Object { 197 | "name": "SF Marina Harbor Master", 198 | }, 199 | "type": "Feature", 200 | }, 201 | ] 202 | ` 203 | 204 | exports[`test/flatten.js TAP flatten multilinestring.input.geojson > multilinestring.input.geojson 1`] = ` 205 | Object { 206 | "features": Array [ 207 | Object { 208 | "geometry": Object { 209 | "coordinates": Array [ 210 | Array [ 211 | 0, 212 | 0, 213 | ], 214 | Array [ 215 | 1, 216 | 1, 217 | ], 218 | ], 219 | "type": "LineString", 220 | }, 221 | "properties": Object { 222 | "name": "SF Marina Harbor Master", 223 | }, 224 | "type": "Feature", 225 | }, 226 | Object { 227 | "geometry": Object { 228 | "coordinates": Array [ 229 | Array [ 230 | 2, 231 | 2, 232 | ], 233 | Array [ 234 | 3, 235 | 3, 236 | ], 237 | ], 238 | "type": "LineString", 239 | }, 240 | "properties": Object { 241 | "name": "SF Marina Harbor Master", 242 | }, 243 | "type": "Feature", 244 | }, 245 | ], 246 | "type": "FeatureCollection", 247 | } 248 | ` 249 | 250 | exports[`test/flatten.js TAP flatten multipoint-single.input.geojson > multipoint-single.input.geojson 1`] = ` 251 | Array [ 252 | Object { 253 | "geometry": Object { 254 | "coordinates": Array [ 255 | 0, 256 | 0, 257 | ], 258 | "type": "Point", 259 | }, 260 | "properties": Object { 261 | "name": "SF Marina Harbor Master", 262 | }, 263 | "type": "Feature", 264 | }, 265 | Object { 266 | "geometry": Object { 267 | "coordinates": Array [ 268 | 1, 269 | 1, 270 | ], 271 | "type": "Point", 272 | }, 273 | "properties": Object { 274 | "name": "SF Marina Harbor Master", 275 | }, 276 | "type": "Feature", 277 | }, 278 | ] 279 | ` 280 | 281 | exports[`test/flatten.js TAP flatten multipoint.input.geojson > multipoint.input.geojson 1`] = ` 282 | Object { 283 | "features": Array [ 284 | Object { 285 | "geometry": Object { 286 | "coordinates": Array [ 287 | 0, 288 | 0, 289 | ], 290 | "type": "Point", 291 | }, 292 | "properties": Object { 293 | "name": "SF Marina Harbor Master", 294 | }, 295 | "type": "Feature", 296 | }, 297 | Object { 298 | "geometry": Object { 299 | "coordinates": Array [ 300 | 1, 301 | 1, 302 | ], 303 | "type": "Point", 304 | }, 305 | "properties": Object { 306 | "name": "SF Marina Harbor Master", 307 | }, 308 | "type": "Feature", 309 | }, 310 | ], 311 | "type": "FeatureCollection", 312 | } 313 | ` 314 | 315 | exports[`test/flatten.js TAP flatten multipolygon-single.input.geojson > multipolygon-single.input.geojson 1`] = ` 316 | Array [ 317 | Object { 318 | "geometry": Object { 319 | "coordinates": Array [ 320 | Array [ 321 | 0, 322 | 0, 323 | ], 324 | Array [ 325 | 1, 326 | 1, 327 | ], 328 | Array [ 329 | 4, 330 | 2, 331 | ], 332 | Array [ 333 | 0, 334 | 0, 335 | ], 336 | ], 337 | "type": "Polygon", 338 | }, 339 | "properties": Object { 340 | "name": "SF Marina Harbor Master", 341 | }, 342 | "type": "Feature", 343 | }, 344 | Object { 345 | "geometry": Object { 346 | "coordinates": Array [ 347 | Array [ 348 | 0, 349 | 0, 350 | ], 351 | Array [ 352 | 5, 353 | 5, 354 | ], 355 | Array [ 356 | 4, 357 | 2, 358 | ], 359 | Array [ 360 | 0, 361 | 0, 362 | ], 363 | ], 364 | "type": "Polygon", 365 | }, 366 | "properties": Object { 367 | "name": "SF Marina Harbor Master", 368 | }, 369 | "type": "Feature", 370 | }, 371 | ] 372 | ` 373 | 374 | exports[`test/flatten.js TAP flatten multipolygon.input.geojson > multipolygon.input.geojson 1`] = ` 375 | Object { 376 | "features": Array [ 377 | Object { 378 | "geometry": Object { 379 | "coordinates": Array [ 380 | Array [ 381 | 0, 382 | 0, 383 | ], 384 | Array [ 385 | 1, 386 | 1, 387 | ], 388 | Array [ 389 | 4, 390 | 2, 391 | ], 392 | Array [ 393 | 0, 394 | 0, 395 | ], 396 | ], 397 | "type": "Polygon", 398 | }, 399 | "properties": Object { 400 | "name": "SF Marina Harbor Master", 401 | }, 402 | "type": "Feature", 403 | }, 404 | Object { 405 | "geometry": Object { 406 | "coordinates": Array [ 407 | Array [ 408 | 0, 409 | 0, 410 | ], 411 | Array [ 412 | 5, 413 | 5, 414 | ], 415 | Array [ 416 | 4, 417 | 2, 418 | ], 419 | Array [ 420 | 0, 421 | 0, 422 | ], 423 | ], 424 | "type": "Polygon", 425 | }, 426 | "properties": Object { 427 | "name": "SF Marina Harbor Master", 428 | }, 429 | "type": "Feature", 430 | }, 431 | ], 432 | "type": "FeatureCollection", 433 | } 434 | ` 435 | 436 | exports[`test/flatten.js TAP flatten nullgeometry-single.input.geojson > nullgeometry-single.input.geojson 1`] = ` 437 | Array [ 438 | Object { 439 | "geometry": null, 440 | "properties": Object { 441 | "name": "SF Marina Harbor Master", 442 | }, 443 | "type": "Feature", 444 | }, 445 | ] 446 | ` 447 | 448 | exports[`test/flatten.js TAP flatten nullgeometry.input.geojson > nullgeometry.input.geojson 1`] = ` 449 | Object { 450 | "features": Array [ 451 | Object { 452 | "geometry": null, 453 | "properties": Object { 454 | "name": "SF Marina Harbor Master", 455 | }, 456 | "type": "Feature", 457 | }, 458 | ], 459 | "type": "FeatureCollection", 460 | } 461 | ` 462 | 463 | exports[`test/flatten.js TAP flatten point-single.input.geojson > point-single.input.geojson 1`] = ` 464 | Array [ 465 | Object { 466 | "geometry": Object { 467 | "geometries": Array [ 468 | 0, 469 | 0, 470 | ], 471 | "type": "Point", 472 | }, 473 | "properties": Object { 474 | "name": "SF Marina Harbor Master", 475 | }, 476 | "type": "Feature", 477 | }, 478 | ] 479 | ` 480 | 481 | exports[`test/flatten.js TAP flatten point.input.geojson > point.input.geojson 1`] = ` 482 | Object { 483 | "features": Array [ 484 | Object { 485 | "geometry": Object { 486 | "geometries": Array [ 487 | 0, 488 | 0, 489 | ], 490 | "type": "Point", 491 | }, 492 | "properties": Object { 493 | "name": "SF Marina Harbor Master", 494 | }, 495 | "type": "Feature", 496 | }, 497 | ], 498 | "type": "FeatureCollection", 499 | } 500 | ` 501 | -------------------------------------------------------------------------------- /test/fixture/multigeometry.input.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": { 7 | "type": "GeometryCollection", 8 | "geometries": [ 9 | { 10 | "type": "MultiPoint", 11 | "coordinates": [ 12 | [ 13 | -122.4425587930444, 14 | 37.80666418607323, 15 | 0 16 | ], 17 | [ 18 | -122.4428379594768, 19 | 37.80663578323093, 20 | 0 21 | ] 22 | ] 23 | }, 24 | { 25 | "type": "LineString", 26 | "coordinates": [ 27 | [ 28 | -122.4425587930444, 29 | 37.80666418607323, 30 | 0 31 | ], 32 | [ 33 | -122.4428379594768, 34 | 37.80663578323093, 35 | 0 36 | ] 37 | ] 38 | }, 39 | { 40 | "type": "LineString", 41 | "coordinates": [ 42 | [ 43 | -122.4425509770566, 44 | 37.80662588061205, 45 | 0 46 | ], 47 | [ 48 | -122.4428340530617, 49 | 37.8065999493009, 50 | 0 51 | ] 52 | ] 53 | } 54 | ] 55 | }, 56 | "properties": { 57 | "name": "SF Marina Harbor Master" 58 | } 59 | } 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /test/fixture/multilinestring.input.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": { 7 | "type": "MultiLineString", 8 | "coordinates": [ 9 | [[0, 0], [1, 1]], 10 | [[2, 2], [3, 3]] 11 | ] 12 | }, 13 | "properties": { 14 | "name": "SF Marina Harbor Master" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/fixture/multipoint.input.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": { 7 | "type": "MultiPoint", 8 | "coordinates": [ 9 | [0, 0], [1, 1] 10 | ] 11 | }, 12 | "properties": { 13 | "name": "SF Marina Harbor Master" 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/fixture/multipolygon.input.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": { 7 | "type": "MultiPolygon", 8 | "coordinates": [ 9 | [[0, 0], [1, 1], [4, 2], [0, 0]], 10 | [[0, 0], [5, 5], [4, 2], [0, 0]] 11 | ] 12 | }, 13 | "properties": { 14 | "name": "SF Marina Harbor Master" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/fixture/nullgeometry.input.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": null, 7 | "properties": { 8 | "name": "SF Marina Harbor Master" 9 | } 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/fixture/point.input.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "geometry": { 7 | "type": "Point", 8 | "geometries": [0, 0] 9 | }, 10 | "properties": { 11 | "name": "SF Marina Harbor Master" 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/flatten.js: -------------------------------------------------------------------------------- 1 | import flatten from "../"; 2 | import fs from "fs"; 3 | import tap from "tap"; 4 | 5 | tap.test("flatten", function(group) { 6 | fs.readdirSync(__dirname + "/fixture") 7 | .filter(function(fix) { 8 | return fix.match(/input/); 9 | }) 10 | .forEach(function(fixture) { 11 | group.test(fixture, function(t) { 12 | t.matchSnapshot( 13 | flatten( 14 | JSON.parse(fs.readFileSync(__dirname + "/fixture/" + fixture)) 15 | ), 16 | fixture 17 | ); 18 | t.end(); 19 | }); 20 | }); 21 | group.end(); 22 | }); 23 | -------------------------------------------------------------------------------- /test/linestring.geojson: -------------------------------------------------------------------------------- 1 | {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.364383,37.824664,0],[-122.364152,37.824322,0]]},"properties":{"name":"unextruded"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.364167,37.824787,50],[-122.363917,37.824423,50]]},"properties":{"name":"extruded"}}]} 2 | -------------------------------------------------------------------------------- /test/point.input.geojson: -------------------------------------------------------------------------------- 1 | {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[-122.0822035425683,37.42228990140251,0]},"properties":{"name":"Simple placemark","description":"Attached to the ground. Intelligently places itself \n at the height of the underlying terrain."}}]} 2 | --------------------------------------------------------------------------------