Skip to content

Commit

Permalink
fix D8 SpatialItem neighbor detection plus add working gradient :D
Browse files Browse the repository at this point in the history
  • Loading branch information
svencc committed Mar 11, 2024
1 parent 332b516 commit 4060833
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ private int calculateForestFragment(

int surroundingForestNeighbourSpaces = 0;
for (int direction = 0; direction < 8; direction++) {
final double adjacentNeighborSpatialX = spacialX + (D8AspectMatrix.directionXComponentMatrix[direction] * demDescriptor.getStepSize()); // Calculate the X-coordinate of the adjacent neighbor.
final double adjacentNeighborSpatialY = spacialY + (D8AspectMatrix.directionYComponentMatrix[direction] * demDescriptor.getStepSize()); // Calculate the Y-coordinate of the adjacent neighbor.
final double adjacentNeighborSpatialX = spacialX + (D8AspectMatrix.directionXComponentMatrix[direction] * spacialIndex.getCellSizeInMeter()); // Calculate the X-coordinate of the adjacent neighbor.
final double adjacentNeighborSpatialY = spacialY + (D8AspectMatrix.directionYComponentMatrix[direction] * spacialIndex.getCellSizeInMeter()); // Calculate the Y-coordinate of the adjacent neighbor.

if (adjacentNeighborSpatialX < 0 || adjacentNeighborSpatialX > demDescriptor.getMapWidthInMeter() || adjacentNeighborSpatialY < 0 || adjacentNeighborSpatialY > demDescriptor.getMapHeightInMeter()) {
continue;
Expand All @@ -83,7 +83,7 @@ private int calculateForestFragment(
} else if (treeDensity >= forestDensityThreshold && surroundingForestNeighbourSpaces >= 5) {
return mapScheme.getBaseColorForest();
} else {
return colorCalculator.modifyTransparency(mapScheme.getBaseColorForest(), 0.5);
return colorCalculator.modifyTransparency(mapScheme.getBaseColorForest(), surroundingForestNeighbourSpaces * 0.1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ private int calculateStructureFragment(

int surroundingStructureNeighbourSpaces = 0;
for (int direction = 0; direction < 8; direction++) {
final double adjacentNeighborSpatialX = spacialX + (D8AspectMatrix.directionXComponentMatrix[direction] * demDescriptor.getStepSize()); // Calculate the X-coordinate of the adjacent neighbor.
final double adjacentNeighborSpatialY = spacialY + (D8AspectMatrix.directionYComponentMatrix[direction] * demDescriptor.getStepSize()); // Calculate the Y-coordinate of the adjacent neighbor.
final double adjacentNeighborSpatialX = spacialX + (D8AspectMatrix.directionXComponentMatrix[direction] * spacialIndex.getCellSizeInMeter()); // Calculate the X-coordinate of the adjacent neighbor.
final double adjacentNeighborSpatialY = spacialY + (D8AspectMatrix.directionYComponentMatrix[direction] * spacialIndex.getCellSizeInMeter()); // Calculate the Y-coordinate of the adjacent neighbor.

if (adjacentNeighborSpatialX < 0 || adjacentNeighborSpatialX > demDescriptor.getMapWidthInMeter() || adjacentNeighborSpatialY < 0 || adjacentNeighborSpatialY > demDescriptor.getMapHeightInMeter()) {
continue;
Expand All @@ -83,7 +83,7 @@ private int calculateStructureFragment(
} else if (StructureDensity >= structureDensityThreshold && surroundingStructureNeighbourSpaces >= 5) {
return mapScheme.getBaseColorStructure();
} else {
return colorCalculator.modifyTransparency(mapScheme.getBaseColorStructure(), 0.5);
return colorCalculator.modifyTransparency(mapScheme.getBaseColorStructure(), surroundingStructureNeighbourSpaces * 0.1);
}
}

Expand Down

0 comments on commit 4060833

Please sign in to comment.