Skip to content

Commit

Permalink
Small fix in handling of vertices without heights
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Commandeur committed Oct 26, 2016
1 parent 86b4d37 commit e6d1c59
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions TopoFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ void TopoFeature::lift_each_boundary_vertices(float percentile) {
}
ringi++;
auto irings = bg::interior_rings(*(_p2));
for (Ring2& iring: irings) {
for (Ring2& iring : irings) {
for (int i = 0; i < iring.size(); i++) {
std::vector<int> &l = _lidarelevs[ringi][i];
if (l.empty() == true)
Expand All @@ -790,38 +790,39 @@ void TopoFeature::lift_each_boundary_vertices(float percentile) {
}
//-- 2. find average height of the polygon
double totalheight = 0.0;
int noheight = 0;
int heightcount = 0;
oring = bg::exterior_ring(*(_p2));
for (int i = 0; i < oring.size(); i++) {
if (_p2z[0][i] != -9999) {
totalheight += double(_p2z[0][i]);
noheight += 1;
heightcount += 1;
}
}
int avgheight;
if (noheight > 0) {
avgheight = int(totalheight / double(noheight));
// std::clog << "avg height: " << avgheight << std::endl;
// std::clog << "no height " << noheight << std::endl;

//-- 3. some vertices will have no values (no lidar point within tolerance thus)
//-- assign them the avg
ringi = 0;
oring = bg::exterior_ring(*(_p2));
int pi;
for (int i = 0; i < oring.size(); i++) {
if (heightcount > 0)
avgheight = int(totalheight / double(heightcount));
else
avgheight = 0;
// std::clog << "avg height: " << avgheight << std::endl;
// std::clog << "height count " << heightcount << std::endl;

//-- 3. some vertices will have no values (no lidar point within tolerance thus)
//-- assign them the avg
ringi = 0;
oring = bg::exterior_ring(*(_p2));
int pi;
for (int i = 0; i < oring.size(); i++) {
if (_p2z[ringi][i] == -9999)
_p2z[ringi][i] = avgheight;
}
ringi++;
irings = bg::interior_rings(*(_p2));
for (Ring2& iring : irings) {
for (int i = 0; i < iring.size(); i++) {
if (_p2z[ringi][i] == -9999)
_p2z[ringi][i] = avgheight;
}
ringi++;
irings = bg::interior_rings(*(_p2));
for (Ring2& iring : irings) {
for (int i = 0; i < iring.size(); i++) {
if (_p2z[ringi][i] == -9999)
_p2z[ringi][i] = avgheight;
}
ringi++;
}
}
}

Expand Down

0 comments on commit e6d1c59

Please sign in to comment.