Skip to content

Commit

Permalink
Initially Load Misison Syncs
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Mar 7, 2024
1 parent 7ba7701 commit 6fa3206
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
6 changes: 4 additions & 2 deletions api/web/src/components/CloudTAK/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ export default {
mapStore.map.getSource('cots').setData(cotStore.collection())
for (const sub of cotStore.subscriptions.keys()) {
if (overlayStore.subscriptions.has())
console.error(sub);
const overlay = overlayStore.subscriptions.get(sub)
if (!overlay) continue;
mapStore.map.getSource(overlay.id).setData(cotStore.collection(cotStore.subscriptions.get(sub)))
}
if (this.locked.length && cotStore.has(this.locked[this.locked.length - 1])) {
Expand Down
30 changes: 19 additions & 11 deletions api/web/src/stores/cots.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ export const useCOTStore = defineStore('cots', {
/**
* Return CoTs as a FeatureCollection
*/
collection: function() {
return {
type: 'FeatureCollection',
features: Array.from(this.cots.values()).map((cot) => {
cot.properties['icon-opacity'] = moment().subtract(5, 'minutes').isBefore(moment(cot.properties.stale)) ? 1 : 0.5;
return cot;
})
collection: function(store) {
if (!store) {
return {
type: 'FeatureCollection',
features: Array.from(this.cots.values()).map((cot) => {
// TODO if not archived set color opacity
cot.properties['icon-opacity'] = moment().subtract(5, 'minutes').isBefore(moment(cot.properties.stale)) ? 1 : 0.5;
return cot;
})
}
} else {
return {
type: 'FeatureCollection',
features: Array.from(store.values())
}
}
},

Expand Down Expand Up @@ -103,7 +111,7 @@ export const useCOTStore = defineStore('cots', {
/**
* Add a CoT GeoJSON to the store and modify props to meet MapLibre style requirements
*/
add: function(feat, mission=null) {
add: function(feat, mission_guid=null) {
//Vector Tiles only support integer IDs
feat.properties.id = feat.id;

Expand Down Expand Up @@ -177,11 +185,11 @@ export const useCOTStore = defineStore('cots', {
}
}

if (mission) {
let cots = this.subscriptions.get(mission);
if (mission_guid) {
let cots = this.subscriptions.get(mission_guid);
if (!cots) {
cots = new Map();
this.subscriptions.set(mission, cots);
this.subscriptions.set(mission_guid, cots);
}

cots.set(feat.id, feat);
Expand Down
3 changes: 1 addition & 2 deletions api/web/src/stores/overlays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ export const useOverlayStore = defineStore('overlays', {
if (overlay.mode === 'mission') {
// mode_id is GUID for mission type
this.subscriptions.set(overlay.mode_id, overlay);
// @TODO Eventually allow name changes so use GUID
await cotStore.loadMission(overlay.name);
await cotStore.loadMission(overlay.mode_id);
}
}

Expand Down

0 comments on commit 6fa3206

Please sign in to comment.