MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _updateDataFlowFeature

Method _updateDataFlowFeature

src/common/mapping/WebMapV2.js:1245–1288  ·  view source on GitHub ↗
(sourceID, newFeature, layerInfo, type)

Source from the content-addressed store, hash-verified

1243 }
1244
1245 _updateDataFlowFeature(sourceID, newFeature, layerInfo, type) {
1246 const { identifyField, maxPointCount, directionField } = layerInfo;
1247 const features = cloneDeep(this.map.getSource(sourceID)._data.features);
1248 let has = false;
1249 features.forEach((item, index) => {
1250 if (item.properties[identifyField] === newFeature.properties[identifyField]) {
1251 has = true;
1252 if (type === 'line') {
1253 const coordinates = item.geometry.coordinates;
1254 coordinates.push(newFeature.geometry.coordinates);
1255 if (maxPointCount && coordinates.length > maxPointCount) {
1256 coordinates.splice(0, coordinates.length - maxPointCount);
1257 }
1258 features[index].geometry.coordinates = coordinates;
1259 } else {
1260 features[index] = newFeature;
1261 }
1262 }
1263 });
1264 if (!has) {
1265 if (type === 'line') {
1266 features.push({
1267 type: 'Feature',
1268 properties: newFeature.properties,
1269 geometry: {
1270 type: 'LineString',
1271 coordinates: [newFeature.geometry.coordinates]
1272 }
1273 });
1274 } else {
1275 features.push(newFeature);
1276 }
1277 }
1278 this.map.getSource(sourceID).setData({ type: 'FeatureCollection', features });
1279 if (type === 'point') {
1280 const type = layerInfo.pointStyle.type;
1281 const iconRotateExpression = this._getDataFlowRotateStyle(features, directionField, identifyField);
1282 if (['SVG_POINT', 'IMAGE_POINT'].includes(type)) {
1283 this.map.setLayoutProperty(sourceID, 'icon-rotate', iconRotateExpression);
1284 } else if (type === 'SYMBOL_POINT') {
1285 this.map.setLayoutProperty(sourceID, 'text-rotate', iconRotateExpression);
1286 }
1287 }
1288 }
1289
1290 _createMigrationLayer(layerInfo, features) {
1291 const { layerID, layerType } = layerInfo;

Callers 1

_addDataflowLayerMethod · 0.95

Calls 6

forEachMethod · 0.80
pushMethod · 0.80
getSourceMethod · 0.45
setDataMethod · 0.45
setLayoutPropertyMethod · 0.45

Tested by

no test coverage detected