Skip to content

Commit

Permalink
all attributes from input used in CityJSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoledoux committed Oct 2, 2017
1 parent 96a272e commit 69b5637
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void Building::get_cityjson(nlohmann::json& j, std::unordered_map<std::string, u
nlohmann::json b;
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"]["min-height-surface"] = hbase;
Expand Down
2 changes: 2 additions & 0 deletions Forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ bool Forest::lift() {
void Forest::get_cityjson(nlohmann::json& j, std::unordered_map<std::string,unsigned long> &dPts) {
nlohmann::json f;
f["type"] = "PlantCover";
f["attributes"];
get_cityjson_attributes(f, _attributes);
nlohmann::json g;
this->get_cityjson_geom(g, dPts);
f["geometry"].push_back(g);
Expand Down
2 changes: 2 additions & 0 deletions Road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void Road::get_cityjson(nlohmann::json& j, std::unordered_map<std::string,unsign
nlohmann::json f;
// f["type"] = "Road"; // TODO : change back to Road when implemented
f["type"] = "GenericCityObject";
f["attributes"];
get_cityjson_attributes(f, _attributes);
nlohmann::json g;
this->get_cityjson_geom(g, dPts);
f["geometry"].push_back(g);
Expand Down
2 changes: 2 additions & 0 deletions Separation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ bool Separation::lift() {
void Separation::get_cityjson(nlohmann::json& j, std::unordered_map<std::string,unsigned long> &dPts) {
nlohmann::json f;
f["type"] = "GenericCityObject";
f["attributes"];
get_cityjson_attributes(f, _attributes);
nlohmann::json g;
this->get_cityjson_geom(g, dPts);
f["geometry"].push_back(g);
Expand Down
2 changes: 2 additions & 0 deletions Terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ bool Terrain::lift() {
void Terrain::get_cityjson(nlohmann::json& j, std::unordered_map<std::string,unsigned long> &dPts) {
nlohmann::json f;
f["type"] = "LandUse";
f["attributes"];
get_cityjson_attributes(f, _attributes);
nlohmann::json g;
this->get_cityjson_geom(g, dPts);
f["geometry"].push_back(g);
Expand Down
9 changes: 9 additions & 0 deletions TopoFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ void TopoFeature::get_imgeo_object_info(std::ofstream& of, std::string id) {
}
}

void TopoFeature::get_cityjson_attributes(nlohmann::json& f, AttributeMap attributes) {
for (auto& attribute : attributes) {
// add attributes except gml_id
if (attribute.first.compare("gml_id") != 0)
f["attributes"][std::get<0>(attribute)] = attribute.second.second;
}
}


void TopoFeature::get_citygml_attributes(std::ofstream& of, AttributeMap attributes) {
for (auto& attribute : attributes) {
// add attributes except gml_id
Expand Down
1 change: 1 addition & 0 deletions TopoFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class TopoFeature {
AttributeMap get_attributes();
void get_imgeo_object_info(std::ofstream& of, std::string id);
void get_citygml_attributes(std::ofstream& of, AttributeMap attributes);
void get_cityjson_attributes(nlohmann::json& f, AttributeMap attributes);
protected:
Polygon2* _p2;
std::vector< std::vector<int> > _p2z;
Expand Down
2 changes: 2 additions & 0 deletions Water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ bool Water::lift() {
void Water::get_cityjson(nlohmann::json& j, std::unordered_map<std::string,unsigned long> &dPts) {
nlohmann::json f;
f["type"] = "WaterBody";
f["attributes"];
get_cityjson_attributes(f, _attributes);
nlohmann::json g;
this->get_cityjson_geom(g, dPts);
f["geometry"].push_back(g);
Expand Down

0 comments on commit 69b5637

Please sign in to comment.