@koopjs/winnow
Advanced tools
Comparing version 4.0.5 to 4.1.0
{ | ||
"name": "@koopjs/winnow", | ||
"version": "4.0.5", | ||
"version": "4.1.0", | ||
"description": "Apply sql-like filters to GeoJSON", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -19,9 +19,15 @@ const _ = require('lodash'); | ||
function extractIdField ({ idField, fields } = {}, feature = {}) { | ||
if (idField) return idField; | ||
if (idField) { | ||
return idField; | ||
} | ||
// metadata.idField is not set, but fields array includes OBJECTID, use that as idField | ||
if (_.find(fields, { name: 'OBJECTID' })) return 'OBJECTID'; | ||
if (_.find(fields, { name: 'OBJECTID' })) { | ||
return 'OBJECTID'; | ||
} | ||
const properties = feature.properties || feature.attributes; | ||
if (_.has(properties, 'OBJECTID') && properties.OBJECTID !== null) return 'OBJECTID'; | ||
if (_.has(properties, 'OBJECTID') && properties.OBJECTID !== null) { | ||
return 'OBJECTID'; | ||
} | ||
@@ -28,0 +34,0 @@ return null; |
@@ -17,2 +17,3 @@ const _ = require('lodash'); | ||
const normalizeOffset = require('./offset'); | ||
const normalizeObjectIds = require('./object-ids'); | ||
@@ -38,3 +39,4 @@ function normalizeQueryOptions (options, features) { | ||
inputCrs: normalizeSourceDataSpatialReference(options), | ||
classification: normalizeClassification(options) | ||
classification: normalizeClassification(options), | ||
objectIds: normalizeObjectIds(options.objectIds) | ||
}); | ||
@@ -41,0 +43,0 @@ normalizedOptions.offset = normalizeOffset(normalizedOptions); |
@@ -8,3 +8,3 @@ const SqlWhereBuilder = require('./where-builder'); | ||
const select = createSelectSql(options); | ||
const where = options.where || options.geometry ? ` WHERE ${SqlWhereBuilder.create(options)}` : ''; | ||
const where = options.objectIds || options.where || options.geometry ? ` WHERE ${SqlWhereBuilder.create(options)}` : ''; | ||
const orderBy = createOrderByClause(options); | ||
@@ -11,0 +11,0 @@ const groupBy = createGroupByClause(options); |
@@ -112,2 +112,6 @@ const { InvalidWhereParameterError } = require('../../errors'); | ||
toJsonSQL () { | ||
if (this.#options.objectIds && this.#options.idField) { | ||
this.#addObjectIdsFilter(); | ||
} | ||
if (!this.#where) { | ||
@@ -121,2 +125,12 @@ return this; | ||
#addObjectIdsFilter() { | ||
const objectIdFilter = `${this.#options.idField} IN (${this.#options.objectIds.join(',')})`; | ||
if (this.#where) { | ||
this.#where = `${this.#where} AND ${objectIdFilter}`; | ||
return; | ||
} | ||
this.#where = objectIdFilter; | ||
} | ||
/** | ||
@@ -123,0 +137,0 @@ * if the where clause includes OBJECTID predicate and there is no "idField" option |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96467
80
2017