Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Akctarus committed Dec 22, 2023
1 parent 5304522 commit 94b7bd2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions front/src/common/IntervalsDataViz/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,14 +662,11 @@ export function getClosestOperationalPoint(
* @returns The entity modified in adquation
*/

// The modification of the linestring modifies the entity real properties only during initialization.
export function entityDoUpdate<T extends EditorEntity>(entity: T, sourceLine: LineString): T {
const newProps: EditorEntity['properties'] = { id: entity.properties.id };
if (entity.properties.length === 0) {
newProps.length = getLineStringDistance(entity.geometry as LineString);
return { ...entity, properties: newProps };
}
if (entity.geometry.type === 'LineString' && !isNil(entity.properties)) {
// The modification of the linestring modifies the entity real properties only during initialization.
const isInitialization = sourceLine.coordinates.length === 0;
if (entity.geometry.type === 'LineString' && !isNil(entity.properties) && isInitialization) {
Object.keys(entity.properties).forEach((name) => {
const value = (entity.properties as { [key: string]: unknown })[name];
// is a LM ?
Expand All @@ -679,6 +676,8 @@ export function entityDoUpdate<T extends EditorEntity>(entity: T, sourceLine: Li
newProps[name] = value;
}
});
newProps.length = getLineStringDistance(entity.geometry as LineString);
return { ...entity, properties: newProps };
}
return entity;
}
Expand Down

0 comments on commit 94b7bd2

Please sign in to comment.