Comparing version 1.16.4 to 1.16.5
@@ -5,2 +5,6 @@ # Change Log | ||
## [1.16.5] - 11-28-2018 | ||
### Changed | ||
* Removed workaround for adding and `OBJECTID` field even when metadata `idField` is set | ||
## [1.16.4] - 09-13-2018 | ||
@@ -293,2 +297,3 @@ ### Fixed | ||
[1.16.5]: https://github.com/featureserver/winnow/compare/v1.16.4...v1.16.5 | ||
[1.16.4]: https://github.com/featureserver/winnow/compare/v1.16.3...v1.16.4 | ||
@@ -295,0 +300,0 @@ [1.16.3]: https://github.com/featureserver/winnow/compare/v1.16.2...v1.16.3 |
@@ -16,2 +16,3 @@ var _ = require('lodash') | ||
var normalizeProjection = ref$1.normalizeProjection; | ||
var normalizeIdField = ref$1.normalizeIdField; | ||
var ref$2 = require('./normalizeClassification'); | ||
@@ -23,2 +24,3 @@ var normalizeClassification = ref$2.normalizeClassification; | ||
collection: normalizeCollection(options, features), | ||
idField: normalizeIdField(options, features), | ||
where: normalizeWhere(options), | ||
@@ -37,3 +39,2 @@ geometry: normalizeGeometry(options), | ||
prepared.dateFields = normalizeDateFields(prepared.collection, prepared.fields) | ||
prepared.idField = _.get(prepared.collection, 'metadata.idField') || null | ||
if (prepared.where === '1=1') { delete prepared.where } | ||
@@ -40,0 +41,0 @@ |
var _ = require('lodash') | ||
var wktParser = require('wkt-parser') | ||
var esriProjCodes = require('@esri/proj-codes') | ||
var esriOldProjCodes = require('esri-proj-codes') | ||
var convertFromEsri = require('../geometry/convert-from-esri') | ||
@@ -19,16 +18,15 @@ var transformArray = require('../geometry/transform-array') | ||
function normalizeCollection (options, features) { | ||
if ( options === void 0 ) options = {}; | ||
if ( features === void 0 ) features = []; | ||
if (!options.collection) { return undefined } | ||
// Make a new copy of the collection so we don't modify the original | ||
var collection = _.cloneDeep(options.collection) | ||
var metadata = collection.metadata || {} | ||
if (!metadata.fields && features[0]) { metadata.fields = detectFieldsType(features[0].properties) } | ||
var oidField | ||
if (features[0]) { | ||
oidField = Object.keys(features[0].properties).filter(function (key) { | ||
return /objectid/i.test(key) | ||
})[0] | ||
} | ||
if (oidField && !metadata.idField) { metadata.idField = oidField } | ||
collection.metadata = metadata | ||
collection.metadata = collection.metadata || {} | ||
// If fields haven't been set in metadata and there is at least one feature, determine | ||
// field set from a feature properties | ||
if (!collection.metadata.fields && features[0]) { collection.metadata.fields = detectFieldsType(features[0].properties) } | ||
return collection | ||
@@ -144,3 +142,3 @@ } | ||
// If the wkid was not found in the local lookup, check the Esri lookups | ||
var esriResult = esriProjCodes.lookup(inputWkid) || esriOldProjCodes.lookup(inputWkid) | ||
var esriResult = esriProjCodes.lookup(inputWkid) | ||
if (esriResult) { | ||
@@ -211,2 +209,31 @@ // Add the WKT to the local lookup so we don't need to scan the Esri lookups next time (we have a local lookup, because it will contain a smaller set of wkids than the Esri lookups) | ||
/** | ||
* Ensure idField is set if metadata doesn't have a value but a field named OBJECTID is present | ||
* @param {object} metadata | ||
*/ | ||
function normalizeIdField (options, features) { | ||
if ( features === void 0 ) features = []; | ||
var collection = options.collection || {} | ||
var metadata = collection.metadata || {} | ||
var feature = features[0] || {} | ||
var featureProperties = feature.properties || feature.attributes || {} | ||
var idField = null | ||
// First, check metadata for idField | ||
if (metadata.idField) { idField = metadata.idField } | ||
// Check metadata.fields for and OBJECTID property | ||
else if (_.find(metadata.fields, { name: 'OBJECTID' })) { idField = 'OBJECTID' } | ||
// Check features for an OBJECTID property that is not null | ||
else if (features.length > 0 && !_.isUndefined(featureProperties.OBJECTID) && !_.isNull(featureProperties.OBJECTID)) { idField = 'OBJECTID' } | ||
// If there are features, check that the idField is one of the properties | ||
if (process.env.NODE_ENV !== 'production' && process.env.KOOP_WARNINGS !== 'suppress' && idField && features.length > 0 && !featureProperties[idField]) { | ||
console.warn("WARNING: requested provider has \"idField\" assignment, but this property is not found in properties of all features.") | ||
} | ||
return idField | ||
} | ||
module.exports = { | ||
@@ -222,3 +249,4 @@ normalizeCollection: normalizeCollection, | ||
normalizeInSR: normalizeInSR, | ||
normalizeSourceSR: normalizeSourceSR | ||
normalizeSourceSR: normalizeSourceSR, | ||
normalizeIdField: normalizeIdField | ||
} |
@@ -0,1 +1,3 @@ | ||
var _ = require('lodash') | ||
function normalizeWhere (options) { | ||
@@ -21,4 +23,6 @@ if (/1\s*=\s*1/.test(options.where)) { return undefined } | ||
var fields = options.fields || options.outFields | ||
var idField = _.get(options, 'collection.metadata.idField') | ||
if (options.returnIdsOnly === true && idField) { return [idField] } | ||
else if (options.returnIdsOnly === true) { return ['OBJECTID'] } | ||
if (fields === '*') { return undefined } | ||
if (options.returnIdsOnly === true) { return ['OBJECTID'] } | ||
if (typeof fields === 'string' || fields instanceof String) { return fields.split(',') } | ||
@@ -25,0 +29,0 @@ if (fields instanceof Array) { return fields } |
@@ -160,3 +160,2 @@ var Terraformer = require('terraformer') | ||
} | ||
properties.OBJECTID = properties[idField] | ||
} else { | ||
@@ -163,0 +162,0 @@ // Create an OBJECTID by creating a numeric hash from the stringified feature |
{ | ||
"name": "winnow", | ||
"version": "1.16.4", | ||
"version": "1.16.5", | ||
"description": "Apply sql-like filters to GeoJSON", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@esri/proj-codes": "^1.0.4", | ||
"@esri/proj-codes": "^2.2.0", | ||
"@turf/bbox-polygon": "^6.0.1", | ||
@@ -39,4 +39,3 @@ "@turf/centroid": "^6.0.0", | ||
"classybrew": "0.0.3", | ||
"esri-proj-codes": "^1.0.3", | ||
"flora-sql-parser": "^0.7.5", | ||
"flora-sql-parser": "^0.8.0", | ||
"highland": "^3.0.0-beta.3", | ||
@@ -43,0 +42,0 @@ "lodash": "^4.17.4", |
Sorry, the diff of this file is not supported yet
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
255535
16
1464
9
+ Added@esri/proj-codes@2.9.0(transitive)
+ Addedflora-errors@0.9.1(transitive)
+ Addedflora-sql-parser@0.8.1(transitive)
- Removedesri-proj-codes@^1.0.3
- Removed@esri/proj-codes@1.0.4(transitive)
- Removedesri-proj-codes@1.0.3(transitive)
- Removedflora-errors@0.8.0(transitive)
- Removedflora-sql-parser@0.7.10(transitive)
Updated@esri/proj-codes@^2.2.0
Updatedflora-sql-parser@^0.8.0