Skip to content

Commit

Permalink
Merge pull request #19 from JacobNiyazov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
JacobNiyazov authored Dec 17, 2023
2 parents c3455d4 + 1ba11b6 commit 6a832aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/components/EditSidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const EditSidePanel = ({

function isNumeric(str) {
if (typeof str != "string") return false
if (str === "" || str.charCodeAt(0) === 8) return true;
if (str === "" || str === "-" || str === "." || str.charCodeAt(0) === 8) return true;

return !isNaN(str) &&
!isNaN(parseFloat(str))
Expand Down
21 changes: 13 additions & 8 deletions client/src/components/HeatMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const HeatMap = ({
const storeRef = useRef(store);
const map = useMap();

const geojsonData = storeRef.current.currentMap.graphics.geojson;
//const geojsonData = storeRef.current.currentMap.graphics.geojson;
const property = storeRef.current.currentMap.graphics.typeSpecific.property;
const low = storeRef.current.currentMap.graphics.typeSpecific.lowGradient;
const med = storeRef.current.currentMap.graphics.typeSpecific.mediumGradient;
const high = storeRef.current.currentMap.graphics.typeSpecific.highGradient;
//const low = storeRef.current.currentMap.graphics.typeSpecific.lowGradient;
//const med = storeRef.current.currentMap.graphics.typeSpecific.mediumGradient;
//const high = storeRef.current.currentMap.graphics.typeSpecific.highGradient;
useEffect(() => {
const regionLayerGroup = L.featureGroup().addTo(map);
const updateLayers = (geojsonData) => {
Expand All @@ -36,6 +36,7 @@ const HeatMap = ({
L.geoJSON(geojsonData, {
onEachFeature: function (feature, layer) {
if(feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon'){
console.log("what in the world is stroke and fill", hasStroke, hasFill)
layer.setStyle({
stroke: hasStroke,
color: colors.StrokeColor,
Expand Down Expand Up @@ -87,11 +88,13 @@ const HeatMap = ({
};

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, storeRef, colors, sizes, opacities, hasStroke, hasFill, textFont]);
}, [map, storeRef, store.currentMap.graphics.geojson, colors, sizes, opacities, hasStroke, hasFill, textFont]);

useEffect(() => {
// Extract coordinates and create a heat map layer
// Helper function to extract coordinates from a Polygon based on a property
const extractCoordsFromFeature = (feature, property,props) => {
const geojsonData = store.currentMap.graphics.geojson;
const extractCoordsFromFeature = (feature, property,props) => {
const propertyValue = feature.properties[property];

// Skip features without the selected property or with non-numeric property values
Expand Down Expand Up @@ -134,7 +137,9 @@ const HeatMap = ({
}
// have to do the store update local map here
store.updateLocalMap(null, null, null, null, null, colors.lowGradient, colors.mediumGradient, colors.highGradient)
if(low === null|| med === null|| high === null){
if(storeRef.current.currentMap.graphics.typeSpecific.lowGradient === null||
storeRef.current.currentMap.graphics.typeSpecific.mediumGradient === null||
storeRef.current.currentMap.graphics.typeSpecific.highGradient === null){
storeRef.current.updateMapGraphics(null, null, null, null, null, null, null, null, colors.lowGradient, colors.mediumGradient, colors.highGradient)
}
};
Expand All @@ -153,7 +158,7 @@ const HeatMap = ({
map.off('click')
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [geojsonData, map, property, colors.lowGradient, colors.mediumGradient, colors.highGradient, colors, low, med, high]);
}, [map, store.currentMap.graphics.geojson, colors.lowGradient, colors.mediumGradient, colors.highGradient]);

// Helper function to extract coordinates from a Polygon
const extractCoordsFromPolygon = (polygonCoords, intensity) => {
Expand Down
7 changes: 6 additions & 1 deletion server/controllers/map-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ createMap = async (req,res) =>{
})
}
}

if(Buffer.byteLength(JSON.stringify(geojsonData)) > 15000000){
return res.status(400).json({
success:false,
errorMessage: 'Map Not Created. File Size too big.'
})
}
let nativeFile = {}
if(body.mapType === "Native File"){
nativeFile = JSON.parse(JSON.stringify(geojsonData));
Expand Down

0 comments on commit 6a832aa

Please sign in to comment.