@@ -78,6 +78,7 @@ interface ModeRouteData {
7878 topRiskFactors ?: { factor : string ; weight : number } [ ] | { label : string ; count : number ; pct : number } [ ] ;
7979 timeBand ?: string ;
8080 segmentRisks ?: number [ ] ;
81+ highRiskCoords ?: Array < { latitude : number ; longitude : number } > ;
8182 aadtAvg ?: number ;
8283 aadtMax ?: number ;
8384 timePenaltyPct ?: number ;
@@ -95,6 +96,7 @@ interface ModeRoutes {
9596 topRiskFactors ?: any [ ] ;
9697 timeBand ?: string ;
9798 segmentRisks ?: number [ ] ;
99+ highRiskCoords ?: Array < { latitude : number ; longitude : number } > ;
98100 aadtAvg ?: number ;
99101 aadtMax ?: number ;
100102 timePenaltyPct ?: number ;
@@ -186,6 +188,7 @@ function mapSafetyRoutesToAlternatives(safetyRoutes: SafetyRoute[]): RouteAltRow
186188 topRiskFactors : r . top_risk_factors ,
187189 timeBand : r . time_band ,
188190 segmentRisks : r . segment_risks ,
191+ highRiskCoords : r . high_risk_coords ?? [ ] ,
189192 aadtAvg : r . aadt_avg ,
190193 aadtMax : r . aadt_max ,
191194 timePenaltyPct : r . time_penalty_pct ,
@@ -211,6 +214,7 @@ function primaryToAlternativeRow(primary: ModeRouteData, index = 0): RouteAltRow
211214 topRiskFactors : primary . topRiskFactors ,
212215 timeBand : primary . timeBand ,
213216 segmentRisks : primary . segmentRisks ,
217+ highRiskCoords : primary . highRiskCoords ,
214218 aadtAvg : primary . aadtAvg ,
215219 aadtMax : primary . aadtMax ,
216220 timePenaltyPct : primary . timePenaltyPct ,
@@ -429,8 +433,22 @@ function RouteDetailsModal({
429433 ) }
430434 < Marker coordinate = { { latitude : destLat , longitude : destLng } } pinColor = "#FF4444" />
431435 { activeData ?. coords ?. length ? (
432- < Polyline coordinates = { activeData . coords } strokeColor = { activeData . routeSource === 'safeway' ? '#1ABC93' : '#4A90E2' } strokeWidth = { 4 } />
436+ ( activeData . segmentRisks as any [ ] ) ?. length
437+ ? ( activeData . segmentRisks as any [ ] ) . map ( ( seg : any , si : number ) => (
438+ < Polyline
439+ key = { `modal-seg-${ si } ` }
440+ coordinates = { [ seg . start , seg . end ] }
441+ strokeColor = { seg . risk > 66 ? '#FF4444' : seg . risk > 33 ? '#FFA500' : '#1ABC93' }
442+ strokeWidth = { 4 }
443+ />
444+ ) )
445+ : < Polyline coordinates = { activeData . coords } strokeColor = { activeData . routeSource === 'safeway' ? '#1ABC93' : '#4A90E2' } strokeWidth = { 4 } />
433446 ) : null }
447+ { ( activeData ?. highRiskCoords as any [ ] ?? [ ] ) . map ( ( coord : any , i : number ) => (
448+ < Marker key = { `modal-hs-${ i } ` } coordinate = { coord } anchor = { { x : 0.5 , y : 1.0 } } tracksViewChanges = { false } >
449+ < Text style = { { fontSize : 14 } } > ⚠️</ Text >
450+ </ Marker >
451+ ) ) }
434452 </ MapView >
435453 { activeData && (
436454 < View style = { dm . routeTimeBubble } >
@@ -782,7 +800,7 @@ export default function DirectionsScreen() {
782800 safetyScore : primary . safetyScore , safetyLabel : primary . safetyLabel , routeSource : primary . routeSource ,
783801 riskPerKm : primary . riskPerKm , nHighRisk : primary . nHighRisk , routeKm : primary . routeKm ,
784802 topRiskFactors : primary . topRiskFactors , timeBand : primary . timeBand ,
785- segmentRisks : primary . segmentRisks , aadtAvg : primary . aadtAvg , aadtMax : primary . aadtMax ,
803+ segmentRisks : primary . segmentRisks , highRiskCoords : primary . highRiskCoords , aadtAvg : primary . aadtAvg , aadtMax : primary . aadtMax ,
786804 timePenaltyPct : primary . timePenaltyPct , riskReductionPct : primary . riskReductionPct ,
787805 } ,
788806 alternatives : alts ,
@@ -819,7 +837,7 @@ export default function DirectionsScreen() {
819837 safetyScore : primary . safetyScore , safetyLabel : primary . safetyLabel , routeSource : primary . routeSource ,
820838 riskPerKm : primary . riskPerKm , nHighRisk : primary . nHighRisk , routeKm : primary . routeKm ,
821839 topRiskFactors : primary . topRiskFactors , timeBand : primary . timeBand ,
822- segmentRisks : primary . segmentRisks , aadtAvg : primary . aadtAvg , aadtMax : primary . aadtMax ,
840+ segmentRisks : primary . segmentRisks , highRiskCoords : primary . highRiskCoords , aadtAvg : primary . aadtAvg , aadtMax : primary . aadtMax ,
823841 timePenaltyPct : primary . timePenaltyPct , riskReductionPct : primary . riskReductionPct ,
824842 } ,
825843 alternatives : alts ,
@@ -842,7 +860,7 @@ export default function DirectionsScreen() {
842860 safetyScore : primary . safetyScore , safetyLabel : primary . safetyLabel , routeSource : primary . routeSource ,
843861 riskPerKm : primary . riskPerKm , nHighRisk : primary . nHighRisk , routeKm : primary . routeKm ,
844862 topRiskFactors : primary . topRiskFactors , timeBand : primary . timeBand ,
845- segmentRisks : primary . segmentRisks , aadtAvg : primary . aadtAvg , aadtMax : primary . aadtMax ,
863+ segmentRisks : primary . segmentRisks , highRiskCoords : primary . highRiskCoords , aadtAvg : primary . aadtAvg , aadtMax : primary . aadtMax ,
846864 timePenaltyPct : primary . timePenaltyPct , riskReductionPct : primary . riskReductionPct ,
847865 } ,
848866 alternatives : alts ,
@@ -981,7 +999,8 @@ export default function DirectionsScreen() {
981999 safetyScore : selectedAlt . safetyScore , safetyLabel : selectedAlt . safetyLabel , routeSource : selectedAlt . routeSource ,
9821000 riskPerKm : selectedAlt . riskPerKm , nHighRisk : selectedAlt . nHighRisk , routeKm : selectedAlt . routeKm ,
9831001 topRiskFactors : selectedAlt . topRiskFactors , timeBand : selectedAlt . timeBand ,
984- segmentRisks : selectedAlt . segmentRisks , aadtAvg : selectedAlt . aadtAvg , aadtMax : selectedAlt . aadtMax ,
1002+ segmentRisks : selectedAlt . segmentRisks , highRiskCoords : selectedAlt . highRiskCoords ,
1003+ aadtAvg : selectedAlt . aadtAvg , aadtMax : selectedAlt . aadtMax ,
9851004 timePenaltyPct : selectedAlt . timePenaltyPct , riskReductionPct : selectedAlt . riskReductionPct ,
9861005 }
9871006 : modeData ?. primary ?? null ;
@@ -1020,6 +1039,19 @@ export default function DirectionsScreen() {
10201039 { alternatives . map ( ( alt , i ) => {
10211040 if ( ! alt . coords ?. length ) return null ;
10221041 const isSelected = i === selectedRouteIndex ;
1042+ const segs = alt . segmentRisks as any [ ] | undefined ;
1043+ if ( isSelected && segs ?. length ) {
1044+ return segs . map ( ( seg : any , si : number ) => (
1045+ < Polyline
1046+ key = { `${ travelMode } -alt-${ i } -seg-${ si } ` }
1047+ coordinates = { [ seg . start , seg . end ] }
1048+ strokeColor = { seg . risk > 66 ? '#FF4444' : seg . risk > 33 ? '#FFA500' : '#1ABC93' }
1049+ strokeWidth = { 5 }
1050+ tappable
1051+ onPress = { ( ) => setSelectedRouteIndex ( i ) }
1052+ />
1053+ ) ) ;
1054+ }
10231055 return (
10241056 < Polyline
10251057 key = { `${ travelMode } -alt-${ i } ` }
@@ -1034,6 +1066,11 @@ export default function DirectionsScreen() {
10341066 { alternatives . length === 0 && activeData ?. coords ?. length ? (
10351067 < Polyline key = { travelMode } coordinates = { activeData . coords } strokeColor = "#4A90E2" strokeWidth = { 5 } />
10361068 ) : null }
1069+ { ( alternatives [ selectedRouteIndex ] ?. highRiskCoords as any [ ] ?? [ ] ) . map ( ( coord : any , i : number ) => (
1070+ < Marker key = { `hs-${ i } ` } coordinate = { coord } anchor = { { x : 0.5 , y : 1.0 } } tracksViewChanges = { false } >
1071+ < Text style = { { fontSize : 16 } } > ⚠️</ Text >
1072+ </ Marker >
1073+ ) ) }
10371074 { heatmapFilter !== 'off' && crashPoints . length > 0 && (
10381075 < Heatmap points = { crashPoints } opacity = { 0.72 } radius = { 20 }
10391076 gradient = { { colors : [ '#00E5FF' , '#FFD600' , '#FF1744' ] , startPoints : [ 0.1 , 0.5 , 1.0 ] , colorMapSize : 256 } }
0 commit comments