From 284656d97b19e15c4db7d0dc948094c310782d92 Mon Sep 17 00:00:00 2001 From: Tom Commandeur Date: Wed, 27 Mar 2019 11:50:26 +0100 Subject: [PATCH] introduce threshold_bridge_jump_edges --- resources/config_files/myconfig.yml | 1 + resources/config_files/myconfig_DEFAULTS.yml | 3 ++- resources/config_files/myconfig_README.yml | 1 + src/Map3d.cpp | 9 +++++++-- src/Map3d.h | 2 ++ src/main.cpp | 14 ++++++++++++++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/resources/config_files/myconfig.yml b/resources/config_files/myconfig.yml index 6f8de9eb..8eb99a64 100644 --- a/resources/config_files/myconfig.yml +++ b/resources/config_files/myconfig.yml @@ -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 diff --git a/resources/config_files/myconfig_DEFAULTS.yml b/resources/config_files/myconfig_DEFAULTS.yml index d1704132..9fd1c091 100644 --- a/resources/config_files/myconfig_DEFAULTS.yml +++ b/resources/config_files/myconfig_DEFAULTS.yml @@ -36,4 +36,5 @@ input_elevation: options: building_radius_vertex_elevation: 3.0 radius_vertex_elevation: 1.0 - threshold_jump_edges: 0.5 \ No newline at end of file + threshold_jump_edges: 0.5 + threshold_bridge_jump_edges: 0.5 \ No newline at end of file diff --git a/resources/config_files/myconfig_README.yml b/resources/config_files/myconfig_README.yml index d7fa1ff1..f3dcc8df 100644 --- a/resources/config_files/myconfig_README.yml +++ b/resources/config_files/myconfig_README.yml @@ -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 diff --git a/src/Map3d.cpp b/src/Map3d.cpp index 0a557379..f41aed65 100644 --- a/src/Map3d.cpp +++ b/src/Map3d.cpp @@ -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; @@ -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; } @@ -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 @@ -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 { diff --git a/src/Map3d.h b/src/Map3d.h index 1e5a03fb..1c720596 100644 --- a/src/Map3d.h +++ b/src/Map3d.h @@ -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); @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 0ae47216..438ff26b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -351,6 +351,11 @@ int main(int argc, const char * argv[]) { map3d.set_building_radius_vertex_elevation(n["building_radius_vertex_elevation"].as()); if (n["threshold_jump_edges"]) map3d.set_threshold_jump_edges(n["threshold_jump_edges"].as()); + if (n["threshold_bridge_jump_edges"]) + map3d.set_threshold_bridge_jump_edges(n["threshold_bridge_jump_edges"].as()); + else if (n["threshold_jump_edges"]) // set threshold_jump_edges same for bridge + map3d.set_threshold_bridge_jump_edges(n["threshold_jump_edges"].as()); + if (n["stitching"] && n["stitching"].as() == "false") bStitching = false; @@ -1143,6 +1148,15 @@ bool validate_yaml(const char* arg, std::set& allowedFeatures) { std::cerr << "\tOption 'options.threshold_jump_edges' invalid.\n"; } } + if (n["threshold_bridge_jump_edges"]) { + try { + boost::lexical_cast(n["threshold_bridge_jump_edges"].as()); + } + 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(); if ((s != "true") && (s != "false")) {