New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

featureservice

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

featureservice - npm Package Compare versions

Comparing version 1.5.11 to 1.5.12

.eslintrc.js

5

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [1.5.12] - 2017-12-29
### Changed
* Z value is requested when paging
## [1.5.11] - 2016-10-23

@@ -233,2 +237,3 @@ ### Fixed

[1.5.12]: https://github.com/koopjs/featureservice/compare/v1.5.11...v1.5.12
[1.5.11]: https://github.com/koopjs/featureservice/compare/v1.5.10...v1.5.11

@@ -235,0 +240,0 @@ [1.5.10]: https://github.com/koopjs/featureservice/compare/v1.5.9...v1.5.10

39

index.js

@@ -30,11 +30,3 @@ var queue = require('async').queue

this._request = require('request').defaults({
gzip: true,
// had to remove forever agent due to https://github.com/nodejs/node/issues/3595
// this is fixed in node 4
timeout: this.options.timeOut,
headers: {
'user-agent': 'Featureservices-Node'
}
})
this._request = require('xhr-request')

@@ -89,16 +81,19 @@ // an async for requesting pages of data

var options = {
method: 'GET',
url: encoded
timeout: this.options.timeOut,
headers: {
'user-agent': 'Featureservices-Node'
}
}
this._request(options, function (err, res) {
this._request(encoded, options, function (err, data, res) {
if (err) {
if (err.message === 'ESOCKETTIMEDOUT') err.code = 504
if (err.code === 'ESOCKETTIMEDOUT') err.code = 504
return callback(err)
}
try {
json = JSON.parse(res.body)
json = JSON.parse(data)
} catch (err) {
// sometimes we get html or plain strings back
var pattern = new RegExp(/[^{\[]/)
if (res.body.slice(0, 1).match(pattern)) {
var pattern = new RegExp(/[^{\[]/) // eslint-disable-line
if (data.slice(0, 1).match(pattern)) {
return callback(new Error('Received HTML or plain text when expecting JSON'))

@@ -367,3 +362,3 @@ }

function singlePage (server, layer) {
return [{req: [server, '/', layer, '/query?where=1=1&returnGeometry=true&outFields=*&outSR=4326&f=json'].join('')}]
return [{req: [server, '/', layer, '/query?where=1=1&returnGeometry=true&returnZ=true&outFields=*&outSR=4326&f=json'].join('')}]
}

@@ -418,6 +413,6 @@

var pageUrl = url + '/' + this.layer + '/query?outSR=4326&f=json&outFields=*&where=1=1'
if (pages === 1) return [{req: pageUrl + '&geometry=&returnGeometry=true&geometryPrecision='}]
if (pages === 1) return [{req: pageUrl + '&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='}]
pageUrl += '&resultOffset=' + resultOffset
pageUrl += '&resultRecordCount=' + size
pageUrl += '&geometry=&returnGeometry=true&geometryPrecision='
pageUrl += '&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='
reqs.push({req: pageUrl})

@@ -448,3 +443,3 @@ }

var pageUrl = this.server + '/' + (this.layer) + '/query?outSR=4326&where=' + where + '&f=json&outFields=*'
pageUrl += '&geometry=&returnGeometry=true&geometryPrecision=10'
pageUrl += '&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=10'
reqs.push({req: pageUrl})

@@ -487,3 +482,3 @@ }

pageUrl = url + '/' + (this.layer || 0) + '/query?outSR=4326&where=' + where + '&f=json&outFields=*'
pageUrl += '&geometry=&returnGeometry=true&geometryPrecision='
pageUrl += '&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='
reqs.push({req: pageUrl})

@@ -549,3 +544,5 @@ }

else this.concurrency += 0.1
if (this.concurrency > this.maxConcurrency) this.concurrency = this.maxConcurrency
this.pageQueue.concurrency = this.concurrency >= 1 ? Math.floor(this.concurrency) : 1

@@ -552,0 +549,0 @@ }

{
"name": "featureservice",
"description": "Get all features from an Esri Feature Service",
"version": "1.5.11",
"version": "1.5.12",
"author": "Chris Helm",

@@ -9,16 +9,16 @@ "bugs": {

},
"contributors": "Daniel Fenton",
"contributors": ["Daniel Fenton"],
"dependencies": {
"async": "^1.4.0",
"request": "^2.75.0"
"async": "^2.1.5",
"xhr-request": "^1.0.1"
},
"devDependencies": {
"browserify": "^11.0.0",
"browserify": "^14.1.0",
"http-browserify": "^1.7.0",
"https-browserify": "0.0.0",
"https-browserify": "1.0.0",
"lodash": "^4.0.0",
"minifyify": "^7.0.3",
"nock": "^2.10.0",
"sinon": "^1.15.4",
"standard": "^5.0.0",
"nock": "^9.0.9",
"sinon": "^2.0.0",
"standard": "^10.0.0",
"tap-spec": "^4.0.2",

@@ -25,0 +25,0 @@ "tape": "^4.0.1",

# featureservice
> Get all features from an Esri Feature Service
*Get all features from an Esri Feature Service*
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]

@@ -12,2 +13,4 @@ [npm-image]: https://img.shields.io/npm/v/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/

@@ -14,0 +17,0 @@ 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.

@@ -75,4 +75,4 @@ var sinon = require('sinon')

pages = service._rangePages(stats, stats.max / 2)
t.equal(pages[0].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID>=0+AND+OBJECTID<=999&f=json&outFields=*&geometry=&returnGeometry=true&geometryPrecision=')
t.equal(pages[1].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID>=1000+AND+OBJECTID<=2000&f=json&outFields=*&geometry=&returnGeometry=true&geometryPrecision=')
t.equal(pages[0].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID>=0+AND+OBJECTID<=999&f=json&outFields=*&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
t.equal(pages[1].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID>=1000+AND+OBJECTID<=2000&f=json&outFields=*&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
t.equal(pages.length, 2)

@@ -89,5 +89,5 @@ pages = service._rangePages(stats, stats.max / 4)

t.equal(pages.length, 3)
t.equal(pages[0].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID >= 0 AND OBJECTID<=1&f=json&outFields=*&geometry=&returnGeometry=true&geometryPrecision=10')
t.equal(pages[1].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID >= 2 AND OBJECTID<=3&f=json&outFields=*&geometry=&returnGeometry=true&geometryPrecision=10')
t.equal(pages[2].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID >= 4 AND OBJECTID<=5&f=json&outFields=*&geometry=&returnGeometry=true&geometryPrecision=10')
t.equal(pages[0].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID >= 0 AND OBJECTID<=1&f=json&outFields=*&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=10')
t.equal(pages[1].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID >= 2 AND OBJECTID<=3&f=json&outFields=*&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=10')
t.equal(pages[2].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&where=OBJECTID >= 4 AND OBJECTID<=5&f=json&outFields=*&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=10')
t.end()

@@ -99,4 +99,4 @@ })

var pages = service._offsetPages(4, maxCount)
t.equal(pages[0].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=0&resultRecordCount=100&geometry=&returnGeometry=true&geometryPrecision=')
t.equal(pages[1].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=100&resultRecordCount=100&geometry=&returnGeometry=true&geometryPrecision=')
t.equal(pages[0].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=0&resultRecordCount=100&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
t.equal(pages[1].req, 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=100&resultRecordCount=100&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
t.equal(pages.length, 4)

@@ -114,3 +114,3 @@

test('get the metadata for a layer on the service', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, layerFixture)

@@ -127,3 +127,3 @@ })

test('get the metadata for a service', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, serviceFixture)

@@ -173,3 +173,3 @@ })

test('get all the object ids for a layer on the service', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, idFixture)

@@ -187,3 +187,3 @@ })

test('get the range of object ids for a service', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, statsFixture)

@@ -203,3 +203,3 @@ })

test('get the range of object ids for a service when the attribute names are unexpectedly capitalized', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, statsFixtureCaps)

@@ -219,3 +219,3 @@ })

test('get the feature count for a layer on the service', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, countFixture)

@@ -233,3 +233,3 @@ })

test('get a json error when trying to get a feature count', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, securedFixture)

@@ -247,3 +247,3 @@ })

test('get an error with no response body when trying to get a feature count', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(new Error(), null)

@@ -259,3 +259,3 @@ })

test('get a json error when trying to get layer ids', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, securedFixture)

@@ -273,3 +273,3 @@ })

test('get an error with no response body when trying to get layer ids', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(new Error(), null)

@@ -285,3 +285,3 @@ })

test('get a json error when trying to get layer info', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, securedFixture)

@@ -299,3 +299,3 @@ })

