Skip to content

Commit

Permalink
error message if MVT output folders cannot be created, or tiles canno…
Browse files Browse the repository at this point in the history
…t be written, to debug #12
  • Loading branch information
patrickbr committed Mar 19, 2024
1 parent 499933b commit e658896
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/transitmap/output/MvtRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,32 @@ void MvtRenderer::serializeTile(size_t x, size_t y, size_t z,
ss << _cfg->mvtPath << "/";

ss << z;
mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
int err = mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);

if (err == -1) {
if (errno != EEXIST) {
throw std::runtime_error("Could not create output directory " + ss.str());
}
}

ss << "/" << x;
mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
err = mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);

if (err == -1) {
if (errno != EEXIST) {
throw std::runtime_error("Could not create output directory " + ss.str());
}
}

ss << "/" << ((1 << z) - 1 - y) << ".mvt";

std::fstream fo(ss.str().c_str(),
std::ios::out | std::ios::trunc | std::ios::binary);

if (!fo.is_open()) {
throw std::runtime_error("Could not open " + ss.str());
}

std::string a;

tile->SerializeToString(&a);
Expand Down

0 comments on commit e658896

Please sign in to comment.