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

Method createPointsData

src/openlayers/mapping/WebMap.js:4776–4812  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.createPointsData * @param {Array} lineData 线数据 * @param {Object} layerInfo 图层信息 * @param {Array} properties 属性 * @returns {Array} 点数据

(lineData, layerInfo, properties)

Source from the content-addressed store, hash-verified

4774 * @returns {Array} 点数据
4775 */
4776 createPointsData(lineData, layerInfo, properties) {
4777 let data = [],
4778 labelSetting = layerInfo.labelSetting;
4779 // 标签隐藏则直接返回
4780 if (!labelSetting.show || !lineData.length) {
4781 return data;
4782 }
4783 let fromData = [],
4784 toData = [];
4785 lineData.forEach((item, idx) => {
4786 let coords = item.coords,
4787 fromCoord = coords[0],
4788 toCoord = coords[1],
4789 fromProperty = properties[idx][labelSetting.from],
4790 toProperty = properties[idx][labelSetting.to];
4791 // 起始字段去重
4792 let f = fromData.find((d) => {
4793 return d.value[0] === fromCoord[0] && d.value[1] === fromCoord[1];
4794 });
4795 !f &&
4796 fromData.push({
4797 name: fromProperty,
4798 value: fromCoord
4799 });
4800 // 终点字段去重
4801 let t = toData.find((d) => {
4802 return d.value[0] === toCoord[0] && d.value[1] === toCoord[1];
4803 });
4804 !t &&
4805 toData.push({
4806 name: toProperty,
4807 value: toCoord
4808 });
4809 });
4810 data = fromData.concat(toData);
4811 return data;
4812 }
4813
4814 /**
4815 * @private

Callers 1

createMigrationLayerMethod · 0.95

Calls 3

forEachMethod · 0.80
pushMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected