https://github.com/koopjs/featureservice
Get all features from an Esri Feature Service.
https://github.com/koopjs/featureservice
Last synced: 10 months ago
JSON representation
Get all features from an Esri Feature Service.
- Host: GitHub
- URL: https://github.com/koopjs/featureservice
- Owner: koopjs
- License: other
- Created: 2015-07-23T16:41:50.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T21:42:59.000Z (over 3 years ago)
- Last Synced: 2025-08-17T14:28:26.481Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 686 KB
- Stars: 22
- Watchers: 8
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# featureservice
*Get all features from an Esri Feature Service*
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
[npm-image]: https://img.shields.io/npm/v/featureservice.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/featureservice
[travis-image]: https://img.shields.io/travis/koopjs/featureservice.svg?style=flat-square
[travis-url]: https://travis-ci.org/koopjs/featureservice
[greenkeeper-image]: https://badges.greenkeeper.io/koopjs/featureservice.svg
[greenkeeper-url]: https://greenkeeper.io/
A little module that extracts every feature from an Esri Feature Service. The real power in this module is that it's designed to page over a service and extract every single feature no matter what ArcGIS Server version the data is hosted on.
## Install
```
npm install featureservice
```
## Usage
```javascript
var FeatureService = require('featureservice')
// a url to a feature service
var url = 'http://....../FeatureServer/0'
var service = new FeatureService(url, options)
service.pages(function (err, pages) {
/* will give you links to all pages of data in the service*/
})
```
### Options
An object passed as the second parameter when initializing a service
- layer: the layer index to use
- size: the maximum page size when requesting features
- concurrency: the maximum concurrency for requesting features from a single server
- timeOut: the amount of time to wait with no response before cancelling a request
- logger: An object with a log method that takes a level and a message e.g. a Winston instance
### API
#### info(callback)
Get the information describing the service itself
#### layerIds(callback)
Get all the ids in a feature service layer
#### layerInfo(callback)
Get the json metadata for a service layer
#### statistics(field, stats, callback)
Get statistics for a field and an array of stats.
```javascript
service.statistics('id', ['min', 'max'], function (err, stats) {
console.log(stats.features)
})
```
#### pages(callback)
Returns an array of page urls that would get every feature in the service
### Browser
A browser ready build of this module is in `dist/featureservice.min.js`.
#### Example
```html
var service = new FeatureService('http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/0', {})
service.statistics('id', ['max'], function (err, stats) {
console.log(err, stats)
})
```
## License
[Apache 2.0](LICENSE)