Skip to content

Commit

Permalink
introduce threshold_bridge_jump_edges
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Commandeur committed Mar 27, 2019
1 parent 447018e commit 284656d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions resources/config_files/myconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ options:
building_radius_vertex_elevation: 3.0
radius_vertex_elevation: 1.0
threshold_jump_edges: 0.5
threshold_bridge_jump_edges: 0.5
3 changes: 2 additions & 1 deletion resources/config_files/myconfig_DEFAULTS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ input_elevation:
options:
building_radius_vertex_elevation: 3.0
radius_vertex_elevation: 1.0
threshold_jump_edges: 0.5
threshold_jump_edges: 0.5
threshold_bridge_jump_edges: 0.5
1 change: 1 addition & 0 deletions resources/config_files/myconfig_README.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ options: # Global options
building_radius_vertex_elevation: 3.0 # Radius in meters used for point-vertex distance between 3D points and vertices of building polygons, radius_vertex_elevation used when not specified
radius_vertex_elevation: 1.0 # Radius in meters used for point-vertex distance between 3D points and vertices of polygons
threshold_jump_edges: 0.5 # Threshold in meters for stitching adjacent objects, when the height difference is larger then the threshold a vertical wall is created
threshold_bridge_jump_edges: 0.5 # Threshold in meters for stitching bridges to adjacent objects, if not specified it falls back to threshold_jump_edges
extent: xmin, ymin, xmax, ymax # Filter the input polygons to this extent
9 changes: 7 additions & 2 deletions src/Map3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Map3d::Map3d() {
_radius_vertex_elevation = 1.0;
_building_radius_vertex_elevation = 3.0;
_threshold_jump_edges = 50;
_threshold_bridge_jump_edges = 50;
_requestedExtent = Box2(Point2(0, 0), Point2(0, 0));
_bbox = Box2(Point2(999999, 999999), Point2(-999999, -999999));
_minxradius = 999999;
Expand Down Expand Up @@ -83,6 +84,10 @@ void Map3d::set_threshold_jump_edges(float threshold) {
_threshold_jump_edges = int(threshold * 100);
}

void Map3d::set_threshold_bridge_jump_edges(float threshold) {
_threshold_bridge_jump_edges = int(threshold * 100);
}

void Map3d::set_building_include_floor(bool include) {
_building_include_floor = include;
}
Expand Down Expand Up @@ -1533,7 +1538,7 @@ void Map3d::stitch_bridges() {
pis.clear();
if (!(fadj->get_class() == BRIDGE && fadj->get_top_level()) && fadj->has_point2(ring[i], ringis, pis)) {
int z = fadj->get_vertex_elevation(ringis[0], pis[0]);
if (abs(f->get_vertex_elevation(ringi, i) - z) < _threshold_jump_edges) {
if (abs(f->get_vertex_elevation(ringi, i) - z) < _threshold_bridge_jump_edges) {
f->set_vertex_elevation(ringi, i, z);
if (!(fadj->get_class() == BRIDGE && fadj->get_top_level() == f->get_top_level())) {
// Add height to NC
Expand Down Expand Up @@ -1705,7 +1710,7 @@ void Map3d::stitch_bridges() {
int interz = interpolate_height(f, p, ringi, previ, ringi, endCorner.first);
int prevz = f->get_vertex_elevation(ringi, previ);
//Allways stich to lower object or if interpolated between corners within threshold or previous within threshold
if (stitchz < interz || abs(stitchz - interz) < _threshold_jump_edges || abs(stitchz - prevz) < _threshold_jump_edges) {
if (stitchz < interz || abs(stitchz - interz) < _threshold_bridge_jump_edges || abs(stitchz - prevz) < _threshold_bridge_jump_edges) {
f->set_vertex_elevation(ringi, pi, stitchz);
}
else {
Expand Down
2 changes: 2 additions & 0 deletions src/Map3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Map3d {
void set_radius_vertex_elevation(float radius);
void set_building_radius_vertex_elevation(float radius);
void set_threshold_jump_edges(float threshold);
void set_threshold_bridge_jump_edges(float threshold);
void set_requested_extent(double xmin, double ymin, double xmax, double ymax);

void add_allowed_las_class(AllowedLASTopo c, int i);
Expand Down Expand Up @@ -132,6 +133,7 @@ class Map3d {
float _radius_vertex_elevation;
float _building_radius_vertex_elevation;
int _threshold_jump_edges; //-- in cm/integer
int _threshold_bridge_jump_edges; //-- in cm/integer
Box2 _bbox;
double _minxradius;
double _maxxradius;
Expand Down
14 changes: 14 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ int main(int argc, const char * argv[]) {
map3d.set_building_radius_vertex_elevation(n["building_radius_vertex_elevation"].as<float>());
if (n["threshold_jump_edges"])
map3d.set_threshold_jump_edges(n["threshold_jump_edges"].as<float>());
if (n["threshold_bridge_jump_edges"])
map3d.set_threshold_bridge_jump_edges(n["threshold_bridge_jump_edges"].as<float>());
else if (n["threshold_jump_edges"]) // set threshold_jump_edges same for bridge
map3d.set_threshold_bridge_jump_edges(n["threshold_jump_edges"].as<float>());

if (n["stitching"] && n["stitching"].as<std::string>() == "false")
bStitching = false;

Expand Down Expand Up @@ -1143,6 +1148,15 @@ bool validate_yaml(const char* arg, std::set<std::string>& allowedFeatures) {
std::cerr << "\tOption 'options.threshold_jump_edges' invalid.\n";
}
}
if (n["threshold_bridge_jump_edges"]) {
try {
boost::lexical_cast<float>(n["threshold_bridge_jump_edges"].as<std::string>());
}
catch (boost::bad_lexical_cast& e) {
wentgood = false;
std::cerr << "\tOption 'options.threshold_bridge_jump_edges' invalid.\n";
}
}
if (n["stitching"]) {
std::string s = n["stitching"].as<std::string>();
if ((s != "true") && (s != "false")) {
Expand Down

0 comments on commit 284656d

Please sign in to comment.