Skip to content

Commit 09706a7

Browse files
committed
final linting and adding selection
1 parent 222def1 commit 09706a7

24 files changed

+312
-255
lines changed

client/src/MapStore.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ export default class MapStore {
185185

186186
public static vectorFeatureTableGraphVisible = ref(false);
187187

188-
public static vectorFeatureTableData: Ref<{ layerId: number, vectorFeatureId: number, defaultGraphs?: string[] } | null> = ref(null);
188+
public static vectorFeatureTableData:
189+
Ref<{ layerId: number, vectorFeatureId: number, defaultGraphs?: string[] } | null> = ref(null);
189190

190191
public static setVectorFeatureTableData = (layerId: number, vectorFeatureId: number, defaultGraphs?: string[]) => {
191192
if (MapStore.mapLayerFeatureGraphsVisible.value) {
@@ -414,7 +415,8 @@ export default class MapStore {
414415
globalMax = Math.max(globalMax, max);
415416
}
416417
});
417-
if ((MapStore.mapLayerFeatureGraphsVisible.value && MapStore.mapLayerFeatureGraphs.value.length) || MapStore.vectorFeatureTableGraphVisible.value) {
418+
if ((MapStore.mapLayerFeatureGraphsVisible.value
419+
&& MapStore.mapLayerFeatureGraphs.value.length) || MapStore.vectorFeatureTableGraphVisible.value) {
418420
globalMin = Math.min(globalMin, MapStore.graphChartsMinMax.value.min);
419421
globalMax = Math.max(globalMax, MapStore.graphChartsMinMax.value.max);
420422
stepSize = Math.min(stepSize, MapStore.graphChartsMinMax.value.stepSize);

client/src/api/UVDATApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {
1010
Dataset,
1111
DerivedRegion,
1212
DisplayConfiguration,
13+
FMVLayer,
14+
FMVLayerData,
1315
FeatureGraphData,
1416
FeatureGraphs,
1517
FeatureGraphsRequest,
1618
FileItem,
17-
FMVLayer,
18-
FMVLayerData,
1919
LayerCollection,
2020
LayerCollectionLayer,
2121
LayerRepresentation,

client/src/components/DataSelection/UploadFile.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export default defineComponent({
1313
const uploadProgress = ref<number>(0);
1414
const uploadFile = ref<File | null>(null);
1515
const uploadError = ref<unknown>();
16-
const acceptTypes = ref('.geojson, .json, .tif, .tiff, .zip, .gpkg, .nc');
16+
const acceptTypes = ref(
17+
'.geojson, .json, .tif, .tiff, .zip, .gpkg, .nc, .mpg, .mp4, .avi, .mov, .mkv, .webm, .jpg, .jpeg, .png, .gif',
18+
);
1719
1820
const fileInput = ref<HTMLInputElement | null>(null);
1921

client/src/components/Map.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { setInternalMap } from '../map/mapLayers';
1414
import TVA_GEOJSON_RAW from '../assets/tva.geojson?raw';
1515
import vectorMapStyles from '../assets/basic-map-styles.json';
1616
import oauthClient from '../plugins/Oauth';
17+
import { updateFMVFlightPathSelected } from '../map/mapFMVLayer';
1718
1819
const TVA_GEOJSON = JSON.parse(TVA_GEOJSON_RAW) as GeoJSON.GeoJSON;
1920
const OSM_VECTOR_ID = 'osm-vector';
@@ -231,6 +232,7 @@ export default defineComponent({
231232
() => {
232233
if (map.value) {
233234
updateSelected(map.value);
235+
updateFMVFlightPathSelected(map.value);
234236
}
235237
},
236238
{ deep: true },

client/src/map/fmvStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
/* eslint-disable no-underscore-dangle */
23
import { Ref, reactive, toRefs } from 'vue';
34
import { VideoSource } from 'maplibre-gl';

client/src/map/mapColors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,4 @@ const calculateColors = (map: maplibregl.Map, layer: VectorMapLayer) => {
228228
}
229229
};
230230

231-
export { calculateColors, colorGenerator };
231+
export { calculateColors, colorGenerator, chainSelected };

client/src/map/mapFMVLayer.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import MapStore from '../MapStore';
1111
import { getLayerDefaultFilter } from './mapFilters';
1212
import { subLayerMapping } from './mapHeatmap';
1313
import { FMVStore, getFMVStore } from './fmvStore';
14+
import { chainSelected } from './mapColors';
1415

1516
const addedLayers: Ref<FMVLayer[]> = ref([]);
1617
const defaultAnnotationColor = 'black';
@@ -93,9 +94,14 @@ const getCircleRadius = () => {
9394
};
9495

9596
// As selectedIds change we modify how they are drawn
96-
const updateSelected = (map: maplibregl.Map) => {
97+
// TODO: UPDATE SELECTED ID COLORS
98+
const updateFMVFlightPathSelected = (map: maplibregl.Map) => {
9799
MapStore.selectedFMVMapLayers.value.forEach((layer) => {
98-
console.log('need to implement selection coloring toggling');
100+
const layerName = `FMVLayer_${layer.id}_circle`;
101+
const colorFilter = chainSelected([], '#00FFFF', 'gray');
102+
if (internalMap.value) {
103+
internalMap.value.setPaintProperty(layerName, 'circle-color', colorFilter);
104+
}
99105
});
100106
};
101107

@@ -365,7 +371,7 @@ type Bounds = [LatLon, LatLon, LatLon, LatLon];
365371

366372
function boundsToBBoxWithMultiplier(
367373
bounds: [[number, number], [number, number], [number, number], [number, number]],
368-
sizeMultiplier: number = 1
374+
sizeMultiplier: number = 1,
369375
): [number, number, number, number] {
370376
// Extract all lats and lons
371377
const lons = bounds.map(([lon, _]) => lon);
@@ -379,14 +385,14 @@ function boundsToBBoxWithMultiplier(
379385
const centerLon = (minLon + maxLon) / 2;
380386
const centerLat = (minLat + maxLat) / 2;
381387

382-
const halfWidth = (maxLon - minLon) / 2 * sizeMultiplier;
383-
const halfHeight = (maxLat - minLat) / 2 * sizeMultiplier;
388+
const halfWidth = ((maxLon - minLon) / 2) * sizeMultiplier;
389+
const halfHeight = ((maxLat - minLat) / 2) * sizeMultiplier;
384390

385391
return [
386392
centerLon - halfWidth, // minLon
387393
centerLat - halfHeight, // minLat
388394
centerLon + halfWidth, // maxLon
389-
centerLat + halfHeight // maxLat
395+
centerLat + halfHeight, // maxLat
390396
];
391397
}
392398

@@ -463,7 +469,7 @@ export {
463469
toggleVisibility,
464470
toggleLayerTypeVisibility,
465471
setLayerProperty,
466-
updateSelected,
472+
updateFMVFlightPathSelected,
467473
updateFMVLayer,
468474
updateFrameFilter,
469475
centerAndZoom,

client/src/map/mouseEvents.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,24 @@ const setPopupEvents = (localMap: Map) => {
256256
click: clickFunc,
257257
});
258258
}
259+
for (let i = 0; i < MapStore.selectedFMVMapLayers.value.length; i += 1) {
260+
const layer = MapStore.selectedFMVMapLayers.value[i];
261+
const { id } = layer;
262+
const clickFunc = singleClick;
263+
const FMVAnnotationType = ['circle'];
264+
// Other layers select and hover is used based on config
265+
FMVAnnotationType.forEach((annotationType) => {
266+
localMap.on('click', `FMVLayer_${id}_${annotationType}`, clickFunc);
267+
});
268+
localMap.off('click', clickOutside);
269+
localMap.on('click', clickOutside);
270+
loadedFunctions.push({
271+
id,
272+
mouseenter,
273+
mouseleave,
274+
click: clickFunc,
275+
});
276+
}
259277
}
260278
};
261279

scripts/fmv/kwiver-klv.py

Lines changed: 25 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ def main(video, output_dir):
7878

7979
click.secho(f'JSON output written to {output_json}', fg='green')
8080

81-
create_geojson_and_bbox(frames, geojson_out, bbox_out, bbox_geojson_out)
81+
geojson_data = create_geojson_and_bbox(frames)
82+
with open(geojson_out, 'w') as f:
83+
json.dump(geojson_data, f, indent=2)
84+
click.secho(f'GeoJSON data created with {len(geojson_data["features"])} features.', fg='green')
8285
click.secho(f'GeoJSON written to {geojson_out}', fg='cyan')
83-
click.secho(f'Bounding box mapping written to {bbox_out}', fg='cyan')
8486

8587

86-
def create_geojson_and_bbox(frames, geojson_out, bbox_out, bbox_geojson_out):
88+
def create_geojson_and_bbox(
89+
frames,
90+
):
8791
geod = pyproj.Geod(ellps='WGS84')
8892
features = []
8993
polygons = []
@@ -120,14 +124,15 @@ def create_geojson_and_bbox(frames, geojson_out, bbox_out, bbox_geojson_out):
120124

121125
# Point feature at sensor location
122126
point = Point(sensor_lon, sensor_lat)
127+
properties = {"fmvType": "flight_path"}
128+
properties["frameId"] = int(frame_id)
129+
for key, value in frame.items():
130+
properties[key] = value
131+
123132
feature = {
124133
"type": "Feature",
125134
"geometry": mapping(point),
126-
"properties": {
127-
"Frame ID": frame_id,
128-
"Platform Ground Speed": frame.get("Platform Ground Speed (m/s)"),
129-
"Platform Vertical Speed": frame.get("Platform Vertical Speed (m/s)")
130-
}
135+
"properties": properties,
131136
}
132137
features.append(feature)
133138

@@ -138,58 +143,29 @@ def create_geojson_and_bbox(frames, geojson_out, bbox_out, bbox_geojson_out):
138143
# Add unioned polygon
139144
if polygons:
140145
merged = unary_union(polygons)
141-
features.append({
142-
"type": "Feature",
143-
"geometry": mapping(merged),
144-
"properties": {
145-
"type": "Unioned Bounding Box"
146+
features.append(
147+
{
148+
"type": "Feature",
149+
"geometry": mapping(merged),
150+
"properties": {"fmvType": "ground_union"},
146151
}
147-
})
148-
149-
# Save GeoJSON
150-
geojson = {
151-
"type": "FeatureCollection",
152-
"features": features
153-
}
154-
155-
with open(geojson_out, 'w') as f:
156-
json.dump(geojson, f, indent=2)
157-
158-
# Save bbox mapping
159-
with open(bbox_out, 'w') as f:
160-
json.dump(frame_to_bbox, f, indent=2)
161-
162-
def get_gradient_color(idx, total):
163-
r = int(255 * (idx / (total - 1)))
164-
b = int(255 * (1 - idx / (total - 1)))
165-
return f"#{r:02x}00{b:02x}"
152+
)
166153

167154
# Individual frame bbox polygons with styling
168-
bbox_features = []
169155
for idx, (frame_id, poly) in enumerate(frame_polygons):
170-
color = get_gradient_color(idx, total)
171156
feature = {
172157
"type": "Feature",
173158
"geometry": mapping(poly),
174159
"properties": {
175-
"frame_id": frame_id,
176-
"type": "Unioned Bounding Box",
177-
"stroke": color,
178-
"stroke-width": 2,
179-
"stroke-opacity": 1,
180-
"fill": "#ff0000",
181-
"fill-opacity": 0.5
182-
}
160+
"frameId": int(frame_id),
161+
"fmvType": "ground_frame",
162+
},
183163
}
184-
bbox_features.append(feature)
164+
features.append(feature)
185165

186-
bbox_geojson = {
187-
"type": "FeatureCollection",
188-
"features": bbox_features
189-
}
166+
geojson = {"type": "FeatureCollection", "features": features}
190167

191-
with open(bbox_geojson_out, 'w') as f:
192-
json.dump(bbox_geojson, f, indent=2)
168+
return geojson
193169

194170
if __name__ == '__main__':
195171
main()

uvdat/core/admin.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
DerivedRegion,
88
DisplayConfiguration,
99
FileItem,
10+
FMVLayer,
11+
FMVVectorFeature,
1012
LayerCollection,
1113
LayerRepresentation,
1214
NetCDFData,
@@ -23,8 +25,6 @@
2325
VectorFeatureRowData,
2426
VectorFeatureTableData,
2527
VectorMapLayer,
26-
FMVLayer,
27-
FMVVectorFeature
2828
)
2929

3030

@@ -76,7 +76,16 @@ def get_map_layer_index(self, obj):
7676

7777

7878
class FMVLayerAdmin(admin.ModelAdmin):
79-
list_display = ['id', 'name', 'dataset', 'get_dataset_name', 'index', 'geojson_file', 'fmv_video', 'bounds']
79+
list_display = [
80+
'id',
81+
'name',
82+
'dataset',
83+
'get_dataset_name',
84+
'index',
85+
'geojson_file',
86+
'fmv_video',
87+
'bounds',
88+
]
8089

8190
def get_dataset_name(self, obj):
8291
return obj.dataset.name

0 commit comments

Comments
 (0)