Skip to content

Commit

Permalink
Fix CoT filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Oct 17, 2024
1 parent 330394a commit 1f8bb40
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 53 deletions.
3 changes: 2 additions & 1 deletion api/lib/sprites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SpriteSmith = promisify(spritesmith.run);

type SpriteConfig = {
name?: string;
useDataAlt?: boolean;
};

export default async function(icons: Array<Static<typeof IconResponse>>, config: SpriteConfig = {}) {
Expand All @@ -16,7 +17,7 @@ export default async function(icons: Array<Static<typeof IconResponse>>, config:
return new Vinyl({
// @ts-expect-error Deal with indexing issue on icon
path: config.name ? icon[config.name] + '.png' : icon.path.replace(/.*?\//, ''),
contents: Buffer.from(icon.data, 'base64'),
contents: Buffer.from(config.useDataAlt && icon.data_alt ? icon.data_alt : icon.data, 'base64'),
})
})
});
Expand Down
106 changes: 59 additions & 47 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions api/routes/connection-layer-cot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default async function router(schema: Schema, config: Config) {
}

const errors: Array<Static<typeof LayerError>> = [];
const cots = [];
let cots = [];
for (const feat of req.body.features) {
try {
cots.push(CoT.from_geojson(feat))
Expand Down Expand Up @@ -129,16 +129,17 @@ export default async function router(schema: Schema, config: Config) {
existMap.set(String(feat.id), feat);
}


for (const cot of cots) {
cots = cots.filter((cot) => {
const exist = existMap.get(cot.uid());
if (exist && data.mission_diff) {
const b = CoT.from_geojson(exist);
if (!cot.isDiff(b)) continue;
if (!cot.isDiff(b)) return false;
}

cot.addDest({ mission: data.name, path: `layer-${layer.id}`, after: '' });
}

return true;
})
} else {
for (const cot of cots) {
cot.addDest({ mission: data.name });
Expand Down

0 comments on commit 1f8bb40

Please sign in to comment.