Skip to content

Commit 5c76650

Browse files
authored
Merge pull request #112 from dfpc-coe/min-max-zoom
Per Feature Min/Max Zoom
2 parents 06df7f2 + dc06f19 commit 5c76650

8 files changed

Lines changed: 292 additions & 193 deletions

File tree

lib/parser/from_geojson.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,30 @@ 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) {
119+
if (!cot.event.detail.display || !cot.event.detail.display._attributes) {
120+
cot.event.detail.display = { _attributes: {} };
121+
}
122+
123+
if (feature.properties.minzoom !== undefined) {
124+
cot.event.detail.display._attributes.minzoom = feature.properties.minzoom;
125+
}
126+
127+
if (feature.properties.maxzoom !== undefined) {
128+
cot.event.detail.display._attributes.maxzoom = feature.properties.maxzoom;
129+
}
130+
}
131+
118132
if (feature.properties.creator) {
119133
cot.event.detail.creator = { _attributes: { ...feature.properties.creator } };
120134
}
121135

122136
if (feature.properties.range !== undefined) {
123-
cot.event.detail.range = { _attributes: { value: feature.properties.range } }
137+
cot.event.detail.range = { _attributes: { value: feature.properties.range } }
124138
}
125139

126140
if (feature.properties.bearing !== undefined) {
127-
cot.event.detail.bearing = { _attributes: { value: feature.properties.bearing } }
141+
cot.event.detail.bearing = { _attributes: { value: feature.properties.bearing } }
128142
}
129143

130144
if (feature.properties.geofence) {

lib/parser/to_geojson.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ export async function to_geojson(cot: CoT): Promise<Static<typeof Feature>> {
8989
feat.properties.bearing = raw.event.detail.bearing._attributes.value;
9090
}
9191

92+
if (raw.event.detail.display?._attributes?.minzoom !== undefined) {
93+
feat.properties.minzoom = raw.event.detail.display._attributes.minzoom;
94+
}
95+
96+
if (raw.event.detail.display?._attributes?.maxzoom !== undefined) {
97+
feat.properties.maxzoom = raw.event.detail.display._attributes.maxzoom;
98+
}
99+
92100
if (raw.event.detail.labels_on && raw.event.detail.labels_on._attributes && raw.event.detail.labels_on._attributes.value !== undefined) {
93101
feat.properties.labels = raw.event.detail.labels_on._attributes.value;
94102
}

lib/types/feature.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export const Properties = Type.Object({
6868
start: Type.String(),
6969
stale: Type.String(),
7070
center: Position,
71+
minzoom: Type.Optional(Type.Number()),
72+
maxzoom: Type.Optional(Type.Number()),
7173
range: Type.Optional(Type.Number()),
7274
bearing: Type.Optional(Type.Number()),
7375
creator: Type.Optional(CreatorAttributes),

lib/types/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,13 @@ export const Inclination = Type.Object({
603603
_attributes: InclinationAttributes,
604604
});
605605

606+
export const Display = Type.Object({
607+
_attributes: Type.Object({
608+
minzoom: Type.Optional(Type.Number()),
609+
maxzoom: Type.Optional(Type.Number()),
610+
})
611+
});
612+
606613
export const NorthRefAttributes = Type.Object({
607614
value: Type.Number()
608615
});
@@ -678,6 +685,10 @@ export const Detail = Type.Object({
678685
link: Type.Optional(Type.Union([Link, Type.Array(Link)])),
679686
link_attr: Type.Optional(LinkAttr),
680687

688+
// Custom Attributes related to CloudTAK Display
689+
display: Type.Optional(Display),
690+
// ---------------------------------------------
691+
681692
usericon: Type.Optional(UserIcon),
682693
track: Type.Optional(Track),
683694
sensor: Type.Optional(Sensor),

package-lock.json

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

test/fixtures/maxzoom.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+
"maxzoom": 5,
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+
}

test/fixtures/minmaxzoom.geojson

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
"maxzoom": 14,
13+
"minzoom": 5,
14+
"stale": "2023-08-04T15:17:43.649Z",
15+
"metadata": {}
16+
},
17+
"geometry": {
18+
"type": "Point",
19+
"coordinates": [1.1, 2.2, 0]
20+
}
21+
}

test/fixtures/minzoom.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+
"minzoom": 5,
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)