Skip to content

Commit

Permalink
mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWillard committed Sep 12, 2023
1 parent 39a691c commit 628218e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/geojsons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/geojsons.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ void writePowerlines(rvff::cxx::OprwCxx& wrp, fs::path& basePathGeojson);
void writeRailways(fs::path& basePathGeojson, const std::vector<std::pair<rvff::cxx::ObjectCxx, rvff::cxx::LodCxx&>>& 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);

0 comments on commit 628218e

Please sign in to comment.