From 0e404f947e5e97e4cac82cc03d7d2208d7534192 Mon Sep 17 00:00:00 2001 From: Clarisse Abalos Date: Sat, 5 Jan 2019 01:39:34 -0500 Subject: [PATCH 1/3] add geometry wildcard and array ref #12 --- SCHEMA.md | 2 +- schema/primitives/feature.js | 2 +- schema/primitives/geometry.js | 2 +- source/classes/regexType/geometry/constants.js | 8 +++++--- test/classes/regexType/constants.js | 3 ++- test/helpers.js | 1 + 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SCHEMA.md b/SCHEMA.md index a3177a9..df7acb6 100644 --- a/SCHEMA.md +++ b/SCHEMA.md @@ -107,7 +107,7 @@ into this... | key | value | description | | ---------------- | :------ | :--------------------------------------------------------------------------------------------- | -| geometry | string | geometry type MapCSS is intended to match | +| geometry | array | geometry type MapCSS is intended to match | | equals | object | object with key/value pair MapCSS is intended to match | | notEqual | string | object with key/value pair MapCSS is not intended to match | | presence | string | tag key MapCSS is intended to match | diff --git a/schema/primitives/feature.js b/schema/primitives/feature.js index 9165b53..43ef33b 100644 --- a/schema/primitives/feature.js +++ b/schema/primitives/feature.js @@ -4,6 +4,6 @@ const Joi = require('joi'); const GEOMETRY = new RegExp(require('../../source/classes/regexType/geometry/constants').GEOMETRY); module.exports = { - geometry: Joi.string().regex(GEOMETRY), + geometry: Joi.array().items(Joi.string().regex(GEOMETRY)), tags: Joi.object() }; diff --git a/schema/primitives/geometry.js b/schema/primitives/geometry.js index 10e00c3..9e0706e 100644 --- a/schema/primitives/geometry.js +++ b/schema/primitives/geometry.js @@ -3,4 +3,4 @@ const Joi = require('joi'); const GEOMETRY_SCHEMA = new RegExp(require('../../source/classes/regexType/geometry/constants').GEOMETRY_SCHEMA); -module.exports = { geometry: Joi.string().regex(GEOMETRY_SCHEMA) }; +module.exports = { geometry: Joi.array().items(Joi.string().regex(GEOMETRY_SCHEMA)) }; diff --git a/source/classes/regexType/geometry/constants.js b/source/classes/regexType/geometry/constants.js index 7981fe3..ffb94a4 100644 --- a/source/classes/regexType/geometry/constants.js +++ b/source/classes/regexType/geometry/constants.js @@ -6,13 +6,15 @@ const _NODE = 'node'; const _WAY = 'way'; const _CLOSEDWAY = ':closed'; const _CLOSEDWAY_FULL = 'closedway'; +const _WILDCARD = '\\*'; exports.NODE = new RegExp(_NODE); exports.WAY = new RegExp(_WAY); exports.CLOSEDWAY = new RegExp(_CLOSEDWAY); exports.CLOSEDWAY_FULL = new RegExp(_CLOSEDWAY_FULL); +exports._WILDCARD = new RegExp(_WILDCARD); -exports.GEOMETRY_GROUPS = `${_NODE}|${_WAY}|${_CLOSEDWAY}`; +exports.GEOMETRY_GROUPS = `${_NODE}|${_WAY}|${_CLOSEDWAY}|${_WILDCARD}`; -exports.GEOMETRY = new RegExp(`^${_NODE}$|^${_WAY}$|^${_CLOSEDWAY}$`, 'i'); -exports.GEOMETRY_SCHEMA = new RegExp(`^${_NODE}$|^${_WAY}$|^${_CLOSEDWAY_FULL}$`, 'i'); \ No newline at end of file +exports.GEOMETRY = new RegExp(`^${_NODE}$|^${_WAY}$|^${_CLOSEDWAY}$|^${_WILDCARD}$`, 'i'); +exports.GEOMETRY_SCHEMA = new RegExp(`^${_NODE}$|^${_WAY}$|^${_CLOSEDWAY_FULL}$|^${_WILDCARD}$`, 'i'); \ No newline at end of file diff --git a/test/classes/regexType/constants.js b/test/classes/regexType/constants.js index e4abc21..f58d95b 100644 --- a/test/classes/regexType/constants.js +++ b/test/classes/regexType/constants.js @@ -11,7 +11,8 @@ const GEOMETRY_GROUPS = require('../../../source/classes/regexType/geometry/cons const NODE = require('../../../source/classes/regexType/geometry/constants').NODE; const WAY = require('../../../source/classes/regexType/geometry/constants').WAY; const CLOSEDWAY = require('../../../source/classes/regexType/geometry/constants').CLOSEDWAY; -const GEOMS = [NODE, WAY, CLOSEDWAY]; +const WILDCARD = require('../../../source/classes/regexType/geometry/constants').WILDCARD; +const GEOMS = [NODE, WAY, CLOSEDWAY, WILDCARD]; const GREATER_THAN = require('../../../source/classes/regexType/selector/constants').GREATER_THAN; const GREATER_THAN_EQUAL = require('../../../source/classes/regexType/selector/constants').GREATER_THAN_EQUAL; diff --git a/test/helpers.js b/test/helpers.js index d94cb4f..e350ac1 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -31,6 +31,7 @@ describe('helpers', () => { expect(helpers.geometryTypeFromSource(':closed')).to.eql('closedway'); expect(helpers.geometryTypeFromSource('node')).to.eql('node'); expect(helpers.geometryTypeFromSource('way')).to.eql('way'); + expect(helpers.geometryTypeFromSource('*')).to.eql('*'); }); }); }); From d5256fa5b16e6adfb3dcdc317821fd9369d08c79 Mon Sep 17 00:00:00 2001 From: Clarisse Abalos Date: Tue, 8 Jan 2019 18:06:11 -0500 Subject: [PATCH 2/3] fix export wildcard, make geometry primitive array, add wildcard in test ref #12 --- source/classes/regexType/geometry/constants.js | 2 +- source/classes/regexType/geometry/index.js | 2 +- testData/test.mapcss | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/classes/regexType/geometry/constants.js b/source/classes/regexType/geometry/constants.js index ffb94a4..2ce93b3 100644 --- a/source/classes/regexType/geometry/constants.js +++ b/source/classes/regexType/geometry/constants.js @@ -12,7 +12,7 @@ exports.NODE = new RegExp(_NODE); exports.WAY = new RegExp(_WAY); exports.CLOSEDWAY = new RegExp(_CLOSEDWAY); exports.CLOSEDWAY_FULL = new RegExp(_CLOSEDWAY_FULL); -exports._WILDCARD = new RegExp(_WILDCARD); +exports.WILDCARD = new RegExp(_WILDCARD); exports.GEOMETRY_GROUPS = `${_NODE}|${_WAY}|${_CLOSEDWAY}|${_WILDCARD}`; diff --git a/source/classes/regexType/geometry/index.js b/source/classes/regexType/geometry/index.js index 1ec4f11..86b518f 100644 --- a/source/classes/regexType/geometry/index.js +++ b/source/classes/regexType/geometry/index.js @@ -14,7 +14,7 @@ class GeometryType extends RegexType { return geometryTypeFromSource(super.getMatches(source)[0]); } getPrimitive(source) { - return { geometry: this.getMatches(source) }; + return { geometry: [this.getMatches(source)] }; } } diff --git a/testData/test.mapcss b/testData/test.mapcss index 2b8bd1e..29df6e6 100644 --- a/testData/test.mapcss +++ b/testData/test.mapcss @@ -30,4 +30,7 @@ way[amenity=school]{ } way[building][height=1] { throwError: "..." +} +*[amenity][!name] { + throwError: "name required on any amenity" } \ No newline at end of file From 75c00cd4dd7ef73a9549aefae889fd0406ce67a4 Mon Sep 17 00:00:00 2001 From: Clarisse Abalos Date: Wed, 9 Jan 2019 15:50:43 -0500 Subject: [PATCH 3/3] update build --- dist/classes/regexType/geometry/constants.js | 2 +- dist/classes/regexType/geometry/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/classes/regexType/geometry/constants.js b/dist/classes/regexType/geometry/constants.js index 2e386a9..35bf141 100644 --- a/dist/classes/regexType/geometry/constants.js +++ b/dist/classes/regexType/geometry/constants.js @@ -1 +1 @@ -/* --- GEOMETRY --- */var _NODE='node',_WAY='way',_CLOSEDWAY=':closed',_CLOSEDWAY_FULL='closedway';exports.NODE=/node/,exports.WAY=/way/,exports.CLOSEDWAY=/:closed/,exports.CLOSEDWAY_FULL=/closedway/,exports.GEOMETRY_GROUPS=_NODE+'|'+_WAY+'|'+_CLOSEDWAY,exports.GEOMETRY=/^node$|^way$|^:closed$/i,exports.GEOMETRY_SCHEMA=/^node$|^way$|^closedway$/i; \ No newline at end of file +/* --- GEOMETRY --- */var _NODE='node',_WAY='way',_CLOSEDWAY=':closed',_CLOSEDWAY_FULL='closedway',_WILDCARD='\\*';exports.NODE=/node/,exports.WAY=/way/,exports.CLOSEDWAY=/:closed/,exports.CLOSEDWAY_FULL=/closedway/,exports.WILDCARD=/\*/,exports.GEOMETRY_GROUPS=_NODE+'|'+_WAY+'|'+_CLOSEDWAY+'|'+_WILDCARD,exports.GEOMETRY=/^node$|^way$|^:closed$|^\*$/i,exports.GEOMETRY_SCHEMA=/^node$|^way$|^closedway$|^\*$/i; \ No newline at end of file diff --git a/dist/classes/regexType/geometry/index.js b/dist/classes/regexType/geometry/index.js index b070930..9260b1d 100644 --- a/dist/classes/regexType/geometry/index.js +++ b/dist/classes/regexType/geometry/index.js @@ -1 +1 @@ -var _createClass=function(){function a(a,b){for(var c,d=0;d