koopjs / FeatureServer

An open source Geoservices Implementation (deprecated)
https://geoservices.github.io
Other
104 stars 32 forks source link

Error when returnCountOnly=true and resulting count=0 #70

Closed jkerr5 closed 6 years ago

jkerr5 commented 6 years ago

When processing a request where returnCountOnly=true but the where clause is such that no features match so the resulting count is 0, I get the following error:

SELECT properties as attributes, esriGeom(geometry) as geometry FROM ? LIMIT 2000 { returnCountOnly: true,
  limit: 2000,
  toEsri: true,
  collection: undefined,
  where: undefined,
  geometry: undefined,
  spatialPredicate: undefined,
  fields: undefined,
  order: undefined,
  aggregates: undefined,
  groupBy: undefined,
  offset: undefined,
Trace: TypeError: features.some is not a function
  projection: undefined,
    at limitQuery (/koop-provider-marklogic/build/koop/node_modules/winnow/dist/executeQuery.js:39:12)
  classification: undefined,
    at Object.Winnow.query (/koop-provider-marklogic/build/koop/node_modules/winnow/dist/index.js:34:36)
  dateFields: [] }
    at query (/koop-provider-marklogic/build/koop/node_modules/featureserver/dist/query.js:32:56)
    at execQuery (/koop-provider-marklogic/build/koop/node_modules/featureserver/dist/route.js:43:16)
    at Object.route (/koop-provider-marklogic/build/koop/node_modules/featureserver/dist/route.js:32:14)
    at /koop-provider-marklogic/build/koop/node_modules/koop-output-geoservices/index.js:9:24
    at /koop-provider-marklogic/build/koop/node_modules/koop/dist/models/index.js:15:9
    at mq.providerGetData.then.data (/koop-provider-marklogic/build/koop/marklogic.js:41:8)
    at execQuery (/koop-provider-marklogic/build/koop/node_modules/featureserver/dist/route.js:45:52)
    at Object.route (/koop-provider-marklogic/build/koop/node_modules/featureserver/dist/route.js:32:14)
    at /koop-provider-marklogic/build/koop/node_modules/koop-output-geoservices/index.js:9:24
    at /koop-provider-marklogic/build/koop/node_modules/koop/dist/models/index.js:15:9
    at mq.providerGetData.then.data (/koop-provider-marklogic/build/koop/marklogic.js:41:8)

Changing the query to return a count other than 0 works fine.

The result returned from the getData() function looks like this

{ type: 'FeatureCollection',
  metadata: { name: 'GDeltGKG' },
  filtersApplied: { geometry: true, where: true, offset: true },
  count: 0 }
jgravois commented 6 years ago

ArcGIS Server response:

// 20171218093136
// http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3/query?where=1%3D2&returnCountOnly=true&f=geojson

{
  "count": 0
}
jkerr5 commented 6 years ago

Yes, that should be the response. I can work around this issue by setting the features in the response to an empty array like this:

{ type: 'FeatureCollection',
  metadata: { name: 'GDeltGKG' },
  filtersApplied: { geometry: true, where: true, offset: true },
  count: 0,
  features: [] }
dmfenton commented 6 years ago

published @2.9.2