{"version":3,"sources":["App.module.css","projects/gas-trade-flow/components/GtfVector.js","projects/gas-trade-flow/components/GtfAnimatedFlowMap.js","projects/gas-trade-flow/components/GtfAnimatedFlow.js","App.js","serviceWorker.js","index.js"],"names":["module","exports","Map","width","height","viewState","colors","onViewStateChange","data","React","useState","time","setTime","undefined","highlight","setHighlight","x","y","object","type","selectedCountry","setSelectedCountry","animationFrames","useRef","HighlightType","getLocationId","loc","properties","name","animate","useCallback","timestamp","Date","now","loopLength","current","window","requestAnimationFrame","useEffect","cancelAnimationFrame","layers","FlowMapLayer","id","locations","flows","pickable","animationCurrentTime","getFlowMagnitude","flow","total","getFlowOriginId","entry","getFlowDestId","exit","getLocationCentroid","centroid","highlightedFlow","highlightedLocationId","locationId","highlightedLocationAreaId","onHover","e","info","PickingType","FLOW","_onHover","selectHighLight","LOCATION_AREA","LOCATION","defaultProps","value","handleFlowMapHover","selected","initialViewState","controller","mapboxApiAccessToken","process","mapStyle","_","style","position","background","padding","zIndex","pointerEvents","left","top","GTFContainer","props","setData","loaded","setLoaded","latitude","longitude","zoom","minZoom","maxZoom","maxBounds","setViewState","console","log","baseURL","calls","axios","get","all","then","response","Papa","parse","header","map","d","lon","lat","locationWithShape","forEach","ISO3","features","push","geometry","coordinates","result","parseFloat","App","test","url","component","GtfAnimatedFlow","path","exact","render","className","classes","Wrapper","PROJECTS","project","idx","Item","baseurl","C","status","styledClass","pending","done","href","Boolean","location","hostname","match","ReactDOM","StrictMode","document","getElementById","navigator","serviceWorker","ready","registration","unregister","catch","error","message"],"mappings":"6FACAA,EAAOC,QAAU,CAAC,QAAU,qBAAqB,QAAU,qBAAqB,KAAO,kBAAkB,SAAW,wB,6PCYpH,I,0BCRe,SAASC,EAAT,GAA6E,IAA9DC,EAA6D,EAA7DA,MAAOC,EAAsD,EAAtDA,OAAQC,EAA8C,EAA9CA,UAAWC,EAAmC,EAAnCA,OAAQC,EAA2B,EAA3BA,kBAAmBC,EAAQ,EAARA,KAAQ,EAElEC,IAA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gG,EAAT,GAAkD,IAAlCF,EAAiC,EAAjCA,QAASK,EAAwB,EAAxBA,OAAQf,EAAgB,EAAhBA,IAAKa,EAAW,EAAXA,QAChCG,EACS,YAAXD,EACIR,IAAQU,QAERV,IAAQW,KAGd,OACE,6BACE,mBAAGZ,UAAWU,EAAaG,KAAI,UAAKN,GAAL,OAAeb,GAA9C,SACGU,MAMT,IAAMD,EAAW,CACf,CACEM,OAAQ,OACRL,QAAS,iBACTV,IAAK,kBAEP,CACEe,OAAQ,OACRL,QAAS,kCACTV,IAAK,2BAEP,CACEe,OAAQ,OACRL,QAAS,6BACTV,IAAK,sBAEP,CACEe,OAAQ,OACRL,QAAS,uBACTV,IAAK,wBAEP,CACEe,OAAQ,OACRL,QAAS,2BACTV,IAAK,4BAEP,CACEe,OAAQ,OACRL,QAAS,0BACTV,IAAK,2BAEP,CACEe,OAAQ,UACRL,QAAS,aACTV,IAAK,2BAEP,CACEe,OAAQ,UACRL,QAAS,eACTV,IAAK,0B,OCvGWoB,QACW,cAA7B9G,OAAO+G,SAASC,UAEe,UAA7BhH,OAAO+G,SAASC,UAEhBhH,OAAO+G,SAASC,SAASC,MACvB,2DCZNC,IAASnB,OACP,cAAC,IAAMoB,WAAP,UACE,cAAC3B,EAAD,MAEF4B,SAASC,eAAe,SDyHpB,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrBlD,MAAK,SAAAmD,GACJA,EAAaC,gBAEdC,OAAM,SAAAC,GACL7D,QAAQ6D,MAAMA,EAAMC,c","file":"static/js/main.2ca4002f.chunk.js","sourcesContent":["// extracted by mini-css-extract-plugin\nmodule.exports = {\"Wrapper\":\"App_Wrapper__2FdRQ\",\"pending\":\"App_pending__1Acoy\",\"done\":\"App_done__Xh8fV\",\"progress\":\"App_progress__2NmV6\"};","import React, { useEffect, useState } from \"react\";\nimport Papa from \"papaparse\";\nimport { useMap, MapContainer, Map } from \"@iea/react-components\";\nimport axios from \"axios\";\nimport {\n borderPoints,\n getCountryColor,\n countryShape,\n getCountryInfo,\n getBorderPointInfo,\n getBorderPointCountriesColor,\n} from \"./util\";\n\nconst GtfVectorContainer = () => {\n const config = {\n map: \"oecd\",\n style: \"mapbox://styles/iea/ckas69pof1o2c1ioys10kqej6\",\n center: [0, 0],\n minZoom: 4.1,\n maxZoom: 7,\n maxBounds: [\n [-15, 23],\n [50, 65],\n ],\n };\n const { map, mapContainerRef, popUp } = useMap(config);\n const colors = [\n \"case\",\n \"#00CDB0\",\n \"#00B3C5\",\n \"#0076C0\",\n \"#0095CB\",\n \"#1355A3\",\n \"red\",\n ];\n const [data, setData] = useState({ borderPoints: null, countryShape: null });\n\n let baseURL = process.env.REACT_APP_DEV;\n if (process.env.NODE_ENV === \"production\")\n baseURL = process.env.REACT_APP_PROD;\n useEffect(() => {\n axios.get(`${baseURL}gtf/flowdata.csv`).then((response) => {\n const results = Papa.parse(response.data, { header: true }),\n data = [...results.data];\n setData({\n borderPoints: borderPoints(data),\n countryShape: countryShape(data),\n });\n });\n }, [baseURL]);\n\n useEffect(() => {\n if (!map) return;\n let borders = [\"solid-border\", \"dotted-border\"];\n\n for (let i in borders) {\n map\n .setPaintProperty(`${borders[i]}-layer`, \"line-color\", \"#404040\")\n .setPaintProperty(`${borders[i]}-layer`, \"line-width\", [\n \"interpolate\",\n [\"exponential\", 0.5],\n [\"zoom\"],\n config.minZoom,\n 0.5,\n config.maxZoom,\n 0.7,\n ]);\n }\n }, [map, config.minZoom, config.maxZoom]);\n\n useEffect(() => {\n if (!map || !data) return;\n const { borderPoints, countryShape } = data;\n\n // Define border points buffer animation\n let size = 100;\n let borderPointsBuffer = {\n width: size,\n height: size,\n data: new Uint8Array(size * size * 4),\n\n // get rendering context for the map canvas when layer is added to the map\n onAdd() {\n let canvas = document.createElement(\"canvas\");\n canvas.width = this.width;\n canvas.height = this.height;\n this.context = canvas.getContext(\"2d\");\n },\n\n // called once before every frame where the icon will be used\n render() {\n let duration = 1000;\n let t = (performance.now() % duration) / duration;\n let outerRadius = (size / 2) * t;\n let ctx = this.context;\n\n // draw outer circle\n ctx.clearRect(0, 0, this.width, this.height);\n ctx.beginPath();\n ctx.arc(this.width / 2, this.height / 2, outerRadius, 0, Math.PI * 2);\n ctx.fillStyle = \"rgba(255,255,0,\" + (1 - t) + \")\";\n ctx.fill();\n\n // update this image's data with data from the canvas\n this.data = ctx.getImageData(0, 0, this.width, this.height).data;\n map.triggerRepaint();\n return true;\n },\n };\n\n let borderpoints = {\n type: \"FeatureCollection\",\n features: borderPoints.map((point, idx) => ({\n type: \"Feature\",\n geometry: {\n type: \"Point\",\n coordinates: [point.lonlat[0], point.lonlat[1]],\n },\n id: idx,\n properties: {\n ...point,\n lonlat: point.lonlat,\n totalValue: point.totalValue,\n tx: point.tx,\n },\n })),\n };\n\n map // Add images for border points buffer\n .addImage(\"borderPointsBuffer\", borderPointsBuffer, { pixelRatio: 2 });\n\n map // Add source\n .addSource(\"border-points\", {\n type: \"geojson\",\n data: borderpoints,\n });\n\n map // Add layers\n .addLayer({\n id: \"border-point\",\n type: \"circle\",\n source: \"border-points\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": \"yellow\",\n },\n })\n .addLayer({\n id: \"border-point-buffers\",\n type: \"symbol\",\n source: \"border-points\",\n layout: {\n \"icon-image\": \"borderPointsBuffer\",\n \"icon-size\": [\n \"step\",\n [\"get\", \"totalValue\"],\n 0.3,\n 20000,\n 0.5,\n 100000,\n 0.7,\n 200000,\n 1,\n ],\n \"icon-allow-overlap\": true,\n },\n });\n\n let countries = [];\n countryShape.forEach((d) => countries.push(d.ISO3));\n map\n .setFilter(\"shapes-layer\", [\n \"all\",\n [\"match\", [\"get\", \"ISO3\"], countries, true, false],\n ])\n .setPaintProperty(\n \"shapes-layer\",\n \"fill-color\",\n getCountryColor(countryShape, colors)\n );\n\n return () => {\n console.log(\"CLEAR\");\n map\n .removeLayer(\"border-point\")\n .removeLayer(\"border-point-buffers\")\n .removeSource(\"border-points\")\n .removeImage(\"borderPointsBuffer\");\n };\n });\n\n useEffect(() => {\n if (!map) return;\n map\n .on(\"mousemove\", \"shapes-layer\", function (e) {\n map.getCanvas().style.cursor = \"pointer\";\n let mousePos = [e.lngLat.lng, e.lngLat.lat];\n let selected = e.features[0].properties.ISO3;\n while (Math.abs(e.lngLat.lng - mousePos[0]) > 180) {\n mousePos[0] += e.lngLat.lng > mousePos[0] ? 360 : -360;\n }\n popUp\n .setLngLat(mousePos)\n .setHTML(getCountryInfo(data.countryShape, selected))\n .addTo(map);\n })\n .on(\"mouseleave\", \"shapes-layer\", function () {\n map.getCanvas().style.cursor = \"\";\n popUp.remove();\n })\n .on(\"mousemove\", \"border-point\", function (e) {\n map.getCanvas().style.cursor = \"pointer\";\n let coordinates = e.features[0].geometry.coordinates;\n let selected = e.features[0].properties;\n popUp.addClassName(\"borderpoint\");\n popUp\n .setLngLat(coordinates)\n .setHTML(getBorderPointInfo(selected))\n .addTo(map);\n if (e.features.length > 0) {\n map.setPaintProperty(\n \"shapes-layer\",\n \"fill-color\",\n getBorderPointCountriesColor(e.features[0].properties.tx)\n );\n }\n })\n .on(\"mouseleave\", \"border-point\", function () {\n map.getCanvas().style.cursor = \"\";\n popUp.remove();\n map.setPaintProperty(\n \"shapes-layer\",\n \"fill-color\",\n getCountryColor(data.countryShape, colors)\n );\n });\n });\n\n return (\n
exit: {object.exit}
\n\t\t\t\t\t\tentry: {object.entry}
\n\t\t\t\t\t\tvalue: {object.total}
\n\t\t\t\t\t