From f91323b0c4c2be0428b64df521dc1739a4a4e307 Mon Sep 17 00:00:00 2001 From: Ricardo Ewert Date: Wed, 17 Apr 2024 14:29:11 +0200 Subject: [PATCH] add check if a landuse/building type is in more than one category --- .../prepare/LanduseBuildingAnalysis.java | 6 ++---- .../prepare/LanduseDataConnectionCreator.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java index dbc1fde1a30..d26f95bde07 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java @@ -120,10 +120,8 @@ private static void createResultingDataForLanduseInZones( resultingDataPerZone.get(zoneId).mergeDouble(categoryData, 0., Double::sum); if (landuseCategoriesAndDataConnection.get(categoryData).contains(categoryLanduse)) { double additionalArea = landuseCategoriesPerZone.get(zoneId).getDouble(categoryLanduse); - // because the category commercial is in two categories (traffic/parcels and - // Tertiary Sector Rest - if (categoryLanduse.equals("commercial")) - additionalArea = additionalArea * 0.5; +// // because the categoryLanduse can be in two categories (e.g., traffic/parcels and Tertiary Sector Rest + additionalArea = additionalArea / LanduseDataConnectionCreator.getNumberOfEmployeeCategoriesOfThisTyp(landuseCategoriesAndDataConnection, categoryLanduse); resultingDataPerZone.get(zoneId).mergeDouble(categoryData, additionalArea, Double::sum); totalSquareMetersPerCategory.get(regionOfZone).mergeDouble(categoryData, additionalArea, Double::sum); diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseDataConnectionCreator.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseDataConnectionCreator.java index 9a66eac4572..63f21ef31c9 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseDataConnectionCreator.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseDataConnectionCreator.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** * Interface for creating the connection between landuse categories and the employee data. @@ -10,4 +11,21 @@ */ public interface LanduseDataConnectionCreator { Map> createLanduseDataConnection(); + + /** + * Counts the number of employee categories in which a type is represented. + * + * @return + */ + static int getNumberOfEmployeeCategoriesOfThisTyp(Map> landuseCategoriesAndDataConnection, String type) { + AtomicInteger count = new AtomicInteger(); + landuseCategoriesAndDataConnection.values().forEach(list -> { + if (list.contains(type)) { + count.getAndIncrement(); + } + }); + return count.get(); + } + + ; }