forked from opensensorhub/osh-client-dev-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
296 lines (263 loc) · 7.85 KB
/
main.js
File metadata and controls
296 lines (263 loc) · 7.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import CesiumView from './osh-js/source/core/ui/view/map/CesiumView.js';
import {
Cartesian3,
CesiumTerrainProvider,
Cesium3DTileset,
EllipsoidTerrainProvider,
Ion,
IonResource
} from 'cesium';
import * as Cesium from "cesium";
import SosGetResultJson from "./osh-js/source/core/datasource/SosGetResultJson";
import PointMarkerLayer from "./osh-js/source/core/ui/layer/PointMarkerLayer";
import PolygonLayer from "./osh-js/source/core/ui/layer/PolygonLayer";
import FFMPEGView from "./osh-js/source/core/ui/view/video/FFMPEGView";
import SosGetResultVideo from "./osh-js/source/core/datasource/SosGetResultVideo";
import ChartJsView from './osh-js/source/core/ui/view/chart/ChartJsView.js';
import CurveLayer from './osh-js/source/core/ui/layer/CurveLayer.js';
import DataSynchronizer from './osh-js/source/core/timesync/DataSynchronizer'
window.CESIUM_BASE_URL = './';
Ion.defaultAccessToken = '';
let server = "ogct17.georobotix.io:8443/sensorhub/sos";
let start = "now";
let end = "2100-01-01Z";
let offeringId = "urn:osh:sensor:uas:predator001";
let locProperty = "http://www.opengis.net/def/property/OGC/0/SensorLocation";
let orientationProperty = "http://www.opengis.net/def/property/OGC/0/PlatformOrientation";
let dataSources = [];
// UAV
// -------- UAV LOCATION AND ORIENTATION
let uavLocDataSource = new SosGetResultJson("UAV-Location", {
protocol: "wss",
service: "SOS",
endpointUrl: server,
offeringID: offeringId,
observedProperty: locProperty,
startTime: start,
endTime: end,
});
dataSources.push(uavLocDataSource);
// uavLocDataSource.connect();
let uavAttitudeDataSource = new SosGetResultJson("UAV-Attitude", {
protocol: "wss",
service: "SOS",
endpointUrl: server,
offeringID: offeringId,
observedProperty: orientationProperty,
startTime: start,
endTime: end,
});
dataSources.push(uavAttitudeDataSource);
// uavAttitudeDataSource.connect();
// style it with a moving point marker
let uavPointMarker = new PointMarkerLayer({
labelOffset: [0, -30],
getLocation: {
dataSourceIds: [uavLocDataSource.getId()],
handler: function (rec){
return{
x: rec.location.lon,
y: rec.location.lat,
z: rec.location.alt
}
}
},
getOrientation: {
dataSourceIds: [uavAttitudeDataSource.getId()],
handler: function (rec){
return{
heading: rec.attitude.heading - 90.0
}
}
},
icon: 'images/uav.glb',
iconSize: [32, 64],
name: "UAV Location",
label: "UAV",
iconScale: .05,
color: '#FF8000'
});
uavPointMarker.props.markerId = "UAV UAS";
uavPointMarker.props.description = "UAV UAS";
// --- UAV VIDEO
let uavVideoDS = new SosGetResultVideo("UAV-Video",{
protocol: "wss",
service: "SOS",
endpointUrl: server,
offeringID: offeringId,
observedProperty: "http://sensorml.com/ont/swe/property/VideoFrame",
startTime: start,
endTime: end,
})
let uavVideo = new FFMPEGView({
container: 'video-window',
css: 'video-h264',
name: 'UAV Video',
framerate:25,
showTime: false,
showStats: false,
dataSourceId: uavVideoDS.id
})
dataSources.push(uavVideoDS);
// uavVideoDS.connect();
// ------- UAV ALTITUDE - CHART ------- //
// #region snippet_curve_layer
let altitudeLayerCurve = new CurveLayer({
dataSourceId: uavLocDataSource.id,
getValues: (rec, timeStamp) => {
return {
x: timeStamp,
y: rec.location.alt
}
},
name: 'ALTITUDE'
});
// #endregion snippet_curve_layer
// show it in video view
let altitudeChartView = new ChartJsView({
container: 'alt-chart-window',
layers: [ altitudeLayerCurve],
css: "chart-view",
chartjsProps: {
chartProps: {
scales: {
yAxes: [{
scaleLabel: {
labelString: "Altitude"
},
ticks: {
maxTicksLimit: 5
}
}],
xAxes: [{
scaleLabel: {
labelString: "Time"
},
ticks: {
maxTicksLimit: 7
}
}],
}
},
datasetsProps: {
backgroundColor: 'rgba(141,242,246, 0.1)'
}
}
});
// ------- UAV Field of Regard ------- //
let uavForDataSource = new SosGetResultJson("UAV-FOR", {
protocol: "wss",
service: "SOS",
endpointUrl: server,
offeringID: "urn:osh:process:georef",
observedProperty: "http://sensorml.com/ont/misb0601/property/GeoRefImageFrame",
startTime: start,
endTime: end,
});
dataSources.push(uavForDataSource);
// uavForDataSource.connect();
let boundedDrapingLayer = new PolygonLayer({
opacity: .5,
getVertices: {
dataSourceIds: [uavForDataSource.getId()],
handler: function (rec){
return [
rec.ulc.lon,
rec.ulc.lat,
rec.llc.lon,
rec.llc.lat,
rec.lrc.lon,
rec.lrc.lat,
rec.urc.lon,
rec.urc.lat,
];
}
},
});
// ------- UAV Tracking Target ------- //
let suvForDataSource = new SosGetResultJson("SUV-TARGET", {
protocol: "wss",
service: "SOS",
endpointUrl: server,
offeringID: "urn:osh:process:vmti",
observedProperty: "http://sensorml.com/ont/swe/property/TargetLocation",
startTime: start,
endTime: end,
});
dataSources.push(suvForDataSource);
// suvForDataSource.connect();
// style it with a moving point marker
let suvPointMarker = new PointMarkerLayer({
labelOffset: [0, -30],
getLocation: {
dataSourceIds: [suvForDataSource.getId()],
handler: function (rec){
return{
x: rec.location.lon,
y: rec.location.lat,
}
}
},
icon: 'images/suv.glb',
iconSize: [32, 64],
name: "SUV Location",
label: "SUV",
iconScale: .0000000000001,
color: '#FFFFFF',
opacity: .25,
orientation: {
heading: 90
}
});
// #region snippet_cesium_location_view
// create Cesium view
let cesiumView = new CesiumView({
container: 'cesium-container',
cesiumProps: {
viewerProps :{
baseLayerPicker: true,
// imageryProviderViewModels: imageryProviders,
// selectedImageryProviderViewModel: imageryProviders[6],
timeline: true,
homeButton: false,
navigationInstructionsInitiallyVisible: false,
navigationHelpButton: false,
geocoder: true,
fullscreenButton: false,
showRenderLoopErrors: true,
animation: true,
scene3DOnly: true, // for draw layer
}
},
layers: [uavPointMarker, boundedDrapingLayer, suvPointMarker]
});
// cesiumView.viewer.terrainProvider = new CesiumTerrainProvider({
// url: IonResource.fromAssetId(1,
// {accessToken: Ion.defaultAccessToken}
// ),
// requestWaterMask: true,
// requestVertexNormals: true
// });
//
// cesiumView.viewer.imageryLayers.addImageryProvider(
// new Cesium.TileMapServiceImageryProvider({
// url: Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
// })
// );
//
// cesiumView.viewer.scene.primitives.add(
// new Cesium3DTileset({
// url: IonResource.fromAssetId(596882,
// {accessToken: Ion.defaultAccessToken}
// )
// }));
cesiumView.viewer.camera.setView({
destination: Cartesian3.fromDegrees(-86.67128902952935, 34.70690480206765, 10000)
});
// start streaming
let masterTimeController = new DataSynchronizer({
replaySpeed: 1,
intervalRate: 5,
dataSources: dataSources
});
masterTimeController.connect();