Skip to content

Commit

Permalink
Merge branch 'gitflow'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Commandeur committed Sep 4, 2018
2 parents 36719c8 + 755ebca commit f6bb502
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 598 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ link_directories(${YamlCpp_LIBRARY_DIRS})
FILE(GLOB SRC_FILES src/*.cpp)
add_executable(3dfier ${SRC_FILES})

target_link_libraries( 3dfier ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${BOOST_LIBRARIES} ${GDAL_LIBRARY} ${LIBLAS_LIBRARY} ${LASZIP_LIBRARY} ${YAMLCPP_LIBRARY} ${Boost_LIBRARIES} )
target_link_libraries( 3dfier ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${GDAL_LIBRARY} ${LIBLAS_LIBRARY} ${LASZIP_LIBRARY} ${YAMLCPP_LIBRARY} Boost::program_options Boost::filesystem Boost::locale)

install(TARGETS 3dfier DESTINATION bin)
install(TARGETS 3dfier DESTINATION bin)
3 changes: 3 additions & 0 deletions src/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ void Bridge::get_citygml_imgeo(std::wostream& of) {
std::string attribute;
if (get_attribute("bgt-type", attribute)) {
of << "<bri:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbruggingsdeel\">" << attribute << "</bri:function>";
}
else if (get_attribute("bgt_type", attribute)) {
of << "<bri:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbruggingsdeel\">" << attribute << "</bri:function>";
}
if (get_attribute("hoortbijtypeoverbrugging", attribute)) {
of << "<imgeo:hoortBijTypeOverbrugging codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbrugging\">" << attribute << "</imgeo:hoortBijTypeOverbrugging>";
Expand Down
6 changes: 6 additions & 0 deletions src/Forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@ void Forest::get_citygml_imgeo(std::wostream& of) {
if (get_attribute("bgt-fysiekvoorkomen", attribute)) {
of << "<veg:class codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenBegroeidTerrein\">" << attribute << "</veg:class>";
}
else if (get_attribute("bgt_fysiekvoorkomen", attribute)) {
of << "<veg:class codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenBegroeidTerrein\">" << attribute << "</veg:class>";
}
if (get_attribute("begroeidterreindeeloptalud", attribute, "false")) {
of << "<imgeo:begroeidTerreindeelOpTalud>" << attribute << "</imgeo:begroeidTerreindeelOpTalud>";
}
if (get_attribute("plus-fysiekvoorkomen", attribute)) {
of << "<imgeo:plus-fysiekVoorkomen codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenBegroeidTerreinPlus\">" << attribute << "</imgeo:plus-fysiekVoorkomen>";
}
else if (get_attribute("plus_fysiekvoorkomen", attribute)) {
of << "<imgeo:plus-fysiekVoorkomen codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenBegroeidTerreinPlus\">" << attribute << "</imgeo:plus-fysiekVoorkomen>";
}
of << "</veg:PlantCover>";
of << "</cityObjectMember>";
}
Expand Down
245 changes: 4 additions & 241 deletions src/Map3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ Map3d::Map3d() {
_radius_vertex_elevation = 1.0;
_building_radius_vertex_elevation = 3.0;
_threshold_jump_edges = 50;
bg::set<bg::min_corner, 0>(_bbox, 999999);
bg::set<bg::min_corner, 1>(_bbox, 999999);
bg::set<bg::max_corner, 0>(_bbox, -999999);
bg::set<bg::max_corner, 1>(_bbox, -999999);
_requestedExtent = Box2(Point2(0, 0), Point2(0, 0));
_bbox = Box2(Point2(999999, 999999), Point2(-999999, -999999));
}

Map3d::~Map3d() {
Expand Down Expand Up @@ -425,7 +423,7 @@ bool Map3d::get_pdok_output(std::string filename) {
OGRLayer *layer = create_gdal_layer(driver, tmpFilename, layername, attributes, f->get_class() == BUILDING);
if (layer == NULL) {
std::cerr << "ERROR: Cannot open database '" + filename + "' for writing" << std::endl;
close_gdal_resources(driver, layers);
GDALClose(driver);
return false;
}
layers.emplace(layername, layer);
Expand All @@ -442,7 +440,7 @@ bool Map3d::get_pdok_output(std::string filename) {

f->get_shape(layers[layername], true, extraAttribute);
}
close_gdal_resources(driver, layers);
GDALClose(driver);
return true;
#endif
}
Expand Down Expand Up @@ -1650,241 +1648,6 @@ void Map3d::stitch_bridges() {
}
}

//void Map3d::stitch_bridges() {
// std::vector<int> ringis, pis;
// for (auto& f : _lsFeatures) {
// if (f->get_class() == BRIDGE && f->get_top_level() == false) {
// //-- 1. store all touching top level (adjacent + incident)
// std::vector<TopoFeature*>* lstouching = f->get_adjacent_features();
//
// //-- gather all rings
// std::vector<Ring2> rings;
// rings.push_back(f->get_Polygon2()->outer());
// for (Ring2& iring : f->get_Polygon2()->inners())
// rings.push_back(iring);
//
// int ringi = -1;
// for (Ring2& ring : rings) {
// ringi++;
//
// for (int i = 0; i < ring.size(); i++) {
// for (auto& fadj : *lstouching) {
// ringis.clear();
// 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) {
// f->set_vertex_elevation(ringi, i, z);
// // Add height to NC
// Point2 p = f->get_point2(ringi, i);
// std::string key_bucket = gen_key_bucket(&p);
// _nc[key_bucket].push_back(z);
// _bridge_stitches[key_bucket] = z;
// }
// }
// }
// }
// }
// Bridge* b = dynamic_cast<Bridge*>(f);
// b->detect_outliers(_road_threshold_outliers);
// }
// }
//
// for (auto& f : _lsFeatures) {
// if (f->get_class() == BRIDGE && f->get_top_level()) {
// //if (f->get_id() == "O0000.5cbe3212cc834f47ba6dfbc4dc83f71c") {
// // std::cout << "stop" << std::endl;
// //}
// //-- 1. store all touching top level (adjacent + incident)
// std::vector<TopoFeature*>* lstouching = f->get_adjacent_features();
//
// //-- gather all rings
// std::vector<Ring2> rings;
// rings.push_back(f->get_Polygon2()->outer());
// for (Ring2& iring : f->get_Polygon2()->inners())
// rings.push_back(iring);
//
// int ringi = -1;
// for (Ring2& ring : rings) {
// ringi++;
//
// std::vector< std::pair<int, bool> > corners;
// for (int i = 0; i < ring.size(); i++) {
// Point2 p = f->get_point2(ringi, i);
// std::string key_bucket = gen_key_bucket(&p);
// std::vector<int> nc;
// int unique = 0;
// if (_nc.find(key_bucket) != _nc.end()) {
// nc = _nc[key_bucket];
// std::sort(nc.begin(), nc.end());
// auto ncuIt = std::unique(nc.begin(), nc.end());
// unique = std::distance(nc.begin(), ncuIt);
// }
// if (unique > 0) {
// bool bridgeAdj = false;
//
// /* this can be 3 cases;
// 1. location where two bridges and other object meet without height jump.
// 2. location where one bridge meets multiple objects which should be a stitching error
// 3. error in stitching adjacent objects
// */
// if (unique <= 1) { // only check for bridge adjacent if there is only 1 unique value in NC for performance
// for (auto& fadj : *lstouching) {
// ringis.clear();
// pis.clear();
// if (fadj->get_class() == BRIDGE && fadj->get_top_level() && fadj->has_point2(ring[i], ringis, pis)) {
// bridgeAdj = true;
// }
// }
// }
//
// int previ = i - 1;
// if (i == 0) {
// previ = ring.size() - 1;
// }
// Point2 prevp = f->get_point2(ringi, previ);
// std::string prev_key_bucket = gen_key_bucket(&prevp);
// int nexti = i + 1;
// if (i == ring.size() - 1) {
// nexti = 0;
// }
// Point2 nextp = f->get_point2(ringi, nexti);
// std::string next_key_bucket = gen_key_bucket(&nextp);
// if ((_bridge_stitches.find(key_bucket) != _bridge_stitches.end() &&
// _bridge_stitches.find(next_key_bucket) == _bridge_stitches.end()) ||
// (_bridge_stitches.find(key_bucket) != _bridge_stitches.end() &&
// _bridge_stitches.find(prev_key_bucket) == _bridge_stitches.end()) ||
//
//
// /* Two cases which are seen as corners of the bridge object, either a height jump or where two bridge objects meet
// 1. if bridge adjacent, use nc. This is the case where a bridge is split into multiple parts touching the adjacent object
// 2. if 2 or more unique values in NC there is a height jump which should only occur at vw of bridge, skip values upto next occurence
// */
// bridgeAdj || unique > 1) {
// //This only works if previous is updated before checking, that is not the case now
// //auto const it = std::lower_bound(nc.begin(), nc.end(), f->get_vertex_elevation(ringi, i-1));
// f->set_vertex_elevation(ringi, i, nc.front());
// // if there are more then 1 unique height in NC we have a height jump.
// bool heightjump = false;
// if (_bridge_stitches.find(next_key_bucket) != _bridge_stitches.end()) {
// heightjump = true;
// }
// corners.push_back(std::make_pair(i, heightjump));
// }
// }
// }
//
// // Set height of vertices in between two corners
// for (int c = 0; c < corners.size(); c++) {
// // prepair vertices to loop for this stretch
// std::pair<int, bool> startCorner = corners[c];
// // set endCorner to first or corners if end of array is reached
// std::pair<int, bool> endCorner = corners.front();
// if (c + 1 < corners.size()) {
// endCorner = corners[c + 1];
// }
// int endCornerIdx = endCorner.first;
//
// std::vector<int> vertices;
// if (endCornerIdx < startCorner.first) {
// for (int i = startCorner.first + 1; i < ring.size(); i++) {
// vertices.push_back(i);
// }
// for (int i = 0; i < endCornerIdx; i++) {
// vertices.push_back(i);
// }
// }
// else {
// for (int i = startCorner.first + 1; i < endCornerIdx; i++) {
// vertices.push_back(i);
// }
// }
//
// for (int pi : vertices) {
// //if (f->get_id() == "O0000.59d49cd362f54875b4a3196c1363606f" && pi == 18) {
// // std::cout << "stop" << std::endl;
// //}
// bool otherAdj = false;
// int stitchz = 0;
// for (auto& fadj : *lstouching) {
// ringis.clear();
// pis.clear();
// if (fadj->get_class() != BRIDGE && fadj->has_point2(ring[pi], ringis, pis) == true) {
// otherAdj = true;
// stitchz = fadj->get_vertex_elevation(ringis[0], pis[0]);
// }
// }
// if (!otherAdj) { //No other type of objects then bridges are adjacent
// //This is empty stretch of points where only bridges connect, interpolate between prevCorner and nextCorner
// Point2 p = f->get_point2(ringi, pi);
// std::string key_bucket = gen_key_bucket(&p);
// int z = 0;
// //Check if height exists in NC thus is created by adjacent bridge
// if (_nc.find(key_bucket) == _nc.end()) {
// // check height of previous vertex
// int previ = pi - 1;
// if (pi == 0) {
// previ = ring.size() - 1;
// }
// // Add height to NC for adjacent bridge
// // interpolate height between previous vertex and next corner distance weighted
// z = interpolate_height(f, p, ringi, previ, ringi, endCorner.first);
// _nc[key_bucket].push_back(z);
// }
// else {
// z = _nc[key_bucket].front();
// }
// f->set_vertex_elevation(ringi, pi, z);
// }
// else {
// Point2 p = f->get_point2(ringi, pi);
// std::string key_bucket = gen_key_bucket(&p);
//
// // This is where the top part is stitched, interpolate between corners
// if (startCorner.second && endCorner.second == false) {
// // interpolate height between start and end corner distance weighted
// int interz = interpolate_height(f, p, ringi, startCorner.first, ringi, endCorner.first);
//
// // Allways stitch if there is a lower object, otherwise use interpolated height
// if (stitchz < interz) {
// f->set_vertex_elevation(ringi, pi, stitchz);
// }
// else {
// f->set_vertex_elevation(ringi, pi, interz);
// // Add height to NC and add VW
// _nc[key_bucket].push_back(interz);
// f->add_vertical_wall();
// }
// }
// else { // when there is no value in _bridge_stitches the upper part is floating thus stitch bottem to adjacent object if within threshold of previous vertex or corner
// // check height of previous vertex
// int previ = pi - 1;
// if (pi == 0) {
// previ = ring.size() - 1;
// }
//
// // interpolate height between previous vertex and next corner distance weighted
// 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) {
// f->set_vertex_elevation(ringi, pi, stitchz);
// }
// else {
// f->set_vertex_elevation(ringi, pi, interz);
// // Add height to NC and add VW
// _nc[key_bucket].push_back(interz);
// f->add_vertical_wall();
// }
// }
// }
// }
// }
// }
// }
// }
//}

int Map3d::interpolate_height(TopoFeature* f, const Point2 &p, int prevringi, int prevpi, int nextringi, int nextpi) {
// interpolate height between previous and next corner distance weighted
double dprev = distance(p, f->get_point2(prevringi, prevpi));
Expand Down
30 changes: 30 additions & 0 deletions src/Road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,46 +118,76 @@ void Road::get_citygml_imgeo(std::wostream& of) {
if (get_attribute("bgt-functie", attribute)) {
of << "<tra:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieSpoor\">" << attribute << "</tra:function>";
}
else if (get_attribute("bgt_functie", attribute)) {
of << "<tra:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieSpoor\">" << attribute << "</tra:function>";
}
if (get_attribute("plus-functiespoor", attribute)) {
of << "<imgeo:plus-functieSpoor codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieSpoorPlus\">" << attribute << "</imgeo:plus-functieSpoor>";
}
else if (get_attribute("plus_functiespoor", attribute)) {
of << "<imgeo:plus-functieSpoor codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieSpoorPlus\">" << attribute << "</imgeo:plus-functieSpoor>";
}
of << "</tra:Railway>";
}
else if (auxiliary) {
if (get_attribute("bgt-functie", attribute)) {
of << "<tra:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOndersteunendWegdeel\">" << attribute << "</tra:function>";
}
else if (get_attribute("bgt_functie", attribute)) {
of << "<tra:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOndersteunendWegdeel\">" << attribute << "</tra:function>";
}
if (get_attribute("bgt-fysiekvoorkomen", attribute)) {
of << "<tra:surfaceMaterial codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenOndersteunendWegdeel\">" << attribute << "</imgeo:tra:surfaceMaterial>";
}
else if (get_attribute("bgt_fysiekvoorkomen", attribute)) {
of << "<tra:surfaceMaterial codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenOndersteunendWegdeel\">" << attribute << "</imgeo:tra:surfaceMaterial>";
}
if (get_attribute("ondersteunendwegdeeloptalud", attribute, "false")) {
of << "<imgeo:ondersteunendWegdeelOpTalud>" << attribute << "</imgeo:ondersteunendWegdeelOpTalud>";
}
if (get_attribute("plus-functieondersteunendwegdeel", attribute)) {
of << "<imgeo:plus-functieOndersteunendWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOndersteunendWegdeelPlus\">" << attribute << "</imgeo:plus-functieOndersteunendWegdeel>";
}
else if (get_attribute("plus_functieondersteunendwegdeel", attribute)) {
of << "<imgeo:plus-functieOndersteunendWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOndersteunendWegdeelPlus\">" << attribute << "</imgeo:plus-functieOndersteunendWegdeel>";
}
if (get_attribute("plus-fysiekvoorkomenondersteunendwegdeel", attribute)) {
of << "<imgeo:plus-fysiekVoorkomenOndersteunendWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenOndersteunendWegdeelPlus\">" << attribute << "</imgeo:plus-fysiekVoorkomenOndersteunendWegdeel>";
}
else if (get_attribute("plus_fysiekvoorkomenondersteunendwegdeel", attribute)) {
of << "<imgeo:plus-fysiekVoorkomenOndersteunendWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenOndersteunendWegdeelPlus\">" << attribute << "</imgeo:plus-fysiekVoorkomenOndersteunendWegdeel>";
}
of << "</tra:AuxiliaryTrafficArea>";
}
else
{
if (get_attribute("bgt-functie", attribute)) {
of << "<tra:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieWeg\">" << attribute << "</tra:function>";
}
else if (get_attribute("bgt_functie", attribute)) {
of << "<tra:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieWeg\">" << attribute << "</tra:function>";
}
if (get_attribute("bgt-fysiekvoorkomen", attribute)) {
of << "<tra:surfaceMaterial codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenWeg\">" << attribute << "</tra:surfaceMaterial>";
}
else if (get_attribute("bgt_fysiekvoorkomen", attribute)) {
of << "<tra:surfaceMaterial codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenWeg\">" << attribute << "</tra:surfaceMaterial>";
}
if (!get_attribute("wegdeeloptalud", attribute, "false")) {
of << "<imgeo:wegdeelOpTalud>" << attribute << "</imgeo:wegdeelOpTalud>";
}
if (get_attribute("plus-functiewegdeel", attribute)) {
of << "<imgeo:plus-functieWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieWegPlus\">" << attribute << "</imgeo:plus-functieWegdeel>";
}
else if (get_attribute("plus_functiewegdeel", attribute)) {
of << "<imgeo:plus-functieWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FunctieWegPlus\">" << attribute << "</imgeo:plus-functieWegdeel>";
}
if (get_attribute("plus-fysiekvoorkomenwegdeel", attribute)) {
of << "<imgeo:plus-fysiekVoorkomenWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenWegPlus\">" << attribute << "</imgeo:plus-fysiekVoorkomenWegdeel>";
}
else if (get_attribute("plus_fysiekvoorkomenwegdeel", attribute)) {
of << "<imgeo:plus-fysiekVoorkomenWegdeel codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#FysiekVoorkomenWegPlus\">" << attribute << "</imgeo:plus-fysiekVoorkomenWegdeel>";
}
of << "</tra:TrafficArea>";
}
of << "</cityObjectMember>";
Expand Down
Loading

0 comments on commit f6bb502

Please sign in to comment.