@@ -142,6 +142,8 @@ private function detectTransmissionGaps(Vessel $vessel): void
142142 'effective_speed ' => round ($ effectiveSpeed , 2 ),
143143 'gap_start ' => $ current ->recorded_at ->toIso8601String (),
144144 'gap_end ' => $ next ->recorded_at ->toIso8601String (),
145+ 'start_pos ' => ['lat ' => round ($ current ->lat , 6 ), 'lng ' => round ($ current ->lng , 6 )],
146+ 'end_pos ' => ['lat ' => round ($ next ->lat , 6 ), 'lng ' => round ($ next ->lng , 6 )],
145147 'start_speed ' => $ current ->speed ,
146148 'end_speed ' => $ next ->speed ,
147149 ], $ current ->recorded_at , $ next ->recorded_at );
@@ -185,6 +187,7 @@ private function detectLoiteringPatterns(Vessel $vessel): void
185187 'duration_hours ' => $ durationHours ,
186188 'lat_span ' => round ($ latRange , 6 ),
187189 'lng_span ' => round ($ lngRange , 6 ),
190+ 'coordinates ' => ['lat ' => round ($ recent ->avg ('lat ' ), 6 ), 'lng ' => round ($ recent ->avg ('lng ' ), 6 )],
188191 ], $ recent ->last ()->recorded_at , $ recent ->first ()->recorded_at );
189192 }
190193 }
@@ -307,10 +310,17 @@ private function persistActivity(
307310 private function resolveDescription (string $ type , array $ details ): string
308311 {
309312 return match ($ type ) {
310- 'ais_gap ' => 'AIS transmission interruption detected ( ' .MaritimeFormatter::formatDuration ($ details ['duration_minutes ' ] ?? 0 ).'). ' ,
311- 'loitering ' => 'Stationary residency pattern in open-sea transit area. ' ,
312- 'speed_anomaly ' => 'Kinematic violation: speed exceeds physical capability ( ' .round ($ details ['reported_speed ' ] ?? 0 , 1 ).' kn). ' ,
313- 'port_of_interest ' => 'Vessel interaction detected at high-risk maritime hub: ' .($ details ['port_name ' ] ?? 'Unknown Port ' ).'. ' ,
313+ 'ais_gap ' => 'AIS transmission interruption detected. From ' .
314+ (isset ($ details ['start_pos ' ]) ? "[ {$ details ['start_pos ' ]['lat ' ]}, {$ details ['start_pos ' ]['lng ' ]}] to [ {$ details ['end_pos ' ]['lat ' ]}, {$ details ['end_pos ' ]['lng ' ]}] " : 'unknown position ' ).
315+ ' ( ' .MaritimeFormatter::formatDuration ($ details ['duration_minutes ' ] ?? 0 ).'). ' ,
316+ 'loitering ' => 'Stationary residency pattern detected at ' .
317+ (isset ($ details ['coordinates ' ]) ? "[ {$ details ['coordinates ' ]['lat ' ]}, {$ details ['coordinates ' ]['lng ' ]}] " : 'unknown area ' ).
318+ ' for ' .($ details ['duration_hours ' ] ?? 0 ).' hours. ' ,
319+ 'speed_anomaly ' => 'Kinematic violation at ' .
320+ (isset ($ details ['coordinates ' ]) ? "[ {$ details ['coordinates ' ]['lat ' ]}, {$ details ['coordinates ' ]['lng ' ]}] " : 'unknown location ' ).
321+ ': speed exceeds physical capability ( ' .round ($ details ['reported_speed ' ] ?? 0 , 1 ).' kn). ' ,
322+ 'port_of_interest ' => 'Vessel interaction detected at high-risk maritime hub: ' .($ details ['port_name ' ] ?? 'Unknown Port ' ).
323+ ' ' .(isset ($ details ['coordinates ' ]) ? "[ {$ details ['coordinates ' ]['lat ' ]}, {$ details ['coordinates ' ]['lng ' ]}] " : '' ).'. ' ,
314324 default => 'Anomalous behavioral event detected. ' ,
315325 };
316326 }
0 commit comments