-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AA storm feature / revisit landfall popup display #1410
Merged
ericboucher
merged 24 commits into
feature/add-new-AA-storm
from
aa-storm-feature/revisit-landfall-popup-display
Jan 17, 2025
Merged
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
954eeee
report the change from PR #1384
5fa8df2
permanently show last analysed time point popup
103eb85
Merge branch 'feature/add-new-AA-storm' into feature/permanently-show…
ericboucher a8966e4
Merge branch 'feature/add-new-AA-storm' into improve-style-of-windpoi…
ericboucher 84e7856
refacto types
f938589
remove unused types, more refacto
f9f46a8
Merge branch 'feature/permanently-show-last-analysed-date-tooltip' of…
53fca9f
improve timeline tooltip arrow
57c3b52
update landfall popup
da8d19d
fix test
19015fb
Merge branch 'feature/permanently-show-last-analysed-date-tooltip' in…
1635a2c
show small landfall popup
6eddfab
move popup of the right
edd7cda
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/revisit…
ericboucher 57cbbc9
Fix lint
ericboucher e395922
Update index.tsx
ericboucher 977735c
Update index.tsx
ericboucher 1f2d078
Cleanup PR
ericboucher 98ab91f
remove usage of unknown keyword
7a4a9b5
Merge branch 'aa-storm-feature/revisit-landfall-popup-display' of ssh…
7dd24d9
fix tooltip behaviour when clicking on it several times
e76f601
redefine how landfall marker is displayed
92a3f97
display landfall marker based on report date instead of current date
32845f0
Update AAStormLandfallMarker.tsx
ericboucher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...toryActionStormLayer/AAStormLandfallPopup/AAStormLandfallMarker/AAStormLandfallMarker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { Popup } from 'react-map-gl/maplibre'; | ||
import { ParsedStormData } from 'context/anticipatoryAction/AAStormStateSlice/parsedStromDataTypes'; | ||
import _React from 'react'; | ||
import { createStyles, makeStyles, Typography } from '@material-ui/core'; | ||
import { findLandfallWindPoint } from '../utils'; | ||
|
||
function AAStormLandfallMarker({ stormData }: AAStormLandfallPopupProps) { | ||
const classes = useStyles(); | ||
|
||
const windpoint = findLandfallWindPoint(stormData); | ||
|
||
if (!windpoint) { | ||
return null; | ||
} | ||
|
||
const lng = windpoint.geometry.coordinates[0]; | ||
const lat = windpoint.geometry.coordinates[1]; | ||
|
||
return ( | ||
<Popup | ||
longitude={lng} | ||
latitude={lat} | ||
anchor="bottom" | ||
offset={25} | ||
closeButton={false} | ||
closeOnClick={false} | ||
className={classes.popup} | ||
> | ||
<Typography className={classes.tooltipText} variant="body1"> | ||
landfall | ||
</Typography> | ||
</Popup> | ||
); | ||
} | ||
|
||
interface AAStormLandfallPopupProps { | ||
stormData: ParsedStormData; | ||
} | ||
|
||
const useStyles = makeStyles(() => | ||
createStyles({ | ||
tooltipText: { | ||
fontSize: '14px', | ||
fontWeight: 600, | ||
lineHeight: '14px', | ||
paddingBottom: '2px', | ||
}, | ||
|
||
popup: { | ||
'& > .maplibregl-popup-content': { | ||
border: 'none', | ||
padding: '4px', | ||
borderRadius: '4px', | ||
background: 'white', | ||
boxShadow: 'inset 0px 0px 0px 1px #A4A4A4', | ||
position: 'relative', | ||
}, | ||
|
||
'& > .maplibregl-popup-tip': { | ||
display: 'none', | ||
}, | ||
|
||
// hack to display the popup tip without overlapping border | ||
'&::after': { | ||
content: '""', | ||
position: 'absolute', | ||
left: '50%', | ||
bottom: '-5px', | ||
width: '10px', | ||
height: '10px', | ||
background: 'white', | ||
transform: 'translateX(-50%) rotate(45deg)', | ||
borderWidth: '0px 1px 1px 0px', | ||
borderColor: '#A4A4A4', | ||
borderStyle: 'solid', | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
export default AAStormLandfallMarker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../src/components/MapView/Layers/AnticipatoryActionStormLayer/AAStormLandfallPopup/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ParsedStormData } from 'context/anticipatoryAction/AAStormStateSlice/parsedStromDataTypes'; | ||
import { AAStormTimeSeriesFeature } from 'context/anticipatoryAction/AAStormStateSlice/rawStormDataTypes'; | ||
|
||
/* find the wind point which time corresponds to the landfall estimated time */ | ||
export function findLandfallWindPoint(stormData: ParsedStormData) { | ||
const { landfall } = stormData; | ||
if (!landfall) { | ||
return null; | ||
} | ||
|
||
const landfallEstimatedtime = landfall.time; | ||
|
||
const windpoints = stormData.timeSeries?.features; | ||
return windpoints?.find(windpoint => | ||
isFeatureAtLandfallEstimateTime(windpoint, landfallEstimatedtime), | ||
); | ||
} | ||
|
||
export function isFeatureAtLandfallEstimateTime( | ||
feature: AAStormTimeSeriesFeature, | ||
landfallEstimatedtime: string[], | ||
) { | ||
return ( | ||
landfallEstimatedtime && | ||
feature.properties.time === landfallEstimatedtime[0] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
frontend/src/context/anticipatoryAction/AAStormStateSlice/parsedStromDataTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ForecastDetails, TimeSeries } from './rawStormDataTypes'; | ||
|
||
export enum AACategory { | ||
Severe = 'Severe', | ||
Moderate = 'Moderate', | ||
Risk = 'Risk', | ||
} | ||
|
||
export enum AACategoryKey { | ||
Severe = 'exposed_area_64kt', | ||
Moderate = 'exposed_area_48kt', | ||
Proba = 'proba_48kt_20_5d', | ||
} | ||
|
||
export enum AACategoryLandfall { | ||
Severe = 'severe tropical storm', | ||
Moderate = 'moderate tropical storm', | ||
} | ||
|
||
export interface AAData { | ||
districtNames: string[]; | ||
polygon: any; | ||
} | ||
|
||
export type DistrictDataType = { | ||
[key in AACategory]?: AAData; | ||
}; | ||
|
||
export interface LandfallInfo { | ||
district: string; | ||
time: string[]; | ||
severity: AACategory[]; | ||
} | ||
|
||
interface FeatureProperties { | ||
time: string; | ||
[key: string]: any; | ||
} | ||
|
||
export const AACategoryDataToLandfallMap: { | ||
[key in AACategoryLandfall]: AACategory; | ||
} = { | ||
[AACategoryLandfall.Severe]: AACategory.Severe, | ||
[AACategoryLandfall.Moderate]: AACategory.Moderate, | ||
}; | ||
|
||
export const AACategoryKeyToCategoryMap: { | ||
[key in AACategoryKey]: AACategory; | ||
} = { | ||
[AACategoryKey.Severe]: AACategory.Severe, | ||
[AACategoryKey.Moderate]: AACategory.Moderate, | ||
[AACategoryKey.Proba]: AACategory.Risk, | ||
}; | ||
|
||
/* parsed storm data type */ | ||
export type ParsedStormData = { | ||
activeDistricts?: DistrictDataType; | ||
naDistricts?: DistrictDataType; | ||
landfall?: LandfallInfo; | ||
timeSeries?: TimeSeries; | ||
landfallDetected?: boolean; | ||
forecastDetails?: ForecastDetails; | ||
uncertaintyCone?: FeatureProperties; | ||
}; | ||
|
||
export type ResultType = { | ||
data: ParsedStormData; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this avoidable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(using "unknown")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I have pushed a simple version without unknown.