Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derjasper/simple-geojson-server
Transform GeoJSON files into a REST API
https://github.com/derjasper/simple-geojson-server
Last synced: 4 months ago
JSON representation
Transform GeoJSON files into a REST API
- Host: GitHub
- URL: https://github.com/derjasper/simple-geojson-server
- Owner: derjasper
- License: gpl-3.0
- Created: 2016-02-15T22:10:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-05T20:05:30.000Z (almost 7 years ago)
- Last Synced: 2024-06-22T13:44:25.769Z (6 months ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-geojson-server
This is a simple HTTP server that reads data from [GeoJSON](http://geojson.org/) files and makes the data available via a RESTful API.
## Data format
All input files must be in GeoJSON format and contain a single FeatureCollection where each Feature has the `id` attribute defined. The encoding should be UTF-8.
## REST API
* `http://host:8081/?radius=&lat=&lng=[&sort=]`
Selects all Features that are contained in a circle of the given radius (in metre) around the given coordinates, sorted by the given property (default: `dist`). The `dist` property is calculated and added as property for each Feature.
Returns a FeatureCollection.
* `http://host:8081//id`
Returns a Feature by id.
There will be more flexible queries possible in future.
## Configuration
Default `config.json`
{
"http": {
"port": 8081 // port to listen to (http)
},
"localsocket": {
"file": "/tmp/simple-geojson-server.sock" // control socket
},
"statistics": {
"file": "statistics.json" // file where usage statistics are recorded to
},
"services": {
"fuelSpain": {
"file": "data/fuelSpain.geojson", // path to geojson file
"limit": 25, // max number of entries in query result
"radius": 25000 // max radius in query (in metres)
}
}
}## Starting the server
Simply run `node app.js`.
## Notify the server about data updates
When another application updated the geojson file, you may want to make the data available to the REST API without restarting the server. The server starts a local socket at `/tmp/simple-geojson-server.sock` by default. By sending `updateService ` you can force an update of the specified service. See `command.js` for an example how to connect to the local socket.
## Statistics
The server contains a simple hit counter that counts hits by service and day.
## Current Limitations
* Only Points are supported
* Features can only be queried by specifying a single position and radius