Skip to content

Commit

Permalink
Merge branch 'release-0.6.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ipadjen committed Mar 7, 2025
2 parents 1d3f74a + 8092097 commit c47d7f7
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 133 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## [0.6.3] 2025-03-07
### Fixed
- CityJSON terrain output

## [0.6.2] - 2025-02-27
### Changed
- Improved inserting surface layer polygons when terrain pc is missing
Expand Down
24 changes: 4 additions & 20 deletions src/Boundary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ void Boundary::prep_output(Vector_2 edge) {
throw city4cfd_error("Cannot find side for output!");
}

std::vector<double> Boundary::get_domain_bbox() {
//todo: proper bbox calculation
std::vector<double> Boundary::get_outer_bnd_bbox() {
double maxx(-global::largnum), maxy(-global::largnum), maxz(-global::largnum);
double minx(global::largnum), miny(global::largnum), minz(global::largnum);

Expand All @@ -165,24 +164,9 @@ std::vector<double> Boundary::get_domain_bbox() {
if (pt.y() > maxy) maxy = pt.y();
else if (pt.y() < miny) miny = pt.y();

// if (pt.z() > maxz) maxz = pt.z();
// else if (pt.z() < minz) minz = pt.z();
if (pt.z() > maxz) maxz = pt.z();
else if (pt.z() < minz) minz = pt.z();
}
minz = -5;
maxz = 100;

return std::vector<double> {minx, miny, minz, maxx, maxy, maxz};
}

//-- TEMP
void Boundary::get_cityjson_info(nlohmann::json& b) const {
//temp
}

void Boundary::get_cityjson_semantics(nlohmann::json& g) const {
//temp
}

std::string Boundary::get_cityjson_primitive() const {
return "";
};
}
5 changes: 1 addition & 4 deletions src/Boundary.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Boundary : public TopoFeature {
static void set_bounds_to_buildings_pc(Point_set_3& pointCloud, const Polygon_2& pcBndPoly);
static void set_bounds_to_terrain_pc(Point_set_3& pointCloud, const Polygon_2& bndPoly,
const Polygon_2& pcBndPoly, const Polygon_2& startBufferPoly);
static std::vector<double> get_domain_bbox();
static std::vector<double> get_outer_bnd_bbox();

virtual void reconstruct() = 0;

Expand All @@ -49,9 +49,6 @@ class Boundary : public TopoFeature {

virtual TopoClass get_class() const = 0;
virtual std::string get_class_name() const = 0;
virtual void get_cityjson_info(nlohmann::json& b) const;
virtual void get_cityjson_semantics(nlohmann::json& g) const;
virtual std::string get_cityjson_primitive() const;

protected:
static std::vector<Point_3> s_outerPts;
Expand Down
23 changes: 12 additions & 11 deletions src/Building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,19 @@ std::string Building::get_lod() const {
return m_reconSettings->lod;
}

void Building::get_cityjson_info(nlohmann::json& b) const {
b["type"] = "Building";
void Building::get_cityjson_cityobj_info(nlohmann::json& f) const {
f["type"] = "Building";
// b["attributes"];
// get_cityjson_attributes(b, _attributes);
// float hbase = z_to_float(this->get_height_base());
// float h = z_to_float(this->get_height());
// b["attributes"]["TerrainHeight"] = m_baseElevations.back(); // temp - will calculate avg for every footprint
b["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
f["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
}

void Building::get_cityjson_geomobj_info(nlohmann::json& g) const {
g["type"] = "MultiSurface";
g["lod"] = this->get_lod();
}

void Building::get_cityjson_semantics(nlohmann::json& g) const {
Expand All @@ -304,22 +309,18 @@ void Building::get_cityjson_semantics(nlohmann::json& g) const {
} else throw city4cfd_error("Semantic property map not found!");

std::unordered_map<std::string, int> surfaceId;
surfaceId["RoofSurface"] = 0; g["semantics"]["surfaces"][0]["type"] = "RoofSurface";
surfaceId["GroundSurface"] = 1; g["semantics"]["surfaces"][1]["type"] = "GroundSurface";
surfaceId["WallSurface"] = 2; g["semantics"]["surfaces"][2]["type"] = "WallSurface";
surfaceId["RoofSurface"] = 0; g["surfaces"][0]["type"] = "RoofSurface";
surfaceId["GroundSurface"] = 1; g["surfaces"][1]["type"] = "GroundSurface";
surfaceId["WallSurface"] = 2; g["surfaces"][2]["type"] = "WallSurface";

for (auto faceIdx : m_mesh.faces()) {
auto it = surfaceId.find(semantics[faceIdx]);
if (it == surfaceId.end()) throw city4cfd_error("Could not find semantic attribute!");

g["semantics"]["values"][faceIdx.idx()] = it->second;
g["values"][faceIdx.idx()] = it->second;
}
}

std::string Building::get_cityjson_primitive() const {
return "MultiSurface";
}

TopoClass Building::get_class() const {
return BUILDING;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Building.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class Building : public PolyFeature {
PointSet3Ptr get_points() const;
std::string get_lod() const;

virtual void get_cityjson_info(nlohmann::json& b) const override;
virtual void get_cityjson_cityobj_info(nlohmann::json& f) const override;
virtual void get_cityjson_geomobj_info(nlohmann::json& g) const override;
virtual void get_cityjson_semantics(nlohmann::json& g) const override;
virtual std::string get_cityjson_primitive() const override;
virtual TopoClass get_class() const override;
virtual std::string get_class_name() const override;

Expand Down
1 change: 0 additions & 1 deletion src/ImportedBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>


int ImportedBuilding::noBottom = 0;

ImportedBuilding::ImportedBuilding(std::unique_ptr<nlohmann::json>& buildingJson, PointSet3Ptr& importedBuildingPts)
Expand Down
3 changes: 0 additions & 3 deletions src/ImportedBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class ImportedBuilding : public Building {
const int get_lod_idx() const;
const bool is_appending() const;

// virtual void get_cityjson_info(nlohmann::json& b) const override;
// virtual void get_cityjson_semantics(nlohmann::json& g) const override;

protected:
std::unordered_map<int, Point_3> m_ptMap;
std::unique_ptr<nlohmann::json> m_buildingJson;
Expand Down
10 changes: 3 additions & 7 deletions src/LoD22.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,12 @@ void LoD22::reconstruct(const PointSet3Ptr& buildingPtsPtr,
++j;
}

//todo groundPts flag
// reconstruct
// m_rooferMeshes = roofer::reconstruct_single_instance(buildingPts, groundPts, linearRing,
// {.lambda = config.m_lambda,
// .lod = config.m_lod,
// .lod13_step_height = config.m_lod13_step_height});
m_rooferMeshes = roofer::reconstruct_single_instance(buildingPts, linearRing,
// groundPts, //todo groundPts flag
{.lambda = config.m_lambda,
.lod = config.m_lod,
.lod13_step_height = config.m_lod13_step_height});
.lod = config.m_lod,
.lod13_step_height = config.m_lod13_step_height});

// store the first mesh from the vector, rest should be handled separately
auto rooferMesh = m_rooferMeshes.front();
Expand Down
3 changes: 0 additions & 3 deletions src/PolyFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ class PolyFeature : public TopoFeature {
void calc_min_bbox();
void clear_feature();

virtual void get_cityjson_info(nlohmann::json& b) const = 0;
virtual void get_cityjson_semantics(nlohmann::json& g) const = 0;
virtual std::string get_cityjson_primitive() const = 0;
virtual TopoClass get_class() const = 0;
virtual std::string get_class_name() const = 0;

Expand Down
21 changes: 4 additions & 17 deletions src/ReconstructedBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,6 @@ void ReconstructedBuilding::reconstruct_flat_terrain() {
}
}

void ReconstructedBuilding::get_cityjson_info(nlohmann::json& b) const {
b["type"] = "Building";
// b["attributes"];
// get_cityjson_attributes(b, _attributes);
// float hbase = z_to_float(this->get_height_base());
// float h = z_to_float(this->get_height());
// b["attributes"]["TerrainHeight"] = m_baseElevations.back(); // temp - will calculate avg for every footprint
b["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
}

void ReconstructedBuilding::get_cityjson_semantics(nlohmann::json& g) const { // Temp for checking CGAL mesh properties
// for now handle only LoD1.2 with semantics, LoD1.3 and LoD2.2 loses information
// when making final repairs
Expand All @@ -346,18 +336,15 @@ void ReconstructedBuilding::get_cityjson_semantics(nlohmann::json& g) const { //
} else throw city4cfd_error("Semantic property map not found!");

std::unordered_map<std::string, int> surfaceId;
surfaceId["RoofSurface"] = 0;
g["semantics"]["surfaces"][0]["type"] = "RoofSurface";
surfaceId["GroundSurface"] = 1;
g["semantics"]["surfaces"][1]["type"] = "GroundSurface";
surfaceId["WallSurface"] = 2;
g["semantics"]["surfaces"][2]["type"] = "WallSurface";
surfaceId["RoofSurface"] = 0; g["surfaces"][0]["type"] = "RoofSurface";
surfaceId["GroundSurface"] = 1; g["surfaces"][1]["type"] = "GroundSurface";
surfaceId["WallSurface"] = 2; g["surfaces"][2]["type"] = "WallSurface";

for (auto faceIdx: m_mesh.faces()) {
auto it = surfaceId.find(semantics[faceIdx]);
if (it == surfaceId.end()) throw city4cfd_error("Could not find semantic attribute!");

g["semantics"]["values"][faceIdx.idx()] = it->second;
g["values"][faceIdx.idx()] = it->second;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/ReconstructedBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class ReconstructedBuilding : public Building {
virtual void reconstruct() override;
virtual void insert_terrain_point(const Point_3& pt) override;
virtual void reconstruct_flat_terrain() override;
virtual void get_cityjson_info(nlohmann::json& b) const override;
virtual void get_cityjson_semantics(nlohmann::json& g) const override;

protected:
Expand Down
22 changes: 5 additions & 17 deletions src/SurfaceLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,12 @@

#include "geomutils.h"

SurfaceLayer::SurfaceLayer()
: PolyFeature() {}

SurfaceLayer::SurfaceLayer(const int outputLayerID)
: PolyFeature(outputLayerID) {}

SurfaceLayer::SurfaceLayer(const nlohmann::json& poly)
: PolyFeature(poly) {}

SurfaceLayer::SurfaceLayer(const nlohmann::json& poly, const int outputLayerID)
: PolyFeature(poly, outputLayerID) {}

SurfaceLayer::SurfaceLayer(const Polygon_with_attr& poly)
: PolyFeature(poly) {}

SurfaceLayer::SurfaceLayer(const Polygon_with_attr& poly, const int outputLayerID)
: PolyFeature(poly, outputLayerID) {}

Expand All @@ -58,16 +49,13 @@ void SurfaceLayer::check_feature_scope(const Polygon_2& bndPoly) {
}
}

void SurfaceLayer::get_cityjson_info(nlohmann::json& b) const {

}

void SurfaceLayer::get_cityjson_semantics(nlohmann::json& g) const {

void SurfaceLayer::get_cityjson_cityobj_info(nlohmann::json& f) const {
f["type"] = "TINRelief";
}

std::string SurfaceLayer::get_cityjson_primitive() const {
return "Dunno yet";
void SurfaceLayer::get_cityjson_geomobj_info(nlohmann::json& g) const {
g["type"] = "CompositeSurface";
g["lod"] = "1.2";
}

TopoClass SurfaceLayer::get_class() const {
Expand Down
8 changes: 2 additions & 6 deletions src/SurfaceLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@

class SurfaceLayer : public PolyFeature {
public:
SurfaceLayer();
SurfaceLayer(const int outputLayerID);
SurfaceLayer(const nlohmann::json& poly);
SurfaceLayer(const nlohmann::json& poly, const int outputLayerID);
SurfaceLayer(const Polygon_with_attr& poly);
SurfaceLayer(const Polygon_with_attr& poly, const int outputLayerID);
~SurfaceLayer() = default;

void check_feature_scope(const Polygon_2& bndPoly);

virtual void get_cityjson_info(nlohmann::json& b) const override;
virtual void get_cityjson_semantics(nlohmann::json& g) const override;
virtual std::string get_cityjson_primitive() const override;
virtual void get_cityjson_cityobj_info(nlohmann::json& f) const override;
virtual void get_cityjson_geomobj_info(nlohmann::json& g) const override;
virtual TopoClass get_class() const override;
virtual std::string get_class_name() const override;

Expand Down
9 changes: 5 additions & 4 deletions src/Terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,14 @@ void Terrain::check_layer(const Face_handle& fh, int surfaceLayer) {
}
*/

void Terrain::get_cityjson_info(nlohmann::json& b) const {
b["type"] = "TINRelief";
void Terrain::get_cityjson_cityobj_info(nlohmann::json& f) const {
f["type"] = "TINRelief";
// b["attributes"]; // commented out until I have attributes to add
}

std::string Terrain::get_cityjson_primitive() const {
return "CompositeSurface";
void Terrain::get_cityjson_geomobj_info(nlohmann::json& g) const {
g["type"] = "CompositeSurface";
g["lod"] = "1.2";
}

CDT& Terrain::get_cdt() {
Expand Down
4 changes: 2 additions & 2 deletions src/Terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class Terrain : public TopoFeature {
const SearchTree& get_mesh_search_tree() const;
std::vector<EPECK::Segment_3>& get_extra_constrained_edges();

void get_cityjson_info(nlohmann::json& b) const override;
std::string get_cityjson_primitive() const override;
void get_cityjson_geomobj_info(nlohmann::json& g) const override;
void get_cityjson_cityobj_info(nlohmann::json& f) const override;
TopoClass get_class() const override;
std::string get_class_name() const override;

Expand Down
14 changes: 3 additions & 11 deletions src/TopoFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,8 @@ void TopoFeature::deactivate() {
m_f_active = false;
}

void TopoFeature::get_cityjson_info(nlohmann::json& j) const {
//TEMP UNTIL ALL FUNCTIONS ARE IMPLEMENTED
}

void TopoFeature::get_cityjson_semantics(nlohmann::json& g) const {
// TEMP until I figure what to do with this
}
void TopoFeature::get_cityjson_cityobj_info(nlohmann::json& /* f */) const { }

void TopoFeature::get_cityjson_geomobj_info(nlohmann::json& /* g */) const { }

std::string TopoFeature::get_cityjson_primitive() const {
//TEMP UNTIL ALL FUNCTIONS ARE IMPLEMENTED
return "Nope";
}
void TopoFeature::get_cityjson_semantics(nlohmann::json& /* g */) const { }
7 changes: 4 additions & 3 deletions src/TopoFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ class TopoFeature {
static void add_recon_region_output_layers(const int numLayers);
static int get_num_output_layers();

virtual void get_cityjson_info(nlohmann::json& b) const;
virtual void get_cityjson_semantics(nlohmann::json& g) const;
virtual std::string get_cityjson_primitive() const;
virtual TopoClass get_class() const = 0;
virtual std::string get_class_name() const = 0;

virtual void get_cityjson_cityobj_info(nlohmann::json& f) const;
virtual void get_cityjson_geomobj_info(nlohmann::json& g) const;
virtual void get_cityjson_semantics(nlohmann::json& g) const;

Mesh& get_mesh();
const Mesh& get_mesh() const;
void set_id(unsigned long id);
Expand Down
Loading

0 comments on commit c47d7f7

Please sign in to comment.