Skip to content

Commit 6727688

Browse files
committed
Use key to avoid data going out of date issues, with the first feature in the GeoJSON' intensity used as the key.
1 parent ff3c058 commit 6727688

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

frontend/src/component/Mapper/ClimateMap.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as turf from "@turf/turf";
22
import { Modal } from "antd";
3-
import { useCallback, useEffect, useRef, useState } from "react";
3+
import { useCallback, useEffect, useState } from "react";
44
import { GeoJSON, MapContainer, Pane } from "react-leaflet";
55
import "leaflet/dist/leaflet.css";
66
import L from "leaflet";
@@ -883,7 +883,7 @@ const ClimateMap = ({ onMount = () => true }) => {
883883
`DEBUGYEARCHANGE: Temperature data length: ${temperatureData.length}`,
884884
);
885885
console.log(
886-
`DEBUGYEARCHANGE: First temperature point:`,
886+
"DEBUGYEARCHANGE: First temperature point:",
887887
temperatureData[0],
888888
);
889889

@@ -901,9 +901,9 @@ const ClimateMap = ({ onMount = () => true }) => {
901901
console.log(
902902
`DEBUGYEARCHANGE: NUTS features count: ${nutsGeoJSON.features.length}`,
903903
);
904-
console.log(`DEBUGYEARCHANGE: NUTS extremes:`, extremes);
904+
console.log("DEBUGYEARCHANGE: NUTS extremes:", extremes);
905905
console.log(
906-
`DEBUGYEARCHANGE: First NUTS feature:`,
906+
"DEBUGYEARCHANGE: First NUTS feature:",
907907
nutsGeoJSON.features[0],
908908
);
909909

@@ -951,9 +951,10 @@ const ClimateMap = ({ onMount = () => true }) => {
951951
worldwideRegionsGeoJSON,
952952
processingError,
953953
loadworldwideRegions,
954-
calculateRegionTemperature,
954+
calculateRegionTemperatureWithCoords,
955955
isPointInRegion,
956956
sampleTemperatureData,
957+
currentYear,
957958
]);
958959

959960
// Cleanup timeouts on unmount

frontend/src/component/Mapper/utilities/GridToNutsConverter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export class GridToNutsConverter {
9090
return index;
9191
}
9292

93-
private getPolygonBounds(polygon: any): {
93+
private getPolygonBounds(
94+
polygon: turf.Feature<turf.Polygon | turf.MultiPolygon>,
95+
): {
9496
minLat: number;
9597
maxLat: number;
9698
minLng: number;
@@ -205,7 +207,9 @@ export class GridToNutsConverter {
205207
return nearestPoint;
206208
}
207209

208-
private createPolygonFromFeature(feature: GeoJSONFeature): any {
210+
private createPolygonFromFeature(
211+
feature: GeoJSONFeature,
212+
): turf.Feature<turf.Polygon | turf.MultiPolygon> | null {
209213
try {
210214
if (feature.geometry?.type === "Polygon") {
211215
return turf.polygon((feature.geometry as Polygon).coordinates);

0 commit comments

Comments
 (0)