Comparing version 1.8.8 to 1.9.0
@@ -5,2 +5,7 @@ # Change Log | ||
## [1.9.0] - 05-24-2017 | ||
### Added | ||
* Support outSR for polygons and lines | ||
* Support selected geometry precision | ||
## [1.8.8] - 04-26-2017 | ||
@@ -143,2 +148,3 @@ ### Fixed | ||
[1.9.0]: https://github.com/featureserver/winnow/compare/v1.9.0...v1.8.8 | ||
[1.8.8]: https://github.com/featureserver/winnow/compare/v1.8.7...v1.8.8 | ||
@@ -145,0 +151,0 @@ [1.8.7]: https://github.com/featureserver/winnow/compare/v1.8.7...v1.8.6 |
@@ -36,3 +36,6 @@ 'use strict' | ||
var query = sql.compile(statement) | ||
var params = [null, options.geometry] | ||
var params = [null] | ||
if (options.projection) { params.push(options.projection) } | ||
if (options.geometryPrecision) { params.push(options.geometryPrecision) } | ||
if (options.geometry) { params.push(options.geometry) } | ||
@@ -39,0 +42,0 @@ return function (input) { |
@@ -1,5 +0,6 @@ | ||
var proj4 = require('proj4') | ||
var convertFromEsri = require('./geometry/convertFromEsri') | ||
var _ = require('lodash') | ||
var convertFromEsri = require('./geometry/convert-from-esri') | ||
var transformArray = require('./geometry/transform-array') | ||
var transformEnvelope = require('./geometry/transform-envelope') | ||
var projectCoordinates = require('./geometry/project-coordinates') | ||
var esriPredicates = { | ||
@@ -12,3 +13,3 @@ esriSpatialRelContains: 'ST_Contains', | ||
function prepare (options) { | ||
return { | ||
return _.merge({}, options, { | ||
where: normalizeWhere(options), | ||
@@ -23,8 +24,4 @@ geometry: normalizeGeometry(options), | ||
offset: normalizeOffset(options), | ||
projection: normalizeProjection(options), | ||
esri: options.esri, | ||
toEsri: options.toEsri, | ||
esriFields: options.esriFields, | ||
collection: options.collection | ||
} | ||
projection: normalizeProjection(options) | ||
}) | ||
} | ||
@@ -104,3 +101,3 @@ | ||
var inSR = normalizeInSR(options) | ||
if (inSR) { geometry.coordinates = projectCoordinates(inSR, geometry.coordinates) } | ||
if (inSR) { geometry.coordinates = projectCoordinates(geometry.coordinates, { inSR: inSR, outSR: 'EPSG:4326' }) } | ||
return geometry | ||
@@ -110,11 +107,16 @@ } | ||
function normalizeInSR (options) { | ||
var SR | ||
if (options.inSR) { | ||
return options.inSR | ||
SR = options.inSR | ||
} else if (options.geometry.spatialReference) { | ||
if (/WGS_1984_Web_Mercator_Auxiliary_Sphere/.test(options.geometry.spatialReference.wkt)) { | ||
return 102100 | ||
SR = 3857 | ||
} else { | ||
return options.geometry.spatialReference.latestWkid || options.geometry.spatialReference.wkid | ||
SR = options.geometry.spatialReference.latestWkid || options.geometry.spatialReference.wkid | ||
} | ||
} | ||
if (SR === 102100) { return "EPSG:3857" } | ||
else if (SR) { return ("EPSG:" + SR) } | ||
else { return 'EPSG:4326' } | ||
} | ||
@@ -143,9 +145,2 @@ | ||
function projectCoordinates (inSR, coordinates) { | ||
if (inSR === 102100) { inSR = 3857 } | ||
if (Array.isArray(coordinates[0]) && Array.isArray(coordinates[0][0])) { return coordinates.map(function (a) { return projectCoordinates(inSR, a) }) } | ||
else if (Array.isArray(coordinates[0]) && typeof coordinates[0][0] === 'number') { return coordinates.map(function (a) { return projectCoordinates(inSR, a) }) } | ||
else { return proj4(("EPSG:" + inSR), 'EPSG:4326', coordinates) } | ||
} | ||
module.exports = { prepare: prepare } |
@@ -27,2 +27,3 @@ 'use strict' | ||
if (options.projection) { params.push(options.projection) } | ||
if (options.geometryPrecision) { params.push(options.geometryPrecision) } | ||
// From stage | ||
@@ -35,2 +36,2 @@ params.push(Array.isArray(features) ? features : [features]) | ||
module.exports = {create: create, params: params} | ||
module.exports = { create: create, params: params } |
@@ -1,16 +0,16 @@ | ||
module.exports = function (fields, options) { | ||
options = options || {} | ||
if (typeof fields !== 'string') { fields = fields.join(',') } | ||
else { fields = fields.replace(/,\s+/g, ',') } | ||
var propType | ||
var geomType | ||
if (options.toEsri) { | ||
propType = 'attributes' | ||
geomType = options.projection ? 'esriGeom(project(geometry, ?)) as geometry' : 'esriGeom(geometry) as geometry' | ||
function createClause (options) { | ||
if ( options === void 0 ) options = {}; | ||
var propType = options.toEsri ? 'attributes' : 'properties' | ||
if (options.fields) { | ||
var fields | ||
if (typeof options.fields !== 'string') { fields = options.fields.join(',') } | ||
else { fields = options.fields.replace(/,\s+/g, ',') } | ||
return ("type, pick(properties, \"" + fields + "\") as " + propType) | ||
} else { | ||
propType = 'properties' | ||
geomType = options.projection ? 'project(geometry, ?) as geometry' : 'geometry' | ||
return ("type, properties as " + propType) | ||
} | ||
} | ||
return ("SELECT type, pick(properties, \"" + fields + "\") as " + propType + ", " + geomType + " FROM ?") | ||
} | ||
module.exports = { createClause: createClause } |
@@ -1,12 +0,13 @@ | ||
var fields = require('./fields') | ||
var aggregates = require('./aggregates') | ||
var toEsri = require('./toEsri') | ||
var createGeometryClause = require('./geometry').createClause | ||
var createFieldsClause = require('./fields').createClause | ||
function createClause (options) { | ||
if (options.aggregates) { return aggregates(options.aggregates, options.groupBy, options.esri) } | ||
else if (options.fields) { return fields(options.fields, options) } | ||
else if (options.toEsri) { return toEsri(options.projection) } | ||
else { return options.projection ? 'SELECT properties, project(geometry, ?) as geometry FROM ?' : 'SELECT * FROM ?' } | ||
var geometryClause = createGeometryClause(options) | ||
var fieldsClause = createFieldsClause(options) | ||
return ("SELECT " + fieldsClause + ", " + geometryClause + " FROM ?") | ||
} | ||
module.exports = { createClause: createClause } |
var Terraformer = require('terraformer') | ||
var convertToEsri = require('./geometry/convertToEsri') | ||
var convertToEsri = require('./geometry/convert-to-esri') | ||
var sql = require('alasql') | ||
@@ -7,3 +7,4 @@ var geohash = require('ngeohash') | ||
var _ = require('lodash') | ||
var proj4 = require('proj4') | ||
var projectCoordinates = require('./geometry/project-coordinates') | ||
var reducePrecision = require('./geometry/reduce-precision') | ||
@@ -54,11 +55,17 @@ sql.MAXSQLCACHESIZE = 0 | ||
sql.fn.project = function (geometry, projection) { | ||
if (geometry && geometry.coordinates) { | ||
var coordinates = proj4(projection).forward(geometry.coordinates) | ||
return { | ||
type: geometry.type, | ||
coordinates: coordinates | ||
} | ||
if (!(geometry && geometry.coordinates) || !projection) { return geometry } | ||
return { | ||
type: geometry.type, | ||
coordinates: projectCoordinates(geometry.coordinates, { outSR: projection }) | ||
} | ||
} | ||
sql.fn.reducePrecision = function (geometry, precision) { | ||
if (!(geometry && geometry.coordinates)) { return geometry } | ||
return { | ||
type: geometry.type, | ||
coordinates: reducePrecision(geometry.coordinates, precision) | ||
} | ||
} | ||
sql.aggr.hash = function (value, obj, acc) { | ||
@@ -65,0 +72,0 @@ obj = obj || {} |
{ | ||
"name": "winnow", | ||
"version": "1.8.8", | ||
"version": "1.9.0", | ||
"description": "Apply sql-like filters to GeoJSON", | ||
@@ -35,3 +35,3 @@ "main": "dist/index.js", | ||
"@turf/centroid": "^4.1.0", | ||
"alasql": "^0.3.6", | ||
"alasql": "^0.4.0", | ||
"highland": "^3.0.0-beta.3", | ||
@@ -38,0 +38,0 @@ "lodash": "^4.17.4", |
@@ -24,2 +24,3 @@ # Project Goal | ||
projection: Number || String // An EPSG code, an OGC WKT or an ESRI WKT used to convert geometry | ||
geometryPrecision: Number // number of digits to appear after decimal point for geometry | ||
} | ||
@@ -26,0 +27,0 @@ winnow.query(features, options) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
28
168
1
1
53679
902
+ Addedadler-32@1.2.0(transitive)
+ Addedalasql@0.4.12(transitive)
+ Addedcfb@1.0.8(transitive)
+ Addedcodepage@1.14.0(transitive)
+ Addedcommander@2.14.12.15.1(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addedfrac@1.1.2(transitive)
+ Addedprintj@1.1.2(transitive)
+ Addedssf@0.10.3(transitive)
+ Addedxlsx@0.13.5(transitive)
- Removedadler-32@1.0.0(transitive)
- Removedalasql@0.3.10(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcfb@0.11.1(transitive)
- Removedcodepage@1.8.1(transitive)
- Removedcolors@0.6.2(transitive)
- Removedcommander@2.9.0(transitive)
- Removedconcat-stream@2.0.0(transitive)
- Removedcrc-32@1.0.2(transitive)
- Removedfrac@1.0.6(transitive)
- Removedgraceful-readlink@1.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedprintj@1.3.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedssf@0.9.4(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvoc@1.2.0(transitive)
- Removedxlsx@0.9.13(transitive)
Updatedalasql@^0.4.0