Skip to content

Commit 879eed1

Browse files
authored
Merge pull request #439 from EarthyScience/jp/border-rotate
country borders rotate with flatmap
2 parents 2620c72 + 59c436f commit 879eed1

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/components/plots/CountryBorders.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@ function Spherize([lon, lat] : [number, number]){
2929

3030
function Borders({features}:{features: any}){
3131
const {xRange, yRange, plotType, borderColor, lonExtent, latExtent, lonResolution, latResolution} = usePlotStore(useShallow(state => ({
32-
xRange: state.xRange,
33-
yRange: state.yRange,
34-
plotType: state.plotType,
35-
borderColor: state.borderColor,
36-
lonExtent: state.lonExtent,
37-
latExtent: state.latExtent,
38-
lonResolution: state.lonResolution,
39-
latResolution: state.latResolution
32+
xRange: state.xRange, yRange: state.yRange,
33+
plotType: state.plotType, borderColor: state.borderColor,
34+
lonExtent: state.lonExtent, latExtent: state.latExtent,
35+
lonResolution: state.lonResolution, latResolution: state.latResolution,
4036
})))
4137
const {flipY, shape } = useGlobalStore(useShallow(state => ({
4238
flipY: state.flipY,
@@ -52,7 +48,6 @@ function Borders({features}:{features: any}){
5248
return [newLonBounds as [number, number], newLatBounds as [number, number]]
5349
},[latExtent, lonExtent, lonResolution, latResolution])
5450

55-
5651
const [spherize, setSpherize] = useState<boolean>(false)
5752

5853
useEffect(()=>{
@@ -192,11 +187,10 @@ const CountryBorders = () => {
192187
dataShape: state.dataShape,
193188
is4D: state.is4D
194189
})))
195-
const {zRange, plotType, showBorders, timeScale} = usePlotStore(useShallow(state => ({
196-
zRange: state.zRange,
197-
plotType: state.plotType,
198-
showBorders: state.showBorders,
199-
timeScale: state.timeScale
190+
const {zRange, plotType, showBorders, timeScale, rotateFlat} = usePlotStore(useShallow(state => ({
191+
zRange: state.zRange, plotType: state.plotType,
192+
showBorders: state.showBorders, timeScale: state.timeScale,
193+
rotateFlat: state.rotateFlat
200194
})))
201195
const {analysisMode, axis} = useAnalysisStore(useShallow(state => ({
202196
analysisMode: state.analysisMode,
@@ -239,9 +233,16 @@ const CountryBorders = () => {
239233
const isFlatMap = plotType == "flat"
240234
const depthScale = dataShape[0]/dataShape[2]*timeScale
241235
return(
242-
<group visible={showBorders && !(analysisMode && axis != 0)} position={(spherize || isFlatMap) ? [0,0,0] : [0, 0, swapSides ? zRange[0]*(isPC ? depthScale : 1) : zRange[1]*(isPC ? depthScale : 1)]}>
243-
{coastLines && <Borders features={coastLines} />}
244-
{borders && <Borders features={borders} />}
236+
<group
237+
rotation={[rotateFlat ? -Math.PI/2 : 0, 0, 0]}
238+
>
239+
<group
240+
visible={showBorders && !(analysisMode && axis != 0)}
241+
position={(spherize || isFlatMap) ? [0,0,(isFlatMap ? 0.001 : 0)] : [0, 0, swapSides ? zRange[0]*(isPC ? depthScale : 1) : zRange[1]*(isPC ? depthScale : 1)]}
242+
>
243+
{coastLines && <Borders features={coastLines} />}
244+
{borders && <Borders features={borders} />}
245+
</group>
245246
</group>
246247
)
247248
}

0 commit comments

Comments
 (0)