https://github.com/koopjs/koop-output-flat
Convert GeoJSON to a flattened JSON array
https://github.com/koopjs/koop-output-flat
Last synced: about 1 year ago
JSON representation
Convert GeoJSON to a flattened JSON array
- Host: GitHub
- URL: https://github.com/koopjs/koop-output-flat
- Owner: koopjs
- License: other
- Created: 2019-01-31T20:56:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T21:13:22.000Z (over 3 years ago)
- Last Synced: 2025-01-24T10:47:17.426Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# koop-output-flat
This output-services plugin converts GeoJSON properties to a "flat" json array. Geometry is stripped. Any nested GeoJSON properties are moved to the root level and given keys that are a path to their original nested location. For example, the following GeoJSON:
```
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"keywords": ["place", "residence"],
"address": {
"street": "187 Suffolk Ln.",
"City": "Boise"
}
},
"geometry": {
"type": "Point",
"coordinates": [
-121.14486694336,
47.884118004966
]
}
}
]
}
```
will get converted to:
```
[
{
"keywords.0": "place",
"keywords.1": "residence",
"address.street": "187 Suffolk Ln.",
"address.City": "Boise"
}
]
```
Note that geometry is omitted from the response
.
## Usage
Register this plugin with koop before your provider plugins to ensure that the `flat` routes are bound to the providers.
```
const flat = require('@koopjs/output-flat')
koop.register(flat)
// Register providers
```
After startup, Koop will include an `flat` route for each registered provider. For example, if you had registered the Github provider, the following route would be available:
`/github/:id/flat`