test('get an error with no response body when trying to get layer info', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(new Error(), null)

@@ -311,3 +311,3 @@ })

test('get a json error when trying to get statistics', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(null, securedFixture)

@@ -325,3 +325,3 @@ })

test('get an error with no response body when trying to get statistics', function (t) {
sinon.stub(service, 'request', function (url, callback) {
sinon.stub(service, 'request').callsFake(function (url, callback) {
callback(new Error(), null)

@@ -363,3 +363,3 @@ })

sinon.stub(service, '_catchErrors', function (task, err, url, callback) {
sinon.stub(service, '_catchErrors').callsFake(function (task, err, url, callback) {
callback(err)

@@ -384,7 +384,7 @@ })

fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision=')
fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
.reply(200, function () { return page })
var service = new FeatureService('http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0')
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision='}
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='}

@@ -402,7 +402,7 @@ service._requestFeatures(task, function (err, json) {

fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision=')
fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
.reply(200, function () { return page }, {'content-encoding': 'gzip'})
var service = new FeatureService('http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0')
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision='}
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='}

@@ -420,7 +420,7 @@ service._requestFeatures(task, function (err, json) {

fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision=')
fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
.reply(200, function () { return page }, {'content-encoding': 'deflate'})
var service = new FeatureService('http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0')
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision='}
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='}

@@ -438,3 +438,3 @@ service._requestFeatures(task, function (err, json) {

fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision=')
fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
.times(4)

@@ -444,3 +444,3 @@ .reply(200, function () { return page })

var service = new FeatureService('http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0', {backoff: 1})
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision='}
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='}

@@ -457,3 +457,3 @@ service._requestFeatures(task, function (err, json) {

fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision=')
fixture.get('/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision=')
.times(4)

@@ -463,3 +463,3 @@ .reply(200, function () { return undefined })

var service = new FeatureService('http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0', {backoff: 1})
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&geometryPrecision='}
var task = {req: 'http://servicesqa.arcgis.com/97KLIFOSt5CxbiRI/arcgis/rest/services/QA_data_simple_point_5000/FeatureServer/0/query?outSR=4326&f=json&outFields=*&where=1=1&resultOffset=1000&resultRecordCount=1000&geometry=&returnGeometry=true&returnZ=true&geometryPrecision='}

@@ -565,3 +565,3 @@ service._requestFeatures(task, function (err, json) {

nock('http://www.foobar.com').get('/FeatureServer/0/query?where=1=1').socketDelay(100).reply({}.toString())
sinon.stub(service, '_abortPaging', function (err, callback) {
sinon.stub(service, '_abortPaging').callsFake(function (err, callback) {
callback(err)

@@ -593,3 +593,3 @@ })

sinon.stub(service, '_abortPaging', function (error, cb) {
sinon.stub(service, '_abortPaging').callsFake(function (error, cb) {
cb(error)

@@ -620,3 +620,3 @@ })

t.plan(2)
sinon.stub(service, '_console', function (level, message) {
sinon.stub(service, '_console').callsFake(function (level, message) {
t.equal(level, 'test')

@@ -623,0 +623,0 @@ t.equal(message, 'test')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc