Skip to content

Commit

Permalink
add check if a landuse/building type is in more than one category
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed Apr 17, 2024
1 parent 3a19203 commit f91323b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -10,4 +11,21 @@
*/
public interface LanduseDataConnectionCreator {
Map<String, List<String>> createLanduseDataConnection();

/**
* Counts the number of employee categories in which a type is represented.
*
* @return
*/
static int getNumberOfEmployeeCategoriesOfThisTyp(Map<String, List<String>> landuseCategoriesAndDataConnection, String type) {
AtomicInteger count = new AtomicInteger();
landuseCategoriesAndDataConnection.values().forEach(list -> {
if (list.contains(type)) {
count.getAndIncrement();
}
});
return count.get();
}

;
}

0 comments on commit f91323b

Please sign in to comment.