From 628218e9284cc391481a6fb428cfd6d3a46830cb Mon Sep 17 00:00:00 2001 From: Willard Date: Tue, 12 Sep 2023 21:55:51 +0200 Subject: [PATCH] mounts --- src/geojsons.cpp | 35 +++++++++++++++++++++++++++++------ src/geojsons.h | 1 + 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/geojsons.cpp b/src/geojsons.cpp index 12e1eb6..603df12 100644 --- a/src/geojsons.cpp +++ b/src/geojsons.cpp @@ -256,9 +256,7 @@ void writeRoads( GDALAllRegister(); poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if (poDriver == NULL) { - threadLock.lock(); - sqf::diag_log("Couldn't get the GeoJSON Driver"); - threadLock.unlock(); + PLOG_ERROR << "Couldn't get the GeoJSON Driver"; return; } papszMetadata = poDriver->GetMetadata(); @@ -307,9 +305,7 @@ void writeRoads( auto dataSet = GDALVectorTranslate((basePathGeojsonTemp / "roads.geojson").string().c_str(), poDstDS, 1, &poDatasetH, gdalOptions, &error); if (error != 0) { - threadLock.lock(); - sqf::diag_log("GDALVectorTranslate failed!"); - threadLock.unlock(); + PLOG_ERROR << "GDALVectorTranslate failed!"; return; } @@ -819,6 +815,32 @@ void writeRiver(rvff::cxx::OprwCxx& wrp, std::filesystem::path& basePathGeojson) writeGZJson("river.geojson.gz", basePathGeojson, rivers); } +void writeMounts(rvff::cxx::OprwCxx& wrp, fs::path& basePathGeojson) { + + auto mounts = nl::json(); + for (auto& mount : wrp.mountains) { + auto pointFeature = nl::json(); + pointFeature["type"] = "Feature"; + + auto geometry = nl::json(); + geometry["type"] = "Point"; + + auto posArray = nl::json::array(); + posArray.push_back((float_t)mount.x); + posArray.push_back((float_t)mount.z); + geometry["coordinates"] = posArray; + + pointFeature["geometry"] = geometry; + pointFeature["properties"] = nl::json::object(); + pointFeature["properties"]["elevation"] = mount.y; + + mounts.push_back(pointFeature); + } + if (!mounts.is_null() && mounts.is_array() && !mounts.empty()) { + writeGZJson("mounts.geojson.gz", basePathGeojson, mounts); + } +} + void writeGeojsons(rvff::cxx::OprwCxx& wrp, std::filesystem::path& basePathGeojson, const std::string& worldName) { using namespace rvff::cxx; @@ -959,6 +981,7 @@ void writeGeojsons(rvff::cxx::OprwCxx& wrp, std::filesystem::path& basePathGeojs writeSpecialIcons(wrp, basePathGeojson, 2, "bush"); writeSpecialIcons(wrp, basePathGeojson, 11, "rock"); writePowerlines(wrp, basePathGeojson); + writeMounts(wrp, basePathGeojson); writeRunways(basePathGeojson, worldName); diff --git a/src/geojsons.h b/src/geojsons.h index f9110ef..13bcf95 100644 --- a/src/geojsons.h +++ b/src/geojsons.h @@ -51,3 +51,4 @@ void writePowerlines(rvff::cxx::OprwCxx& wrp, fs::path& basePathGeojson); void writeRailways(fs::path& basePathGeojson, const std::vector>& objectPairs); void writeGeojsons(rvff::cxx::OprwCxx& wrp, std::filesystem::path& basePathGeojson, const std::string& worldName); void writeRiver(rvff::cxx::OprwCxx& wrp, std::filesystem::path& basePathGeojson); +void writeMounts(rvff::cxx::OprwCxx& wrp, fs::path& basePathGeojson);