-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxime Chaillet
committed
Jan 14, 2025
1 parent
19015fb
commit 1635a2c
Showing
4 changed files
with
133 additions
and
10 deletions.
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