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

Function getHighestMatchAdministration

src/openlayers/core/Util.js:379–399  ·  view source on GitHub ↗

* @function Util.getHighestMatchAdministration * @param {string} featureName 初始匹配的要素数组 * @param {string} fieldName 要匹配的地名 * @returns {boolean} 是否匹配 * @private

(features, fieldName)

Source from the content-addressed store, hash-verified

377 * @private
378 */
379 getHighestMatchAdministration(features, fieldName) {
380 let filterFeatures = features.filter((item) => {
381 return isMatchAdministrativeName(item.properties.Name, fieldName);
382 });
383
384 let maxMatchPercent = 0,
385 maxMatchFeature = null;
386 filterFeatures.forEach((feature) => {
387 let count = 0;
388 Array.from(new Set(feature.properties.Name.split(''))).forEach((char) => {
389 if (fieldName.includes(char)) {
390 count++;
391 }
392 });
393 if (count > maxMatchPercent) {
394 maxMatchPercent = count;
395 maxMatchFeature = feature;
396 }
397 });
398 return maxMatchFeature;
399 },
400
401 /**
402 * @function Util.setMask

Callers

nothing calls this directly

Calls 3

filterMethod · 0.80
forEachMethod · 0.80

Tested by

no test coverage detected