Fix device geometry update
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good Details

2022.01
Willem Dantuma 2021-08-12 17:13:40 +02:00
parent eb1157d608
commit 6ff3c0ec96
1 changed files with 6 additions and 5 deletions

View File

@ -50,15 +50,16 @@ export class MapEffects {
private _wktFormat: WKT;
private overrideSelectedItemLayer: boolean = false;
private toPointFeature(updateEvent:commonActions.DeviceUpdateEvent): Feature {
private updateFeatureGeometry(feature:Feature, updateEvent:commonActions.DeviceUpdateEvent): Feature {
let newFeature = feature.clone();
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
f.setId(updateEvent.itemCode);
var centroid = getCenter(f.getGeometry().getExtent());
f.setGeometry(new Point(centroid));
return f;
newFeature.setId(feature.getId());
newFeature.setGeometry(new Point(centroid));
return newFeature;
}
init$ = createEffect(() => this.actions$.pipe(
@ -263,7 +264,7 @@ export class MapEffects {
}
}
if (feature) {
return of(new mapActions.UpdateFeatureSuccess(this.toPointFeature(deviceUpdateEventAction)));
return of(new mapActions.UpdateFeatureSuccess(this.updateFeatureGeometry(feature,deviceUpdateEventAction)));
} else {
return [];
}