diff --git a/src/components/modal/count/Count.tsx b/src/components/modal/count/Count.tsx index 9b2e2ab96dd81fb77b4a5924d7038dcb5c5009f4..40766b24f8807a58e259d6bc0a816f99b2a2d2cc 100644 --- a/src/components/modal/count/Count.tsx +++ b/src/components/modal/count/Count.tsx @@ -4,7 +4,7 @@ import React, { FC, useState, useEffect } from 'react' import { Button, Icon } from '@commonground/design-system' -import type { Feature, Polygon, FeatureCollection, Geometry } from 'geojson' +import type { FeatureCollection, Geometry } from 'geojson' import { getTotals } from '../../../services/count/services/get-total' import { getVerblijfsobjectDocument } from '../../../services/count/get-verblijfsobject-count' @@ -149,12 +149,13 @@ export const Count: FC = () => { )} - {activeDataLayers[0].id !== 'layerDook100' && ( - - {totaalVerblijfsObject.toLocaleString('nl-NL')} - Verblijfsobjecten - - )} + {activeDataLayers[0].id !== 'layerDook100' && + activeDataLayers[0].id !== 'layerReferenceUse' && ( + + {totaalVerblijfsObject.toLocaleString('nl-NL')} + Verblijfsobjecten + + )} {config.product === 'DEGO' && ( diff --git a/src/components/modal/count/GetCountClient.tsx b/src/components/modal/count/GetCountClient.tsx index 8cf2a57c0de7106ad429a5aae244cabdddd43809..998bb2eb18d7164dab029b61b8ed3cf4333e1e41 100644 --- a/src/components/modal/count/GetCountClient.tsx +++ b/src/components/modal/count/GetCountClient.tsx @@ -18,11 +18,11 @@ interface GetCountClientProps { layerId: string } -export const GetCountClient: FC = ({ +export const GetCountClient = ({ map, featureCollection, layerId, -}) => { +}: GetCountClientProps) => { const [results, setResults] = useState([]) useEffect(() => { @@ -54,6 +54,41 @@ export const GetCountClient: FC = ({ }, []) const totalGJArray = results.map((item) => item.properties.totaal_gj) + const VboAfter1946Array = results.map((item) => + item.properties.bouwjaar >= 1946 + ? item.properties.aantal_verblijfsobjecten + : 0 + ) + const VboBefore1946Array = results.map((item) => + item.properties.bouwjaar < 1946 + ? item.properties.aantal_verblijfsobjecten + : 0 + ) + + // Calculate total for totaal_gj + const totalGj = + totalGJArray.length > 0 + ? (Math.round(totalGJArray.reduce((sum, val) => sum + val, 0)) * 100) / + 100 + : 0 + + // Calculate total VBO count for bouwjaar after 1946 + const totalCountVboAfter1946 = + VboAfter1946Array.length > 0 + ? (Math.round(VboAfter1946Array.reduce((sum, val) => sum + val, 0)) * + 100) / + 100 + : 0 + + // Calculate total VBO count for bouwjaar before 1946 + const totalCountVboBefore1946 = + VboBefore1946Array.length > 0 + ? (Math.round(VboBefore1946Array.reduce((sum, val) => sum + val, 0)) * + 100) / + 100 + : 0 + + // Calculate average for totaal_gj const avgGJ = totalGJArray.length > 0 ? Math.round( @@ -63,58 +98,49 @@ export const GetCountClient: FC = ({ ) / 100 : 0 - // Calculate average for koken_gj + // Calculate total for koken_gj const kokenGJArray = results.map((item) => item.properties.koken_gj) - const avgKokenGJ = + + const totalKokenGJ = kokenGJArray.length > 0 - ? Math.round( - (kokenGJArray.reduce((sum, val) => sum + val, 0) / - kokenGJArray.length) * - 100 - ) / 100 + ? Math.round(kokenGJArray.reduce((sum, val) => sum + val, 0) * 100) / 100 : 0 - // Calculate average for ruimteverwarming_gj + // Calculate total for ruimteverwarming_gj const ruimteverwarmingGJArray = results.map( (item) => item.properties.ruimteverwarming_gj ) - const avgRuimteverwarmingGJ = + const totalRuimteverwarmingGJ = ruimteverwarmingGJArray.length > 0 ? Math.round( - (ruimteverwarmingGJArray.reduce((sum, val) => sum + val, 0) / - ruimteverwarmingGJArray.length) * - 100 + ruimteverwarmingGJArray.reduce((sum, val) => sum + val, 0) * 100 ) / 100 : 0 - // Calculate average for warm_tapwater_gj + // Calculate total for warm_tapwater_gj const warmTapwaterGJArray = results.map( (item) => item.properties.warm_tapwater_gj ) - const avgWarmTapwaterGJ = + const totalWarmTapwaterGJ = warmTapwaterGJArray.length > 0 ? Math.round( - (warmTapwaterGJArray.reduce((sum, val) => sum + val, 0) / - warmTapwaterGJArray.length) * - 100 + warmTapwaterGJArray.reduce((sum, val) => sum + val, 0) * 100 ) / 100 : 0 const graphData = [ - { key: 'V', value: avgRuimteverwarmingGJ }, - { key: 'T', value: avgWarmTapwaterGJ }, - { key: 'K', value: avgKokenGJ }, + { key: 'V', value: totalRuimteverwarmingGJ }, + { key: 'T', value: totalWarmTapwaterGJ }, + { key: 'K', value: totalKokenGJ }, ] return (
- Gemiddeld referentieverbruik verblijfsobjecten:{' '} - {Math.floor(avgGJ)} GJ + Totaal geschatte warmtevraag verblijfsobjecten:{' '} + {Math.floor(totalGj)} GJ
- {/* - Gemiddeld energieverbruik over {results.length} panden: {avgGJ} - */} +
{Array.isArray(graphData) && graphData.length > 0 && ( = ({ aandeel koken
+
+ Gemiddeld geschatte warmtevraag per verblijfsobject:{' '} + {Math.floor(avgGJ)} GJ +
+
+ Aantal verblijfsobjecten:{' '} + {(totalCountVboBefore1946 + totalCountVboAfter1946)} +
+
+ Aandeel verblijfsobjecten met bouwjaar voor 1946:{' '} + + {Math.floor( + (totalCountVboBefore1946 / + (totalCountVboBefore1946 + totalCountVboAfter1946)) * + 100 + )} + % + +
) }