Skip to content

Commit

Permalink
pts2DGround should not return topographic points under the building p…
Browse files Browse the repository at this point in the history
…olygon
  • Loading branch information
nicolas-f committed Oct 23, 2024
1 parent f4c00ed commit e6f8ac7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,35 @@ private static List<Coordinate> computePts2D(List<CutPoint> pts) {
* @return the computed coordinate list
*/
List<Coordinate> computePts2DGround(CutProfile cutProfile, Scene data) {
List<Coordinate> pts2D= cutProfile.getCutPoints().stream()
.filter(cut -> cut.getType() != GROUND_EFFECT)
.map(cut -> BUILDING.equals(cut.getType()) || WALL.equals(cut.getType()) ?
new Coordinate(cut.getCoordinate().x, cut.getCoordinate().y, cut.getCoordinate().z)
: new Coordinate(cut.getCoordinate().x, cut.getCoordinate().y, cut.getzGround())
)
.collect(Collectors.toList());
List<Coordinate> pts2D = new ArrayList<>(cutProfile.getCutPoints().size());
if(cutProfile.getCutPoints().isEmpty()) {
return pts2D;
}
// keep track of the obstacle under our current position. If -1 there is only ground below
int overObstacleIndex = cutProfile.getCutPoints().get(0).getBuildingId();
for (CutPoint cut : cutProfile.getCutPoints()) {
if (cut.getType() != GROUND_EFFECT) {
Coordinate coordinate;
if (BUILDING.equals(cut.getType()) || WALL.equals(cut.getType())) {
if(Double.compare(cut.getCoordinate().z, cut.getzGround()) == 0) {
// current position is at the ground level in front of or behind the first/last wall
if(overObstacleIndex == -1) {
overObstacleIndex = cut.getId();
} else {
overObstacleIndex = -1;
}
}
// Take the obstacle altitude instead of the ground level
coordinate = new Coordinate(cut.getCoordinate().x, cut.getCoordinate().y, cut.getCoordinate().z);
} else {
coordinate = new Coordinate(cut.getCoordinate().x, cut.getCoordinate().y, cut.getzGround());
}
// we will ignore topographic point if we are over a building
if(!(overObstacleIndex >= 0 && TOPOGRAPHY.equals(cut.getType()))) {
pts2D.add(coordinate);
}
}
}
return JTSUtility.getNewCoordinateSystem(pts2D);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ public void TC08() {
List<Coordinate> expectedZ_profile = new ArrayList<>();
expectedZ_profile.add(new Coordinate(0.00, 0.00));
expectedZ_profile.add(new Coordinate(170.49, 0.00));
expectedZ_profile.add(new Coordinate(170.49, 6.00));
expectedZ_profile.add(new Coordinate(170.49, 0.00));
expectedZ_profile.add(new Coordinate(194.16, 0.00));

/* Table 42 */
Expand Down Expand Up @@ -592,6 +594,8 @@ public void TC09() {
expectedZ_profile.add(new Coordinate(0.00, 0.00));
expectedZ_profile.add(new Coordinate(112.41, 0.00));
expectedZ_profile.add(new Coordinate(170.49, 8.74));
expectedZ_profile.add(new Coordinate(170.49, 16.63));
expectedZ_profile.add(new Coordinate(170.49, 8.74));
expectedZ_profile.add(new Coordinate(178.84, 10.00));
expectedZ_profile.add(new Coordinate(194.16, 10.00));

Expand Down Expand Up @@ -675,6 +679,8 @@ public void TC10() {
List<Coordinate> expectedZ_profile = new ArrayList<>();
expectedZ_profile.add(new Coordinate(0.00, 0.00));
expectedZ_profile.add(new Coordinate(5, 0.00));
expectedZ_profile.add(new Coordinate(5, 10.00));
expectedZ_profile.add(new Coordinate(15, 10));
expectedZ_profile.add(new Coordinate(15, 0));
expectedZ_profile.add(new Coordinate(20, 0));

Expand Down Expand Up @@ -754,6 +760,8 @@ public void TC11() {
List<Coordinate> expectedZ_profile = new ArrayList<>();
expectedZ_profile.add(new Coordinate(0.00, 0.00));
expectedZ_profile.add(new Coordinate(5, 0.00));
expectedZ_profile.add(new Coordinate(5, 10.00));
expectedZ_profile.add(new Coordinate(15, 10.00));
expectedZ_profile.add(new Coordinate(15, 0));
expectedZ_profile.add(new Coordinate(20, 0));

Expand Down Expand Up @@ -831,6 +839,8 @@ public void TC12() {
List<Coordinate> expectedZ_profile = new ArrayList<>();
expectedZ_profile.add(new Coordinate(0.00, 0.00));
expectedZ_profile.add(new Coordinate(12.26, 0.00));
expectedZ_profile.add(new Coordinate(12.26, 10.00));
expectedZ_profile.add(new Coordinate(18.82, 10));
expectedZ_profile.add(new Coordinate(18.82, 0));
expectedZ_profile.add(new Coordinate(31.62, 0));

Expand Down Expand Up @@ -915,7 +925,8 @@ public void TC13() {
expectedZ_profile.add(new Coordinate(0.00, 0.00));
expectedZ_profile.add(new Coordinate(112.41, 0.00));
expectedZ_profile.add(new Coordinate(164.07, 7.8));
expectedZ_profile.add(new Coordinate(178.83, 10));
expectedZ_profile.add(new Coordinate(164.07, 30.00));
expectedZ_profile.add(new Coordinate(181.83, 30));
expectedZ_profile.add(new Coordinate(181.83, 10));
expectedZ_profile.add(new Coordinate(194.16, 10));

Expand Down

0 comments on commit e6f8ac7

Please sign in to comment.