From b8135ecf797e17b7f9ba636c5f4fcf6d720acd62 Mon Sep 17 00:00:00 2001 From: haoxusci Date: Thu, 15 Jul 2021 16:51:45 +0200 Subject: [PATCH 1/2] identify clevage segmentation --- src/components/layers/VectorLayer.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/layers/VectorLayer.vue b/src/components/layers/VectorLayer.vue index 4677325..ab1cfe9 100644 --- a/src/components/layers/VectorLayer.vue +++ b/src/components/layers/VectorLayer.vue @@ -274,8 +274,14 @@ function polygonCut(polygon, line, properties) { } } + properties['id'] = new Date().getTime() cutPolyGeoms.forEach(function(geometry) { - cutFeatures.push(turf.polygon(geometry, properties)); + if (Object.keys(properties).includes('id')){ + properties['id'] = properties['id'] + 1 + console.log(JSON.stringify(properties['id'])) + } + const propertiesCut= JSON.parse(JSON.stringify(properties)); + cutFeatures.push(turf.polygon(geometry, propertiesCut)); }); } From 23dad040299b98cecd4118998ec3aabf53a6e988 Mon Sep 17 00:00:00 2001 From: haoxusci Date: Fri, 16 Jul 2021 11:41:05 +0200 Subject: [PATCH 2/2] randId --- src/components/layers/VectorLayer.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/layers/VectorLayer.vue b/src/components/layers/VectorLayer.vue index ab1cfe9..4503312 100644 --- a/src/components/layers/VectorLayer.vue +++ b/src/components/layers/VectorLayer.vue @@ -188,6 +188,7 @@ import Polygon from "ol/geom/Polygon"; import { intersects } from "ol/extent"; import { createRegularPolygon, createBox } from "ol/interaction/Draw"; import * as turf from "@turf/turf"; +import { randId } from '../../utils'; function getRandomColor() { var letters = "0123456789ABCDEF"; @@ -274,13 +275,11 @@ function polygonCut(polygon, line, properties) { } } - properties['id'] = new Date().getTime() cutPolyGeoms.forEach(function(geometry) { - if (Object.keys(properties).includes('id')){ - properties['id'] = properties['id'] + 1 - console.log(JSON.stringify(properties['id'])) - } const propertiesCut= JSON.parse(JSON.stringify(properties)); + if (Object.keys(propertiesCut).includes('id')){ + propertiesCut['id'] = randId() + } cutFeatures.push(turf.polygon(geometry, propertiesCut)); }); }