Skip to content

Commit

Permalink
Recommended Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AKATWIJUKA-ELIA committed Feb 19, 2025
1 parent 1a657e7 commit 041591c
Show file tree
Hide file tree
Showing 4 changed files with 23,192 additions and 8,269 deletions.
37 changes: 2 additions & 35 deletions netmanager-app/components/NetManagerMap/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useRef, useState } from 'react'
import { Input } from '../ui/input'
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
import { ConvertToGeojson } from '@/lib/utils';

const NetManagerMap = () => {

Expand Down Expand Up @@ -157,10 +158,6 @@ const NetManagerMap = () => {
}
}
});
}{
<div>
Loading Data
</div>
}
}, []);

Expand Down Expand Up @@ -235,37 +232,7 @@ const NetManagerMap = () => {
.catch(error => console.error("Error fetching location:", error));

}
const ConvertToGeojson=(data: any)=>{
return {
type: "FeatureCollection" as const,
features: data.measurements.map((item: any) => ({
type: "Feature",
geometry: {
type: "Point",
coordinates: [
item.siteDetails.approximate_longitude,
item.siteDetails.approximate_latitude
]
},
properties: {
id: item._id,
site_id:item.site_id,
time: new Date(item.time).toLocaleDateString("en-US", {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric"
}),
location_name:item.siteDetails.name,
aqi_category: item.aqi_category,
aqi_color:item.aqi_color.startsWith("#") ? item.aqi_color : `#${item.aqi_color}`,
value:item.pm2_5 ?.value??0,
}
}))
}


}


return (
<div className="flex flex-col-reverse md:flex md:flex-row min-h-screen md:h-screen -ml-5 ">
Expand Down
32 changes: 32 additions & 0 deletions netmanager-app/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,35 @@ export const transformDataToGeoJson = (
features,
};
};

export const ConvertToGeojson=(data: any)=>{
return {
type: "FeatureCollection" as const,
features: data.measurements.map((item: any) => ({
type: "Feature",
geometry: {
type: "Point",
coordinates: [
item.siteDetails.approximate_longitude,
item.siteDetails.approximate_latitude
]
},
properties: {
id: item._id,
site_id:item.site_id,
time: new Date(item.time).toLocaleDateString("en-US", {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric"
}),
location_name:item.siteDetails.name,
aqi_category: item.aqi_category,
aqi_color:item.aqi_color.startsWith("#") ? item.aqi_color : `#${item.aqi_color}`,
value:item.pm2_5 ?.value??0,
}
}))
}


}
Loading

0 comments on commit 041591c

Please sign in to comment.