Skip to content

Commit

Permalink
Improved CityJSON parsing, support 0.5-style semantics with null flat…
Browse files Browse the repository at this point in the history
…tening
  • Loading branch information
kenohori committed Dec 19, 2017
1 parent b0ae33e commit 18cdf0a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 44 deletions.
4 changes: 2 additions & 2 deletions azul.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = NO;
DEVELOPMENT_TEAM = UD3V83TPY7;
GCC_OPTIMIZATION_LEVEL = fast;
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = /usr/local/include;
INFOPLIST_FILE = src/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libs";
PRODUCT_BUNDLE_IDENTIFIER = tudelft3d.azul;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "src/azul-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
Expand Down
135 changes: 93 additions & 42 deletions src/DataManager/JSONParsingHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,30 @@ class JSONParsingHelper {
// std::cout << "Geometry: " << geometry.dump(2) << std::endl;

if (geometry["type"] == "MultiSurface" || geometry["type"] == "CompositeSurface") {
// std::cout << "Surfaces: " << geometry["geometry"].dump() << std::endl;
for (unsigned int surfaceIndex = 0; surfaceIndex < geometry["geometry"].size(); ++surfaceIndex) {
// std::cout << "Surface: " << geometry["geometry"][surfaceIndex].dump() << std::endl;
std::vector<std::vector<std::size_t>> surface = geometry["geometry"][surfaceIndex];
// std::cout << "Surfaces: " << geometry["boundaries"].dump() << std::endl;
for (unsigned int surfaceIndex = 0; surfaceIndex < geometry["boundaries"].size(); ++surfaceIndex) {
// std::cout << "Surface: " << geometry["boundaries"][surfaceIndex].dump() << std::endl;
std::vector<std::vector<std::size_t>> surface = geometry["boundaries"][surfaceIndex];
std::string surfaceType;
if (geometry.count("semantics")) {
auto const &surfaceSemantics = geometry["semantics"][surfaceIndex];
// std::cout << "Surface semantics: " << surfaceSemantics.dump() << std::endl;
surfaceType = surfaceSemantics["type"];
// std::cout << "Surface type: " << surfaceType << std::endl;
AzulObject newChild;
newChild.type = surfaceType;
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
newChild.polygons.push_back(newPolygon);
object.children.push_back(newChild);
// std::cout << "Surface semantics: " << geometry["semantics"] << std::endl;
if (geometry["semantics"]["values"].size() > surfaceIndex &&
!geometry["semantics"]["values"][surfaceIndex].is_null()) {
std::size_t semanticSurfaceIndex = geometry["semantics"]["values"][surfaceIndex];
auto const &surfaceSemantics = geometry["semantics"]["surfaces"][semanticSurfaceIndex];
surfaceType = surfaceSemantics["type"];
std::cout << "Surface type: " << surfaceType << std::endl;
AzulObject newChild;
newChild.type = surfaceType;
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
newChild.polygons.push_back(newPolygon);
object.children.push_back(newChild);
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
object.polygons.push_back(newPolygon);
}
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
Expand All @@ -59,24 +67,39 @@ class JSONParsingHelper {
}

else if (geometry["type"] == "Solid") {
// std::cout << "Shells: " << geometry["geometry"].dump() << std::endl;
for (unsigned int shellIndex = 0; shellIndex < geometry["geometry"].size(); ++shellIndex) {
// std::cout << "Shell: " << geometry["geometry"][shellIndex].dump() << std::endl;
for (unsigned int surfaceIndex = 0; surfaceIndex < geometry["geometry"][shellIndex].size(); ++surfaceIndex) {
// std::cout << "Surface: " << geometry["geometry"][shellIndex][surfaceIndex].dump() << std::endl;
std::vector<std::vector<std::size_t>> surface = geometry["geometry"][shellIndex][surfaceIndex];
// std::cout << "Shells: " << geometry["boundaries"].dump() << std::endl;
for (unsigned int shellIndex = 0; shellIndex < geometry["boundaries"].size(); ++shellIndex) {
// std::cout << "Shell: " << geometry["boundaries"][shellIndex].dump() << std::endl;
for (unsigned int surfaceIndex = 0; surfaceIndex < geometry["boundaries"][shellIndex].size(); ++surfaceIndex) {
// std::cout << "Surface: " << geometry["boundaries"][shellIndex][surfaceIndex].dump() << std::endl;
std::vector<std::vector<std::size_t>> surface = geometry["boundaries"][shellIndex][surfaceIndex];
std::string surfaceType;
if (geometry.count("semantics")) {
auto const &surfaceSemantics = geometry["semantics"][shellIndex][surfaceIndex];
// std::cout << "Surface semantics: " << surfaceSemantics.dump() << std::endl;
surfaceType = surfaceSemantics["type"];
// std::cout << "Surface type: " << surfaceType << std::endl;
AzulObject newChild;
newChild.type = surfaceType;
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
newChild.polygons.push_back(newPolygon);
object.children.push_back(newChild);
// std::cout << "Surface semantics: " << geometry["semantics"] << std::endl;
if (geometry["semantics"]["values"].size() > shellIndex &&
!geometry["semantics"]["values"][shellIndex].is_null()) {
if (geometry["semantics"]["values"][shellIndex].size() > surfaceIndex &&
!geometry["semantics"]["values"][shellIndex][surfaceIndex].is_null()) {
std::size_t semanticSurfaceIndex = geometry["semantics"]["values"][shellIndex][surfaceIndex];
auto const &surfaceSemantics = geometry["semantics"]["surfaces"][semanticSurfaceIndex];
surfaceType = surfaceSemantics["type"];
std::cout << "Surface type: " << surfaceType << std::endl;
AzulObject newChild;
newChild.type = surfaceType;
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
newChild.polygons.push_back(newPolygon);
object.children.push_back(newChild);
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
object.polygons.push_back(newPolygon);
}
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
object.polygons.push_back(newPolygon);
}
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
Expand All @@ -87,20 +110,48 @@ class JSONParsingHelper {
}

else if (geometry["type"] == "MultiSolid" || geometry["type"] == "CompositeSolid") {
for (unsigned int solidIndex = 0; solidIndex < geometry["geometry"].size(); ++solidIndex) {
for (unsigned int shellIndex = 0; shellIndex < geometry["geometry"][solidIndex].size(); ++shellIndex) {
for (unsigned int surfaceIndex = 0; surfaceIndex < geometry["geometry"][solidIndex][shellIndex].size(); ++surfaceIndex) {
std::vector<std::vector<std::size_t>> surface = geometry["geometry"][solidIndex][shellIndex][surfaceIndex];
// std::cout << "Solids: " << geometry["boundaries"].dump() << std::endl;
for (unsigned int solidIndex = 0; solidIndex < geometry["boundaries"].size(); ++solidIndex) {
// std::cout << "Shells: " << geometry["boundaries"][solidIndex].dump() << std::endl;
for (unsigned int shellIndex = 0; shellIndex < geometry["boundaries"][solidIndex].size(); ++shellIndex) {
// std::cout << "Shell: " << geometry["boundaries"][solidIndex][shellIndex].dump() << std::endl;
for (unsigned int surfaceIndex = 0; surfaceIndex < geometry["boundaries"][solidIndex][shellIndex].size(); ++surfaceIndex) {
// std::cout << "Surface: " << geometry["boundaries"][solidIndex][shellIndex][surfaceIndex].dump() << std::endl;
std::vector<std::vector<std::size_t>> surface = geometry["boundaries"][solidIndex][shellIndex][surfaceIndex];
std::string surfaceType;
if (geometry.count("semantics")) {
auto const &surfaceSemantics = geometry["semantics"][solidIndex][shellIndex][surfaceIndex];
surfaceType = surfaceSemantics["type"];
AzulObject newChild;
newChild.type = surfaceType;
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
newChild.polygons.push_back(newPolygon);
object.children.push_back(newChild);
// std::cout << "Surface semantics: " << geometry["semantics"] << std::endl;
if (geometry["semantics"]["values"].size() > solidIndex &&
!geometry["semantics"]["values"][solidIndex].is_null()) {
if (geometry["semantics"]["values"].size() > shellIndex &&
!geometry["semantics"]["values"][solidIndex][shellIndex].is_null()) {
if (geometry["semantics"]["values"][solidIndex][shellIndex].size() > surfaceIndex &&
!geometry["semantics"]["values"][solidIndex][shellIndex][surfaceIndex].is_null()) {
std::size_t semanticSurfaceIndex = geometry["semantics"]["values"][solidIndex][shellIndex][surfaceIndex];
auto const &surfaceSemantics = geometry["semantics"]["surfaces"][semanticSurfaceIndex];
surfaceType = surfaceSemantics["type"];
std::cout << "Surface type: " << surfaceType << std::endl;
AzulObject newChild;
newChild.type = surfaceType;
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
newChild.polygons.push_back(newPolygon);
object.children.push_back(newChild);
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
object.polygons.push_back(newPolygon);
}
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
object.polygons.push_back(newPolygon);
}
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
object.polygons.push_back(newPolygon);
}
} else {
AzulPolygon newPolygon;
parseCityJSONPolygon(surface, newPolygon, vertices);
Expand Down

0 comments on commit 18cdf0a

Please sign in to comment.