FeatureServer
An open source implementation of the GeoServices specification
Usage
This is meant to be used as a plugin to Express
Example server
const express = require('express')
const app = express()
const featureServer = require('featureserver')
const cache = require('cache')
const handler = (req, res) => {
cache.get(, (err, data) => {
if (err) res.status(500).json({error: err.message})
else FeatureServer.route(req, res, data)
})
}
const routes = ['/FeatureServer', '/FeatureServer/layers', '/FeatureServer/:layer', '/FeatureServer/:layer/:method']
routes.forEach(route => {
app.route(route)
.get(handler)
.post(handler)
})
API
FeatureServer.route
Pass in an incoming request object
, an outgoing response object
and geojson
and this function will route and return a geoservices compliant response
Supports: '/FeatureServer', '/FeatureServer/layers', '/FeatureServer/:layer', '/FeatureServer/:layer/:method'
Note: only query
and info
are supported methods at this type
FeatureServer.route(req, res, data, options)
Data is a geojson object extended with some additional properties. These properties are optional and can be used to provide more specific metadata or to shortcut the built in filtering mechanism.
e.g.
{
type: 'FeatureCollection'
features: Array,
statistics: Object,
metadata: {
name: String,
extent: Object || Array
id: String
},
filtersApplied: {
geometry: Boolean,
where: Boolean
}
count: Number
}
FeatureServer.query
Pass in geojson
and a valid geoservices query object
e.g. where=OBJECTID>10
and the function will perform the query and return a valid geoservices query object
FeatureServer.query(geojson, options)
FeatureServer.serverInfo
Generate version 10.21
Geoservices-like server info
FeatureServer.serverInfo()
FeatureServer.layerInfo
Generate version 10.21
Geoservices-like information about a single layer
FeatureServer.layerInfo(geojson, options)
FeatureServer.layers
Generate version 10.21
Geoservices-like information about one or many layers
Can pass a single geojson object or an array of geojson objects
FeatureServer.layers(geojson, options)