@@ -457,66 +457,6 @@ const ClimateMap = ({ onMount = () => true }) => {
457457 [ ] ,
458458 ) ;
459459
460- // Calculate average temperature for a region based on points within it
461- const calculateRegionTemperature = useCallback (
462- (
463- regionFeature : GeoJSON . Feature ,
464- temperatureData : TemperatureDataPoint [ ] ,
465- ) => {
466- const regionName =
467- regionFeature . properties ?. name ||
468- regionFeature . properties ?. name_en ||
469- regionFeature . properties ?. admin ||
470- "Unknown" ;
471-
472- const pointsInRegion = temperatureData . filter ( ( point ) => {
473- // Use turf.js for accurate point-in-polygon checking
474- const isInside = isPointInRegion (
475- point . lat ,
476- point . lng ,
477- regionFeature . geometry ,
478- ) ;
479- return isInside ;
480- } ) ;
481-
482- console . log (
483- `Region ${ regionName } : found ${ pointsInRegion . length } points within region` ,
484- ) ;
485-
486- // Debug: For first few regions, test with some sample points
487- if ( temperatureData . length > 0 ) {
488- const samplePoint = temperatureData [ 0 ] ;
489- const testResult = isPointInRegion (
490- samplePoint . lat ,
491- samplePoint . lng ,
492- regionFeature . geometry ,
493- ) ;
494- console . log (
495- `Region ${ regionName } : testing sample point (${ samplePoint . lat } , ${ samplePoint . lng } ) - inside: ${ testResult } ` ,
496- ) ;
497- }
498-
499- if ( pointsInRegion . length === 0 ) {
500- // Fallback: find nearest point
501- const nearestPoint = findNearestPoint ( regionFeature , temperatureData ) ;
502- console . log (
503- `Region ${ regionName } : using nearest point fallback, temp: ${ nearestPoint ? nearestPoint . temperature : "null" } ` ,
504- ) ;
505- return nearestPoint ? nearestPoint . temperature : null ;
506- }
507-
508- // Calculate average temperature
509- const avgTemp =
510- pointsInRegion . reduce ( ( sum , point ) => sum + point . temperature , 0 ) /
511- pointsInRegion . length ;
512- console . log (
513- `Region ${ regionName } : calculated average temp: ${ avgTemp } from ${ pointsInRegion . length } points` ,
514- ) ;
515- return avgTemp ;
516- } ,
517- [ ] ,
518- ) ;
519-
520460 // Calculate temperature and coordinate info for a region
521461 const calculateRegionTemperatureWithCoords = useCallback (
522462 (
0 commit comments