Skip to content

Commit

Permalink
Rework cutpoint to remove attributes on unrelated cutpoints type. Pre…
Browse files Browse the repository at this point in the history
…pare for export in json format
  • Loading branch information
nicolas-f committed Dec 5, 2024
1 parent 9ed58d5 commit e3dd0fb
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 386 deletions.
4 changes: 4 additions & 0 deletions noisemodelling-pathfinder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,22 +346,6 @@ private static List<Coordinate> computePts2D(List<CutPoint> pts) {
return pts2D;
}

/**
*
* @param sourceOrientation
* @param src
* @param next
* @return
*/
private static Orientation computeOrientation(Orientation sourceOrientation, Coordinate src, Coordinate next){
if(sourceOrientation == null) {
return null;
}
Vector3D outgoingRay = new Vector3D(new Coordinate(next.x - src.x,
next.y - src.y,
next.z - src.z)).normalize();
return Orientation.fromVector(Orientation.rotate(sourceOrientation, outgoingRay, true), 0);
}

/**
* Compute horizontal diffraction (diffraction of vertical edge.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,129 +9,56 @@

package org.noise_planet.noisemodelling.pathfinder.profilebuilder;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.locationtech.jts.geom.Coordinate;
import org.noise_planet.noisemodelling.pathfinder.path.MirrorReceiver;
import org.noise_planet.noisemodelling.pathfinder.utils.geometry.Orientation;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class CutPoint implements Comparable<CutPoint> {
/**
* On the vertical cut profile, this is one of the point
* This abstract class is implemented with specific attributes depending on the intersection object
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = CutPointSource.class, name = "Source"),
@JsonSubTypes.Type(value = CutPointReceiver.class, name = "Receiver"),
@JsonSubTypes.Type(value = CutPointWall.class, name = "Wall"),
@JsonSubTypes.Type(value = CutPointReflection.class, name = "Reflection"),
@JsonSubTypes.Type(value = CutPointGroundEffect.class, name = "GroundEffect"),
@JsonSubTypes.Type(value = CutPointTopography.class, name = "Topography"),
@JsonSubTypes.Type(value = CutPointVEdgeDiffraction.class, name = "VEdgeDiffraction")
})
public abstract class CutPoint implements Comparable<CutPoint> {
/** {@link Coordinate} of the cut point. */
public Coordinate coordinate = new Coordinate();
/** Intersection type. */
public ProfileBuilder.IntersectionType type;
/** Identifier of the cut element. */
public int id = -1;
/** Identifier of the building containing the point. -1 if no building. */
public int buildingId = -1;
/** Identifier of the wall containing the point. -1 if no wall. */
public int wallId = -1;

/** Topographic height of the point. */
public double zGround = Double.NaN;
/** Ground effect coefficient. 0 if there is no coefficient. */
public double groundCoef = Double.NaN;
/** Wall alpha. NaN if there is no coefficient. */
public List<Double> wallAlpha = Collections.emptyList();
/** Source line subdivision length (1.0 means a point is representing 1 meter of line sound source) */
public double li = 1.0;
/**
* Index of the object that reference the external data (not a temporary index in a subdomain)
*/
public long primaryKey;
/**
* Orientation of the point (should be about the source or receiver point)
* The orientation is related to the directivity associated to the object
*/
public Orientation orientation = new Orientation();

/** On reflection intersection type this object contain the associated reflection data */
public MirrorReceiver mirrorReceiver = null;

/**
* Constructor using a {@link Coordinate}.
* @param coord Coordinate to copy.
* @param type Intersection type.
* @param id Identifier of the cut element.
*/
public CutPoint(Coordinate coord, ProfileBuilder.IntersectionType type, int id) {
this.coordinate = new Coordinate(coord);
this.type = type;
this.id = id;
this.primaryKey = id;
}

public CutPoint() {
}

/**
* Copy constructor
* @param cut
*/
public CutPoint(CutPoint cut) {
this.coordinate = new Coordinate(cut.getCoordinate());
this.type = cut.type;
this.id = cut.id;
this.buildingId = cut.buildingId;
this.wallId = cut.wallId;
this.groundCoef = cut.groundCoef;
this.wallAlpha = new ArrayList<>(cut.wallAlpha);
this.zGround = cut.zGround;
this.mirrorReceiver = cut.mirrorReceiver;
}

/**
* @return On reflection intersection type this object contain the associated reflection data
*/
public MirrorReceiver getMirrorReceiver() {
return mirrorReceiver;
}

/**
* @param mirrorReceiver On reflection intersection type this object contain the associated reflection data
*/
public void setMirrorReceiver(MirrorReceiver mirrorReceiver) {
this.mirrorReceiver = mirrorReceiver;
}

public void setType(ProfileBuilder.IntersectionType type) {
this.type = type;
}

public void setId(int id) {
this.id = id;
}
* Ground effect coefficient.
* G=1.0 Soft, uncompacted ground (pasture, loose soil); snow etc
* G=0.7 Compacted soft ground (lawns, park areas):
* G=0.3 Compacted dense ground (gravel road, compacted soil):
* G=0.0 Hard surfaces (asphalt, concrete, top of buildings):
**/
public double groundCoefficient = Double.NaN;

public void setCoordinate(Coordinate coordinate) {
this.coordinate = coordinate;
}

