@@ -47,7 +47,11 @@ const OutputSchema = Type.Object({
4747 primary_assignee_firstName : Type . Optional ( Type . String ( ) ) ,
4848 primary_assignee_lastName : Type . Optional ( Type . String ( ) ) ,
4949 primary_assignee_badgeNumber : Type . Optional ( Type . String ( ) ) ,
50- primary_assignee_userId : Type . Optional ( Type . String ( ) )
50+ primary_assignee_userId : Type . Optional ( Type . String ( ) ) ,
51+
52+ vehicle_vehicleId : Type . Optional ( Type . String ( ) ) ,
53+ vehicle_assigneeType : Type . Optional ( Type . String ( ) ) ,
54+ vehicle_vehicleName : Type . Optional ( Type . String ( ) ) ,
5155} ) ;
5256
5357export default class Task extends ETL {
@@ -163,7 +167,8 @@ export default class Task extends ETL {
163167 } ) ) ,
164168 status : Type . String ( ) ,
165169 stream : Type . Object ( {
166- isStreamable : Type . Boolean ( )
170+ isStreamable : Type . Boolean ( ) ,
171+ reason : Type . Optional ( Type . String ( ) )
167172 } ) ,
168173 links : Type . Optional ( Type . Object ( {
169174 view : Type . String ( )
@@ -174,6 +179,14 @@ export default class Task extends ETL {
174179 batteries : Type . Optional ( Type . Array ( Type . Object ( {
175180 batteryPercentage : Type . Integer ( )
176181 } ) ) ) ,
182+ connectedDevices : Type . Optional ( Type . Array ( Type . Object ( {
183+ axonDeviceId : Type . String ( )
184+ } ) ) ) ,
185+ vehicle : Type . Optional ( Type . Object ( {
186+ assigneeType : Type . String ( ) ,
187+ vehicleName : Type . String ( ) ,
188+ vehicleId : Type . String ( )
189+ } ) ) ,
177190 assignees : Type . Optional ( Type . Array ( Type . Object ( {
178191 assigneeType : Type . String ( ) ,
179192 firstName : Type . String ( ) ,
@@ -191,7 +204,6 @@ export default class Task extends ETL {
191204 const features : Static < typeof InputFeature > [ ] = [ ] ;
192205
193206 for ( const device of devicesRes . data ) {
194-
195207 const primary = ( device . attributes . assignees || [ ] ) . filter ( ( user ) => {
196208 return user . primary
197209 } )
@@ -208,49 +220,77 @@ export default class Task extends ETL {
208220 continue ;
209221 }
210222
211- const feat : Static < typeof InputFeature > = {
212- id : device . axonDeviceId ,
213- type : 'Feature' ,
214- properties : {
215- type : 'a-f-G-U-U-L' ,
216- how : 'm-g' ,
217- callsign : ( primary . length ? `${ env . AgencyAcronym || '' } ${ primary [ 0 ] . firstName . slice ( 0 , 1 ) } . ${ primary [ 0 ] . lastName } ` : 'Unknown User' ) . trim ( ) ,
218- time : new Date ( ) . toISOString ( ) ,
219- start : new Date ( device . attributes . location . locationUpdateTimestamp ) . toISOString ( ) ,
220- status : device . attributes . batteries ? {
221- battery : String ( device . attributes . batteries [ 0 ] . batteryPercentage )
222- } : undefined ,
223- remarks : [
224- `Agency: ${ device . partnerName } ` ,
225- `Name: ${ primary . length ? primary [ 0 ] . firstName + " " + primary [ 0 ] . lastName : "Unknown" } `
226- ] . join ( '\n' ) ,
227- metadata : {
228- partnerName : device . partnerName ,
229- axonDeviceId : device . axonDeviceId ,
230- deviceModel : device . deviceModel ,
231- deviceUpdateTimestamp : device . deviceUpdateTimestamp ,
232- deviceSerial : device . attributes . deviceSerial ,
233- location_accuracy : device . attributes . location . accuracy ,
234- location_latitude : device . attributes . location . latitude ,
235- location_longitude : device . attributes . location . longitude ,
236- location_locationUpdateTimestamp : device . attributes . location . locationUpdateTimestamp ,
237- status : device . attributes . status ,
238- stream_isStreamable : device . attributes . stream ? device . attributes . stream . isStreamable : false ,
239- signalStrength : device . attributes . signalStrengths ? device . attributes . signalStrengths [ 0 ] . signalStrength : undefined ,
240- battery : device . attributes . batteries ? device . attributes . batteries [ 0 ] . batteryPercentage : undefined ,
241- primary_assignee_firstName : primary . length ? primary [ 0 ] . firstName : undefined ,
242- primary_assignee_lastName : primary . length ? primary [ 0 ] . lastName : undefined ,
243- primary_assignee_badgeNumber : primary . length ? primary [ 0 ] . badgeNumber : undefined ,
244- primary_assignee_userId : primary . length ? primary [ 0 ] . userId : undefined
245- }
246- } ,
247- geometry : {
248- type : 'Point' ,
249- coordinates : [ device . attributes . location . longitude , device . attributes . location . latitude ]
250- }
223+ const metadata = {
224+ partnerName : device . partnerName ,
225+ axonDeviceId : device . axonDeviceId ,
226+ deviceModel : device . deviceModel ,
227+ deviceUpdateTimestamp : device . deviceUpdateTimestamp ,
228+ deviceSerial : device . attributes . deviceSerial ,
229+ location_accuracy : device . attributes . location . accuracy ,
230+ location_latitude : device . attributes . location . latitude ,
231+ location_longitude : device . attributes . location . longitude ,
232+ location_locationUpdateTimestamp : device . attributes . location . locationUpdateTimestamp ,
233+ status : device . attributes . status ,
234+ stream_isStreamable : device . attributes . stream ? device . attributes . stream . isStreamable : false ,
235+ signalStrength : device . attributes . signalStrengths ? device . attributes . signalStrengths [ 0 ] . signalStrength : undefined ,
236+ battery : device . attributes . batteries ? device . attributes . batteries [ 0 ] . batteryPercentage : undefined ,
237+ primary_assignee_firstName : primary . length ? primary [ 0 ] . firstName : undefined ,
238+ primary_assignee_lastName : primary . length ? primary [ 0 ] . lastName : undefined ,
239+ primary_assignee_badgeNumber : primary . length ? primary [ 0 ] . badgeNumber : undefined ,
240+ primary_assignee_userId : primary . length ? primary [ 0 ] . userId : undefined ,
241+ vehicle_vehicleId : device . attributes . vehicle ? device . attributes . vehicle . vehicleId : undefined ,
242+ vehicle_assigneeType : device . attributes . vehicle ? device . attributes . vehicle . assigneeType : undefined ,
243+ vehicle_vehicleName : device . attributes . vehicle ? device . attributes . vehicle . vehicleName : undefined
251244 }
252245
253- features . push ( feat ) ;
246+ if ( primary . length ) {
247+ features . push ( {
248+ id : device . axonDeviceId ,
249+ type : 'Feature' ,
250+ properties : {
251+ type : 'a-f-G-U-U-L' ,
252+ how : 'm-g' ,
253+ callsign : ( primary . length ? `${ env . AgencyAcronym || '' } ${ primary [ 0 ] . firstName . slice ( 0 , 1 ) } . ${ primary [ 0 ] . lastName } ` : 'Unknown User' ) . trim ( ) ,
254+ time : new Date ( ) . toISOString ( ) ,
255+ start : new Date ( device . attributes . location . locationUpdateTimestamp ) . toISOString ( ) ,
256+ status : device . attributes . batteries ? {
257+ battery : String ( device . attributes . batteries [ 0 ] . batteryPercentage )
258+ } : undefined ,
259+ remarks : [
260+ 'Type: Officer' ,
261+ `Agency: ${ device . partnerName } ` ,
262+ `Name: ${ primary . length ? primary [ 0 ] . firstName + " " + primary [ 0 ] . lastName : "Unknown" } `
263+ ] . join ( '\n' ) ,
264+ metadata : metadata
265+ } ,
266+ geometry : {
267+ type : 'Point' ,
268+ coordinates : [ device . attributes . location . longitude , device . attributes . location . latitude ]
269+ }
270+ } ) ;
271+ } else if ( device . attributes . vehicle ) {
272+ features . push ( {
273+ id : device . axonDeviceId ,
274+ type : 'Feature' ,
275+ properties : {
276+ type : 'a-f-G-E-V' ,
277+ how : 'm-g' ,
278+ callsign : device . attributes . vehicle . vehicleName ,
279+ time : new Date ( ) . toISOString ( ) ,
280+ start : new Date ( device . attributes . location . locationUpdateTimestamp ) . toISOString ( ) ,
281+ remarks : [
282+ 'Type: Vehicle' ,
283+ `Agency: ${ device . partnerName } ` ,
284+ `Name: ${ device . attributes . vehicle . vehicleName } `
285+ ] . join ( '\n' ) ,
286+ metadata : metadata
287+ } ,
288+ geometry : {
289+ type : 'Point' ,
290+ coordinates : [ device . attributes . location . longitude , device . attributes . location . latitude ]
291+ }
292+ } ) ;
293+ }
254294 }
255295
256296 const fc : Static < typeof InputFeatureCollection > = {
0 commit comments