Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koopjs/koop-provider-file-geojson
Simple Koop provider for serving file-based GeoJSON
https://github.com/koopjs/koop-provider-file-geojson
koop-provider
Last synced: about 1 month ago
JSON representation
Simple Koop provider for serving file-based GeoJSON
- Host: GitHub
- URL: https://github.com/koopjs/koop-provider-file-geojson
- Owner: koopjs
- License: other
- Created: 2018-05-22T14:47:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-21T16:55:34.000Z (over 1 year ago)
- Last Synced: 2024-11-05T13:56:31.311Z (about 2 months ago)
- Topics: koop-provider
- Language: JavaScript
- Homepage:
- Size: 252 KB
- Stars: 5
- Watchers: 5
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# koop-provider-file-geojson
Serve local GeoJSON files as [Koop](https://github.com/koopjs/koop) services. Use as a standalone Koop instance or add to an existing Koop implementation.
## Getting Started
Add the provider to your koop instance
``sh
$ npm install @koopjs/provider-file-geojson
``Then register the provider with Koop in your server file.
```js
const Koop = require('koop')
const koop = new Koop()const provider = require('@koopjs/provider-file-geojson')
koop.register(provider)
```### Usage
The provider will look for requested geojson files in a `/data` directory in the koop application root. For example, the following request will serve data from the file `data/polygon-sample.geojson` :
```
$ curl http://localhost:8080/file-geojson/rest/services/polygon-sample/FeatureServer/0/query
```## Usage
### Setting the data directory
The provider needs to know where to locate the GeoJSON files it should serve. A directory can be assign in several ways.
By default, the provider looks for files in the `/data` directory in the koop application root. For example, the following request will serve data from the file `data/polygon-sample.geojson`:```
$ curl http://localhost:8080/file-geojson/rest/services/polygon-sample/FeatureServer/0/query
```You can override where the provider looks by adding a `dataDir` field to the provider's registration options:
```js
const Koop = require('koop')
const koop = new Koop()const provider = require('@koopjs/provider-file-geojson')
koop.register(provider, { dataDir: 'path-to-data-directory'})
```You can also achieve the same by setting an environment variable `KOOP_DATA_DIR=`. Paths should be relative to the koop server file.
### Files
All valid GeoJSON files can be served. Place them in the data directory and ensure they have a `.geojson` file extension.### Request parameters
Request a particular file by using the (extension-less) file name as the `:id` parameter in the URL. For example, when requesting data from the file `point-fc.geojson`:
`http://localhost:8080/file-geojson/rest/services/:id/FeatureServer/0/query`becomes:
`http://localhost:8080/file-geojson/rest/services/point-fc/FeatureServer/0/query`
## Contributing
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/Esri/contributing).
## License
[Apache 2.0](LICENSE)