/**
* Sets the id of the building containing the point.
* @param buildingId Id of the building containing the point.
*/
public void setBuildingId(int buildingId) {
this.buildingId = buildingId;
this.wallId = -1;
}

/**
* Sets the id of the wall containing the point.
* @param wallId Id of the wall containing the point.
*/
public void setWallId(int wallId) {
this.wallId = wallId;
this.buildingId = -1;
}

/**
* Sets the ground coefficient of this point.
* @param groundCoef The ground coefficient of this point.
* @param groundCoefficient The ground coefficient of this point.
*/
public void setGroundCoef(double groundCoef) {
this.groundCoef = groundCoef;
public void setGroundCoefficient(double groundCoefficient) {
this.groundCoefficient = groundCoefficient;
}

/**
Expand All @@ -142,13 +69,6 @@ public void setZGround(double zGround) {
this.zGround = zGround;
}

/**
* Sets the wall alpha.
* @param wallAlpha The wall alpha.
*/
public void setWallAlpha(List<Double> wallAlpha) {
this.wallAlpha = wallAlpha;
}

/**
* Retrieve the coordinate of the point.
Expand All @@ -158,36 +78,12 @@ public Coordinate getCoordinate(){
return coordinate;
}

/**
* Retrieve the identifier of the cut element.
* @return Identifier of the cut element.
*/
public int getId() {
return id;
}

/**
* Retrieve the identifier of the building containing the point. If no building, returns -1.
* @return Building identifier or -1
*/
public int getBuildingId() {
return buildingId;
}

/**
* Retrieve the identifier of the wall containing the point. If no wall, returns -1.
* @return Wall identifier or -1
*/
public int getWallId() {
return wallId;
}

/**
* Retrieve the ground effect coefficient of the point. If there is no coefficient, returns 0.
* @return Ground effect coefficient or NaN.
*/
public double getGroundCoef() {
return groundCoef;
public double getGroundCoefficient() {
return groundCoefficient;
}

/**
Expand All @@ -199,43 +95,21 @@ public Double getzGround() {
}

/**
* Return the wall alpha value.
* @return The wall alpha value.
*
* @param cutPoint the object to be compared.
* @return
*/
public List<Double> getWallAlpha() {
return wallAlpha;
}

public ProfileBuilder.IntersectionType getType() {
return type;
@Override
public int compareTo(CutPoint cutPoint) {
return this.coordinate.compareTo(cutPoint.coordinate);
}

@Override
public String toString() {
return "CutPoint{" +
"coordinate=" + coordinate +
", type=" + type +
", id=" + id +
", buildingId=" + buildingId +
", wallId=" + wallId +
", zGround=" + zGround +
", groundCoef=" + groundCoef +
", wallAlpha=" + wallAlpha +
", li=" + li +
", primaryKey=" + primaryKey +
", orientation=" + orientation +
(mirrorReceiver == null ? "" : ", mirrorReceiver=" + mirrorReceiver) +
", groundCoefficient=" + groundCoefficient +
'}';
}

/**
*
* @param cutPoint the object to be compared.
* @return
*/
@Override
public int compareTo(CutPoint cutPoint) {
return this.coordinate.compareTo(cutPoint.coordinate);
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use.
* <p>
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software.
* <p>
* Official webpage : http://noise-planet.org/noisemodelling.html
* Contact: [email protected]
*/


package org.noise_planet.noisemodelling.pathfinder.profilebuilder;

import org.locationtech.jts.geom.Coordinate;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use.
* <p>
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software.
* <p>
* Official webpage : http://noise-planet.org/noisemodelling.html
* Contact: [email protected]
*/
package org.noise_planet.noisemodelling.pathfinder.profilebuilder;

public class CutPointGroundEffect extends CutPoint {
/**
* Index of the object that reference the external data (not a temporary index in a subdomain)
*/
public long groundPolygonIndex = -1;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use.
* <p>
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software.
* <p>
* Official webpage : http://noise-planet.org/noisemodelling.html
* Contact: [email protected]
*/
package org.noise_planet.noisemodelling.pathfinder.profilebuilder;

public class CutPointReceiver extends CutPoint {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use.
* <p>
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software.
* <p>
* Official webpage : http://noise-planet.org/noisemodelling.html
* Contact: [email protected]
*/
package org.noise_planet.noisemodelling.pathfinder.profilebuilder;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.locationtech.jts.geom.LineSegment;

import java.util.Collections;
import java.util.List;

public class CutPointReflection extends CutPoint {
/**
* x,y,z coordinates of the top segment of the wall that reflect the vertical cut plane
* z is altitude
*/
public LineSegment wall;
/**
* Unique external identifier of the wall. Could be the primary key of the related building in the database
*/
public long wallPrimaryKey;

/**
* Obstacle index in the subdomain
* @see ProfileBuilder#processedWalls
*/
@JsonIgnore
public int obstacleIndex = -1;

/** Wall absorption coefficient per frequency band.*/
public List<Double> wallAlpha = Collections.emptyList();


/**
* Sets the wall alpha.
* @param wallAlpha The wall alpha.
*/
public void setWallAlpha(List<Double> wallAlpha) {
this.wallAlpha = wallAlpha;
}
}
Loading

0 comments on commit e3dd0fb

Please sign in to comment.