Skip to content

Commit c47d7f7

Browse files
committed
Merge branch 'release-0.6.3' into main
2 parents 1d3f74a + 8092097 commit c47d7f7

20 files changed

+128
-133
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## [0.6.3] 2025-03-07
3+
### Fixed
4+
- CityJSON terrain output
5+
26
## [0.6.2] - 2025-02-27
37
### Changed
48
- Improved inserting surface layer polygons when terrain pc is missing

src/Boundary.cpp

+4-20
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ void Boundary::prep_output(Vector_2 edge) {
153153
throw city4cfd_error("Cannot find side for output!");
154154
}
155155

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

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

168-
// if (pt.z() > maxz) maxz = pt.z();
169-
// else if (pt.z() < minz) minz = pt.z();
167+
if (pt.z() > maxz) maxz = pt.z();
168+
else if (pt.z() < minz) minz = pt.z();
170169
}
171-
minz = -5;
172-
maxz = 100;
173170

174171
return std::vector<double> {minx, miny, minz, maxx, maxy, maxz};
175-
}
176-
177-
//-- TEMP
178-
void Boundary::get_cityjson_info(nlohmann::json& b) const {
179-
//temp
180-
}
181-
182-
void Boundary::get_cityjson_semantics(nlohmann::json& g) const {
183-
//temp
184-
}
185-
186-
std::string Boundary::get_cityjson_primitive() const {
187-
return "";
188-
};
172+
}

