2017-04-05 15:59:37 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
#include <sys/stat.h>
|
2017-05-24 16:32:44 +01:00
|
|
|
#include "dirtiles.hpp"
|
2017-04-05 15:59:37 +01:00
|
|
|
|
2017-05-24 16:32:44 +01:00
|
|
|
void dir_write_tile(const char *outdir, int z, int tx, int ty, std::string const &pbf) {
|
2017-04-05 15:59:37 +01:00
|
|
|
mkdir(outdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
|
|
|
std::string curdir(outdir);
|
2017-04-07 13:33:01 +01:00
|
|
|
std::string slash("/");
|
2017-04-05 16:05:50 +01:00
|
|
|
std::string newdir = curdir + slash + std::to_string(z);
|
2017-04-05 15:59:37 +01:00
|
|
|
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
2017-04-05 16:05:50 +01:00
|
|
|
newdir = newdir + "/" + std::to_string(tx);
|
|
|
|
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
|
|
|
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
|
|
|
|
|
2017-04-07 13:33:01 +01:00
|
|
|
std::ofstream pbfFile(newdir, std::ios::out | std::ios::binary);
|
|
|
|
pbfFile.write(pbf.data(), pbf.size());
|
2017-04-05 16:05:50 +01:00
|
|
|
pbfFile.close();
|
2017-04-07 12:36:34 -07:00
|
|
|
}
|