Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winnow

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winnow - npm Package Compare versions

Comparing version 1.8.8 to 1.9.0

.eslintrc.js

6

CHANGELOG.md

@@ -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

5

dist/index.js

@@ -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) {

35

dist/options.js

@@ -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)

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