src/Boundary.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Boundary : public TopoFeature {
4040
static void set_bounds_to_buildings_pc(Point_set_3& pointCloud, const Polygon_2& pcBndPoly);
4141
static void set_bounds_to_terrain_pc(Point_set_3& pointCloud, const Polygon_2& bndPoly,
4242
const Polygon_2& pcBndPoly, const Polygon_2& startBufferPoly);
43-
static std::vector<double> get_domain_bbox();
43+
static std::vector<double> get_outer_bnd_bbox();
4444

4545
virtual void reconstruct() = 0;
4646

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

5050
virtual TopoClass get_class() const = 0;
5151
virtual std::string get_class_name() const = 0;
52-
virtual void get_cityjson_info(nlohmann::json& b) const;
53-
virtual void get_cityjson_semantics(nlohmann::json& g) const;
54-
virtual std::string get_cityjson_primitive() const;
5552

5653
protected:
5754
static std::vector<Point_3> s_outerPts;

src/Building.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,19 @@ std::string Building::get_lod() const {
286286
return m_reconSettings->lod;
287287
}
288288

289-
void Building::get_cityjson_info(nlohmann::json& b) const {
290-
b["type"] = "Building";
289+
void Building::get_cityjson_cityobj_info(nlohmann::json& f) const {
290+
f["type"] = "Building";
291291
// b["attributes"];
292292
// get_cityjson_attributes(b, _attributes);
293293
// float hbase = z_to_float(this->get_height_base());
294294
// float h = z_to_float(this->get_height());
295295
// b["attributes"]["TerrainHeight"] = m_baseElevations.back(); // temp - will calculate avg for every footprint
296-
b["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
296+
f["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
297+
}
298+
299+
void Building::get_cityjson_geomobj_info(nlohmann::json& g) const {
300+
g["type"] = "MultiSurface";
301+
g["lod"] = this->get_lod();
297302
}
298303

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

306311
std::unordered_map<std::string, int> surfaceId;
307-
surfaceId["RoofSurface"] = 0; g["semantics"]["surfaces"][0]["type"] = "RoofSurface";
308-
surfaceId["GroundSurface"] = 1; g["semantics"]["surfaces"][1]["type"] = "GroundSurface";
309-
surfaceId["WallSurface"] = 2; g["semantics"]["surfaces"][2]["type"] = "WallSurface";
312+
surfaceId["RoofSurface"] = 0; g["surfaces"][0]["type"] = "RoofSurface";
313+
surfaceId["GroundSurface"] = 1; g["surfaces"][1]["type"] = "GroundSurface";
314+
surfaceId["WallSurface"] = 2; g["surfaces"][2]["type"] = "WallSurface";
310315

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

315-
g["semantics"]["values"][faceIdx.idx()] = it->second;
320+
g["values"][faceIdx.idx()] = it->second;
316321
}
317322
}
318323

319-
std::string Building::get_cityjson_primitive() const {
320-
return "MultiSurface";
321-
}
322-
323324
TopoClass Building::get_class() const {
324325
return BUILDING;
325326
}

src/Building.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ class Building : public PolyFeature {
6767
PointSet3Ptr get_points() const;
6868
std::string get_lod() const;
6969

70-
virtual void get_cityjson_info(nlohmann::json& b) const override;
70+
virtual void get_cityjson_cityobj_info(nlohmann::json& f) const override;
71+
virtual void get_cityjson_geomobj_info(nlohmann::json& g) const override;
7172
virtual void get_cityjson_semantics(nlohmann::json& g) const override;
72-
virtual std::string get_cityjson_primitive() const override;
7373
virtual TopoClass get_class() const override;
7474
virtual std::string get_class_name() const override;
7575

src/ImportedBuilding.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
4040
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
4141

42-
4342
int ImportedBuilding::noBottom = 0;
4443

4544
ImportedBuilding::ImportedBuilding(std::unique_ptr<nlohmann::json>& buildingJson, PointSet3Ptr& importedBuildingPts)

src/ImportedBuilding.h

-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ class ImportedBuilding : public Building {
5353
const int get_lod_idx() const;
5454
const bool is_appending() const;
5555

56-
// virtual void get_cityjson_info(nlohmann::json& b) const override;
57-
// virtual void get_cityjson_semantics(nlohmann::json& g) const override;
58-
5956
protected:
6057
std::unordered_map<int, Point_3> m_ptMap;
6158
std::unique_ptr<nlohmann::json> m_buildingJson;

src/LoD22.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,12 @@ void LoD22::reconstruct(const PointSet3Ptr& buildingPtsPtr,
8888
++j;
8989
}
9090

91-
//todo groundPts flag
9291
// reconstruct
93-
// m_rooferMeshes = roofer::reconstruct_single_instance(buildingPts, groundPts, linearRing,
94-
// {.lambda = config.m_lambda,
95-
// .lod = config.m_lod,
96-
// .lod13_step_height = config.m_lod13_step_height});
9792
m_rooferMeshes = roofer::reconstruct_single_instance(buildingPts, linearRing,
93+
// groundPts, //todo groundPts flag
9894
{.lambda = config.m_lambda,
99-
.lod = config.m_lod,
100-
.lod13_step_height = config.m_lod13_step_height});
95+
.lod = config.m_lod,
96+
.lod13_step_height = config.m_lod13_step_height});
10197

10298
// store the first mesh from the vector, rest should be handled separately
10399
auto rooferMesh = m_rooferMeshes.front();

src/PolyFeature.h

-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ class PolyFeature : public TopoFeature {
5757
void calc_min_bbox();
5858
void clear_feature();
5959

60-
virtual void get_cityjson_info(nlohmann::json& b) const = 0;
61-
virtual void get_cityjson_semantics(nlohmann::json& g) const = 0;
62-
virtual std::string get_cityjson_primitive() const = 0;
6360
virtual TopoClass get_class() const = 0;
6461
virtual std::string get_class_name() const = 0;
6562

src/ReconstructedBuilding.cpp

+4-17
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,6 @@ void ReconstructedBuilding::reconstruct_flat_terrain() {
325325
}
326326
}
327327

328-
void ReconstructedBuilding::get_cityjson_info(nlohmann::json& b) const {
329-
b["type"] = "Building";
330-
// b["attributes"];
331-
// get_cityjson_attributes(b, _attributes);
332-
// float hbase = z_to_float(this->get_height_base());
333-
// float h = z_to_float(this->get_height());
334-
// b["attributes"]["TerrainHeight"] = m_baseElevations.back(); // temp - will calculate avg for every footprint
335-
b["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
336-
}
337-
338328
void ReconstructedBuilding::get_cityjson_semantics(nlohmann::json& g) const { // Temp for checking CGAL mesh properties
339329
// for now handle only LoD1.2 with semantics, LoD1.3 and LoD2.2 loses information
340330
// when making final repairs
@@ -346,18 +336,15 @@ void ReconstructedBuilding::get_cityjson_semantics(nlohmann::json& g) const { //
346336
} else throw city4cfd_error("Semantic property map not found!");
347337

348338
std::unordered_map<std::string, int> surfaceId;
349-
surfaceId["RoofSurface"] = 0;
350-
g["semantics"]["surfaces"][0]["type"] = "RoofSurface";
351-
surfaceId["GroundSurface"] = 1;
352-
g["semantics"]["surfaces"][1]["type"] = "GroundSurface";
353-
surfaceId["WallSurface"] = 2;
354-
g["semantics"]["surfaces"][2]["type"] = "WallSurface";
339+
surfaceId["RoofSurface"] = 0; g["surfaces"][0]["type"] = "RoofSurface";
340+
surfaceId["GroundSurface"] = 1; g["surfaces"][1]["type"] = "GroundSurface";
341+
surfaceId["WallSurface"] = 2; g["surfaces"][2]["type"] = "WallSurface";
355342

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

360-
g["semantics"]["values"][faceIdx.idx()] = it->second;
347+
g["values"][faceIdx.idx()] = it->second;
361348
}
362349
}
363350
}

src/ReconstructedBuilding.h

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class ReconstructedBuilding : public Building {
4747
virtual void reconstruct() override;
4848
virtual void insert_terrain_point(const Point_3& pt) override;
4949
virtual void reconstruct_flat_terrain() override;
50-
virtual void get_cityjson_info(nlohmann::json& b) const override;
5150
virtual void get_cityjson_semantics(nlohmann::json& g) const override;
5251

5352
protected:

src/SurfaceLayer.cpp

+5-17
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,12 @@
2929

3030
#include "geomutils.h"
3131

32-
SurfaceLayer::SurfaceLayer()
33-
: PolyFeature() {}
34-
3532
SurfaceLayer::SurfaceLayer(const int outputLayerID)
3633
: PolyFeature(outputLayerID) {}
3734

38-
SurfaceLayer::SurfaceLayer(const nlohmann::json& poly)
39-
: PolyFeature(poly) {}
40-
4135
SurfaceLayer::SurfaceLayer(const nlohmann::json& poly, const int outputLayerID)
4236
: PolyFeature(poly, outputLayerID) {}
4337

44-
SurfaceLayer::SurfaceLayer(const Polygon_with_attr& poly)
45-
: PolyFeature(poly) {}
46-
4738
SurfaceLayer::SurfaceLayer(const Polygon_with_attr& poly, const int outputLayerID)
4839
: PolyFeature(poly, outputLayerID) {}
4940

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

61-
void SurfaceLayer::get_cityjson_info(nlohmann::json& b) const {
62-
63-
}
64-
65-
void SurfaceLayer::get_cityjson_semantics(nlohmann::json& g) const {
66-
52+
void SurfaceLayer::get_cityjson_cityobj_info(nlohmann::json& f) const {
53+
f["type"] = "TINRelief";
6754
}
6855

69-
std::string SurfaceLayer::get_cityjson_primitive() const {
70-
return "Dunno yet";
56+
void SurfaceLayer::get_cityjson_geomobj_info(nlohmann::json& g) const {
57+
g["type"] = "CompositeSurface";
58+
g["lod"] = "1.2";
7159
}
7260

7361
TopoClass SurfaceLayer::get_class() const {

src/SurfaceLayer.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,15 @@
3232

3333
class SurfaceLayer : public PolyFeature {
3434
public:
35-
SurfaceLayer();
3635
SurfaceLayer(const int outputLayerID);
37-
SurfaceLayer(const nlohmann::json& poly);
3836
SurfaceLayer(const nlohmann::json& poly, const int outputLayerID);
39-
SurfaceLayer(const Polygon_with_attr& poly);
4037
SurfaceLayer(const Polygon_with_attr& poly, const int outputLayerID);
4138
~SurfaceLayer() = default;
4239

4340
void check_feature_scope(const Polygon_2& bndPoly);
4441

45-
virtual void get_cityjson_info(nlohmann::json& b) const override;
46-
virtual void get_cityjson_semantics(nlohmann::json& g) const override;
47-
virtual std::string get_cityjson_primitive() const override;
42+
virtual void get_cityjson_cityobj_info(nlohmann::json& f) const override;
43+
virtual void get_cityjson_geomobj_info(nlohmann::json& g) const override;
4844
virtual TopoClass get_class() const override;
4945
virtual std::string get_class_name() const override;
5046

src/Terrain.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,14 @@ void Terrain::check_layer(const Face_handle& fh, int surfaceLayer) {
316316
}
317317
*/
318318

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

324-
std::string Terrain::get_cityjson_primitive() const {
325-
return "CompositeSurface";
324+
void Terrain::get_cityjson_geomobj_info(nlohmann::json& g) const {
325+
g["type"] = "CompositeSurface";
326+
g["lod"] = "1.2";
326327
}
327328

328329
CDT& Terrain::get_cdt() {

src/Terrain.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class Terrain : public TopoFeature {
5858
const SearchTree& get_mesh_search_tree() const;
5959
std::vector<EPECK::Segment_3>& get_extra_constrained_edges();
6060

61-
void get_cityjson_info(nlohmann::json& b) const override;
62-
std::string get_cityjson_primitive() const override;
61+
void get_cityjson_geomobj_info(nlohmann::json& g) const override;
62+
void get_cityjson_cityobj_info(nlohmann::json& f) const override;
6363
TopoClass get_class() const override;
6464
std::string get_class_name() const override;
6565

src/TopoFeature.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,8 @@ void TopoFeature::deactivate() {
8181
m_f_active = false;
8282
}
8383

84-
void TopoFeature::get_cityjson_info(nlohmann::json& j) const {
85-
//TEMP UNTIL ALL FUNCTIONS ARE IMPLEMENTED
86-
}
87-
88-
void TopoFeature::get_cityjson_semantics(nlohmann::json& g) const {
89-
// TEMP until I figure what to do with this
90-
}
84+
void TopoFeature::get_cityjson_cityobj_info(nlohmann::json& /* f */) const { }
9185

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

93-
std::string TopoFeature::get_cityjson_primitive() const {
94-
//TEMP UNTIL ALL FUNCTIONS ARE IMPLEMENTED
95-
return "Nope";
96-
}
88+
void TopoFeature::get_cityjson_semantics(nlohmann::json& /* g */) const { }

src/TopoFeature.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ class TopoFeature {
4141
static void add_recon_region_output_layers(const int numLayers);
4242
static int get_num_output_layers();
4343

44-
virtual void get_cityjson_info(nlohmann::json& b) const;
45-
virtual void get_cityjson_semantics(nlohmann::json& g) const;
46-
virtual std::string get_cityjson_primitive() const;
4744
virtual TopoClass get_class() const = 0;
4845
virtual std::string get_class_name() const = 0;
4946

47+
virtual void get_cityjson_cityobj_info(nlohmann::json& f) const;
48+
virtual void get_cityjson_geomobj_info(nlohmann::json& g) const;
49+
virtual void get_cityjson_semantics(nlohmann::json& g) const;
50+
5051
Mesh& get_mesh();
5152
const Mesh& get_mesh() const;
5253
void set_id(unsigned long id);

0 commit comments

Comments
 (0)