From 6b2bea3b66ee1f2bd60f2133101b61b74dc42131 Mon Sep 17 00:00:00 2001 From: ingalls Date: Thu, 5 Sep 2024 16:34:28 -0600 Subject: [PATCH] Move style into COT class --- api/web/src/stores/cots.ts | 2 -- api/web/src/stores/cots/cot.ts | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/web/src/stores/cots.ts b/api/web/src/stores/cots.ts index 682e74f60..19165fedc 100644 --- a/api/web/src/stores/cots.ts +++ b/api/web/src/stores/cots.ts @@ -385,8 +385,6 @@ export const useCOTStore = defineStore('cots', { * Add a CoT GeoJSON to the store and modify props to meet MapLibre style requirements */ add: async function(feat: Feature, mission_guid?: string) { - feat = COT.style(feat); - mission_guid = mission_guid || this.subscriptionPending.get(feat.id); if (mission_guid) { diff --git a/api/web/src/stores/cots/cot.ts b/api/web/src/stores/cots/cot.ts index 89af24698..bf842e50c 100644 --- a/api/web/src/stores/cots/cot.ts +++ b/api/web/src/stores/cots/cot.ts @@ -35,17 +35,25 @@ export default class COT implements Feature { geometry: Feature["geometry"]; constructor(feat: Feature) { + feat = COT.style(feat); + this.id = feat.id || crypto.randomUUID(); this.type = feat.type || 'Feature'; this.path = feat.path || '/'; this.properties = feat["properties"] || {}; this.geometry = feat["geometry"]; + + if (!this.properties.archived) { + this.properties.archived = false + } } /** * Update the COT and return a boolean as to whether the COT needs to be re-rendered */ update(feat: Feature): boolean { + feat = COT.style(feat); + let changed = false; for (const prop of RENDERED_PROPERTIES) { if (this.properties[prop] !== feat.properties[prop]) {