MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / parseFilterCondition

Method parseFilterCondition

src/openlayers/mapping/WebMap.js:3193–3210  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.parseFilterCondition * @description 1、替换查询语句 中的 and / AND / or / OR / = / != * 2、匹配 Name in ('', ''),多条件需用()包裹 * @param {string} filterCondition - 过滤条件 * @return {string} 换成组件能识别的字符串

(filterCondition)

Source from the content-addressed store, hash-verified

3191 * @return {string} 换成组件能识别的字符串
3192 */
3193 parseFilterCondition(filterCondition) {
3194 return filterCondition
3195 .replace(/=/g, '==')
3196 .replace(/AND|and/g, '&&')
3197 .replace(/or|OR/g, '||')
3198 .replace(/<==/g, '<=')
3199 .replace(/>==/g, '>=')
3200 .replace(/\(?[^\(]+?\s*in\s*\([^\)]+?\)\)?/gi, (res) => {
3201 // res格式:(省份 in ('四川', '河南'))
3202 const data = res.match(/([^(]+?)\s*in\s*\(([^)]+?)\)/i);
3203 return data.length === 3
3204 ? `(${data[2]
3205 .split(',')
3206 .map((c) => `${data[1]} == ${c.trim()}`)
3207 .join(' || ')})`
3208 : res;
3209 });
3210 }
3211
3212 /**
3213 * @private

Callers 3

getFiterFeaturesMethod · 0.95
createDataflowLayerMethod · 0.80

Calls 3

matchMethod · 0.80
mapMethod · 0.80
trimMethod · 0.80

Tested by

no test coverage detected