-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Vizzuality/client/feature/story
Add story
- Loading branch information
Showing
24 changed files
with
5,326 additions
and
10,282 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,39 @@ | ||
import Highcharts from 'highcharts'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
|
||
const Chart = ({ options }: { options: any }) => { | ||
return ( | ||
<div className="h-[500px] w-[500px]"> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={{ | ||
title: { text: '' }, | ||
series: options.series, | ||
chart: { | ||
...options.chart, | ||
backgroundColor: 'transparent', | ||
height: '300px', | ||
}, | ||
legend: { enabled: false }, | ||
xAxis: { | ||
labels: { style: { color: '#fff' } }, | ||
legend: { style: { color: '#fff' } }, | ||
lineWidth: 0, | ||
}, | ||
yAxis: { | ||
title: { text: '' }, | ||
gridLineDashStyle: 'Dash', | ||
gridLineColor: 'rgba(255, 255, 255, 0.80)', | ||
lineColor: '#ff0000', | ||
gridLineWidth: 1, | ||
legend: { style: { color: '#fff' }, title: { text: '' } }, | ||
labels: { style: { color: '#fff' } }, | ||
}, | ||
...options, | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Chart; |
143 changes: 143 additions & 0 deletions
143
client/src/components/map/layers/animated-tile-layer/index.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,143 @@ | ||
'use client'; | ||
|
||
import { useEffect, useMemo, useState } from 'react'; | ||
|
||
import { TileLayer } from '@deck.gl/geo-layers'; | ||
import { BitmapLayer } from '@deck.gl/layers'; | ||
import parseAPNG from 'apng-js'; | ||
import { useIntervalWhen } from 'rooks'; | ||
|
||
import { LayerProps } from '@/types/layers'; | ||
|
||
import { useDeckMapboxOverlayContext } from '@/components/map/provider'; | ||
|
||
export type DeckLayerProps<T> = LayerProps & | ||
T & { | ||
type: any; | ||
config: any; | ||
paramsConfig: any; | ||
}; | ||
|
||
const AnimatedTileLayer = <T,>({ id, type, config, paramsConfig, ...props }: DeckLayerProps<T>) => { | ||
// Render deck layer | ||
const i = `${id}-deck`; | ||
const { addLayer, removeLayer } = useDeckMapboxOverlayContext(); | ||
const [frame, setFrame] = useState(0); | ||
const SATELLITE_DECK_LAYER = useMemo(() => { | ||
const { opacity = 1, visible = true } = paramsConfig; | ||
const { minZoom, maxZoom, url } = config; | ||
return [ | ||
new TileLayer({ | ||
id: i, | ||
beforeId: id, | ||
frame, | ||
// getPolygonOffset: () => { | ||
// return [0, 5000000]; | ||
// }, | ||
getTileData: (tile: any) => { | ||
const { | ||
index: { x, y, z }, | ||
signal, | ||
} = tile; | ||
// const url = `https://fra1.digitaloceanspaces.com/esa-gda-comms-staging/APNGs/SatelliteImagery/${z}/${x}/${y}.png`; | ||
const url = `https://fra1.digitaloceanspaces.com/esa-gda-comms-staging/APNGs/Settlement/${z}/${x}/${y}.png`; | ||
// const url = `https://storage.googleapis.com/skydipper_materials/movie-tiles/MODIS/APNGs/${z}/${x}/${y}.png`; | ||
|
||
const response = fetch(url, { signal }); | ||
|
||
if (signal.aborted) { | ||
return null; | ||
} | ||
|
||
return response | ||
.then((res) => res.arrayBuffer()) | ||
.then((buffer) => { | ||
const apng = parseAPNG(buffer); | ||
if (apng instanceof Error) { | ||
throw apng; | ||
} | ||
return apng.frames.map((f: any) => { | ||
return { | ||
...f, | ||
bitmapData: createImageBitmap(f.imageData), | ||
}; | ||
}); | ||
}); | ||
}, | ||
tileSize: 256, | ||
visible: true, | ||
opacity: 1, | ||
refinementStrategy: 'no-overlap', | ||
renderSubLayers: (sl: any) => { | ||
if (!sl) return null; | ||
|
||
const { id: subLayerId, data, tile, visible, opacity = 1, frame: f } = sl; | ||
|
||
if (!tile || !data) return null; | ||
|
||
const { | ||
z, | ||
bbox: { west, south, east, north }, | ||
} = tile; | ||
|
||
const FRAME = data[f]; | ||
|
||
if (FRAME) { | ||
return new BitmapLayer({ | ||
id: subLayerId, | ||
beforeId: id, | ||
image: FRAME.bitmapData, | ||
bounds: [west, south, east, north], | ||
getPolygonOffset: () => { | ||
return [0, 5000]; | ||
}, | ||
// textureParameters: { | ||
// [GL.TEXTURE_MIN_FILTER]: GL.NEAREST, | ||
// [GL.TEXTURE_MAG_FILTER]: GL.NEAREST, | ||
// [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE, | ||
// [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE, | ||
// }, | ||
zoom: z, | ||
visible: true, | ||
opacity: 1, | ||
}); | ||
} | ||
return null; | ||
}, | ||
minZoom: 9, | ||
maxZoom: 14, | ||
// extent: initialViewState.bounds, | ||
}), | ||
]; | ||
}, [config, i, paramsConfig, frame]); | ||
|
||
useIntervalWhen(() => { | ||
setFrame((prev) => { | ||
if (prev === 21) { | ||
return 0; | ||
} | ||
|
||
return prev + 1; | ||
}); | ||
}, 1000); | ||
|
||
useEffect(() => { | ||
// const ly = new type({ | ||
// ...props, | ||
// id: i, | ||
// beforeId: id, | ||
// }); | ||
console.log(SATELLITE_DECK_LAYER); | ||
addLayer(SATELLITE_DECK_LAYER); | ||
}, [i, id, type, props, addLayer, SATELLITE_DECK_LAYER]); | ||
|
||
useEffect(() => { | ||
return () => { | ||
removeLayer(i); | ||
}; | ||
}, [i, removeLayer]); | ||
|
||
return null; | ||
}; | ||
|
||
export default AnimatedTileLayer; |
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
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
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
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
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
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
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
Oops, something went wrong.