Skip to content

Commit 1bb237e

Browse files
authored
Merge pull request #113 from dfpc-coe/rotate
Rotate
2 parents 89df135 + c18905b commit 1bb237e

7 files changed

Lines changed: 316 additions & 268 deletions

File tree

lib/parser/from_geojson.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ export async function from_geojson(
115115
cot.event.detail.takv = { _attributes: { ...feature.properties.takv } };
116116
}
117117

118-
if (feature.properties.minzoom !== undefined || feature.properties.maxzoom !== undefined) {
118+
if (
119+
feature.properties.minzoom !== undefined
120+
|| feature.properties.maxzoom !== undefined
121+
|| feature.properties.rotate !== undefined
122+
) {
119123
if (!cot.event.detail.display || !cot.event.detail.display._attributes) {
120124
cot.event.detail.display = { _attributes: {} };
121125
}
@@ -127,6 +131,10 @@ export async function from_geojson(
127131
if (feature.properties.maxzoom !== undefined) {
128132
cot.event.detail.display._attributes.maxzoom = feature.properties.maxzoom;
129133
}
134+
135+
if (feature.properties.rotate !== undefined) {
136+
cot.event.detail.display._attributes.rotate = feature.properties.rotate;
137+
}
130138
}
131139

132140
if (feature.properties.creator) {

lib/parser/to_geojson.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ export async function to_geojson(cot: CoT): Promise<Static<typeof Feature>> {
9393
feat.properties.minzoom = raw.event.detail.display._attributes.minzoom;
9494
}
9595

96+
if (raw.event.detail.display?._attributes?.rotate !== undefined) {
97+
feat.properties.rotate = raw.event.detail.display._attributes.rotate;
98+
}
99+
96100
if (raw.event.detail.display?._attributes?.maxzoom !== undefined) {
97101
feat.properties.maxzoom = raw.event.detail.display._attributes.maxzoom;
98102
}

lib/types/feature.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const Properties = Type.Object({
7070
center: Position,
7171
minzoom: Type.Optional(Type.Number()),
7272
maxzoom: Type.Optional(Type.Number()),
73+
rotate: Type.Optional(Type.Boolean()),
7374
range: Type.Optional(Type.Number()),
7475
bearing: Type.Optional(Type.Number()),
7576
creator: Type.Optional(CreatorAttributes),

lib/types/types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,15 @@ export const Inclination = Type.Object({
605605

606606
export const Display = Type.Object({
607607
_attributes: Type.Object({
608-
minzoom: Type.Optional(Type.Number()),
609-
maxzoom: Type.Optional(Type.Number()),
608+
minzoom: Type.Optional(Type.Number({
609+
description: 'The minimum zoom level at which to display the feature'
610+
})),
611+
maxzoom: Type.Optional(Type.Number({
612+
description: 'The maximum zoom level at which to display the feature'
613+
})),
614+
rotate: Type.Optional(Type.Boolean({
615+
description: 'Whether to rotate the icon based on heading'
616+
})),
610617
})
611618
});
612619

package-lock.json

Lines changed: 271 additions & 264 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
"@turf/point-on-feature": "^7.0.0",
3737
"@turf/sector": "^7.1.0",
3838
"@turf/truncate": "^7.0.0",
39-
"@types/archiver": "^6.0.2",
39+
"@types/archiver": "^7.0.0",
4040
"@types/geojson": "^7946.0.14",
4141
"ajv": "^8.12.0",
4242
"archiver": "^7.0.1",
4343
"color": "^5.0.0",
4444
"geomagnetism": "^0.2.0",
4545
"json-diff-ts": "^4.0.1",
46+
"mil-std-2525": "^0.2.8",
4647
"milsymbol": "^3.0.2",
4748
"node-stream-zip": "^1.15.0",
4849
"protobufjs": "^7.3.0",

test/fixtures/rotate.geojson

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"id": "123",
3+
"type": "Feature",
4+
"path": "/",
5+
"properties": {
6+
"type": "a-f-G",
7+
"how": "m-g",
8+
"callsign": "BasicTest",
9+
"center": [ 1.1, 2.2, 0 ],
10+
"time": "2023-08-04T15:17:43.649Z",
11+
"start": "2023-08-04T15:17:43.649Z",
12+
"rotate": true,
13+
"stale": "2023-08-04T15:17:43.649Z",
14+
"metadata": {}
15+
},
16+
"geometry": {
17+
"type": "Point",
18+
"coordinates": [1.1, 2.2, 0]
19+
}
20+
}

0 commit comments

Comments
 (0)