Lowercased some consts
This commit is contained in:
parent
947d0c8a60
commit
98604b0f91
60
src/main.cpp
60
src/main.cpp
|
@ -64,12 +64,12 @@ int main(int argc, char *argv[]) {
|
||||||
switch (argc - optind) {
|
switch (argc - optind) {
|
||||||
case 0: {
|
case 0: {
|
||||||
res_loc = NULL;
|
res_loc = NULL;
|
||||||
for (const auto &FE : std::filesystem::directory_iterator(".")) {
|
for (const auto& fe : std::filesystem::directory_iterator(".")) {
|
||||||
if (!FE.is_regular_file())
|
if (!fe.is_regular_file())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto FP = FE.path();
|
const auto fp = fe.path();
|
||||||
if (FP.extension() != ".shp")
|
if (fp.extension() != ".shp")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (res_loc != NULL) {
|
if (res_loc != NULL) {
|
||||||
|
@ -78,10 +78,10 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string FPS = FP;
|
const std::string fps = fp;
|
||||||
res_loc = static_cast<char *>(malloc((FPS.size() + 1) * sizeof(*res_loc)));
|
res_loc = static_cast<char *>(malloc((fps.size() + 1) * sizeof(*res_loc)));
|
||||||
FPS.copy(res_loc, FPS.size());
|
fps.copy(res_loc, fps.size());
|
||||||
res_loc[FPS.size()] = '\0';
|
res_loc[fps.size()] = '\0';
|
||||||
}
|
}
|
||||||
if (res_loc == NULL) {
|
if (res_loc == NULL) {
|
||||||
std::cerr << "Failed to automatically find residents shapefile!" << std::endl;
|
std::cerr << "Failed to automatically find residents shapefile!" << std::endl;
|
||||||
|
@ -97,11 +97,11 @@ int main(int argc, char *argv[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto RES_H = SHPOpen(res_loc, "rb");
|
const auto res_h = SHPOpen(res_loc, "rb");
|
||||||
|
|
||||||
std::cout << "Reading residents data..." << std::endl;
|
std::cout << "Reading residents data..." << std::endl;
|
||||||
int res_n, res_type;
|
int res_n, res_type;
|
||||||
SHPGetInfo(RES_H, &res_n, &res_type, NULL, NULL);
|
SHPGetInfo(res_h, &res_n, &res_type, NULL, NULL);
|
||||||
if (res_type != SHPT_POINT) {
|
if (res_type != SHPT_POINT) {
|
||||||
std::cerr << "Expected point data from " << res_loc << "!" << std::endl;
|
std::cerr << "Expected point data from " << res_loc << "!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -109,61 +109,61 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
std::vector<std::pair<double, double>> residentials;
|
std::vector<std::pair<double, double>> residentials;
|
||||||
for (auto i = 0; i < res_n; i++) {
|
for (auto i = 0; i < res_n; i++) {
|
||||||
const auto RES_P = SHPReadObject(RES_H, i);
|
const auto res_p = SHPReadObject(res_h, i);
|
||||||
residentials.push_back(std::make_pair(RES_P->padfX[0], RES_P->padfY[0]));
|
residentials.push_back(std::make_pair(res_p->padfX[0], res_p->padfY[0]));
|
||||||
SHPDestroyObject(RES_P);
|
SHPDestroyObject(res_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHPClose(RES_H);
|
SHPClose(res_h);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "Reading fires data..." << std::endl;
|
std::cout << "Reading fires data..." << std::endl;
|
||||||
std::vector<month_info> all_fires;
|
std::vector<month_info> all_fires;
|
||||||
for (const auto& MONTH_ENTRY : std::filesystem::directory_iterator(fire_dir)) {
|
for (const auto& month_entry : std::filesystem::directory_iterator(fire_dir)) {
|
||||||
if (!std::filesystem::is_directory(MONTH_ENTRY))
|
if (!std::filesystem::is_directory(month_entry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string MONTH = MONTH_ENTRY.path().filename();
|
const std::string month = month_entry.path().filename();
|
||||||
std::map<std::string, std::vector<std::pair<double, double>>> all_days;
|
std::map<std::string, std::vector<std::pair<double, double>>> all_days;
|
||||||
unsigned long long n_fires_month = 0;
|
unsigned long long n_fires_month = 0;
|
||||||
|
|
||||||
for (const auto& DAY_ENTRY : std::filesystem::directory_iterator(MONTH_ENTRY)) {
|
for (const auto& day_entry : std::filesystem::directory_iterator(month_entry)) {
|
||||||
const auto FP = DAY_ENTRY.path();
|
const auto fp = day_entry.path();
|
||||||
if (FP.extension() != ".shp")
|
if (fp.extension() != ".shp")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto DAY = FP.stem().string().substr(8);
|
const auto day = fp.stem().string().substr(8);
|
||||||
|
|
||||||
const auto FIRE_H = SHPOpen(FP.c_str(), "rb");
|
const auto fire_h = SHPOpen(fp.c_str(), "rb");
|
||||||
int fire_n, fire_type;
|
int fire_n, fire_type;
|
||||||
SHPGetInfo(FIRE_H, &fire_n, &fire_type, NULL, NULL);
|
SHPGetInfo(fire_h, &fire_n, &fire_type, NULL, NULL);
|
||||||
if (res_type != SHPT_POINT) {
|
if (res_type != SHPT_POINT) {
|
||||||
std::cerr << "Expected point data from " << FP << "!" << std::endl;
|
std::cerr << "Expected point data from " << fp << "!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<double, double>> fires;
|
std::vector<std::pair<double, double>> fires;
|
||||||
for (auto i = 0; i < fire_n; i++) {
|
for (auto i = 0; i < fire_n; i++) {
|
||||||
const auto FIRE_P = SHPReadObject(FIRE_H, i);
|
const auto fire_p = SHPReadObject(fire_h, i);
|
||||||
int zone;
|
int zone;
|
||||||
bool northp;
|
bool northp;
|
||||||
double x, y;
|
double x, y;
|
||||||
GeographicLib::UTMUPS::Forward(FIRE_P->padfY[0], FIRE_P->padfX[0], zone, northp, x, y);
|
GeographicLib::UTMUPS::Forward(fire_p->padfY[0], fire_p->padfX[0], zone, northp, x, y);
|
||||||
fires.push_back(std::make_pair(x, y));
|
fires.push_back(std::make_pair(x, y));
|
||||||
SHPDestroyObject(FIRE_P);
|
SHPDestroyObject(fire_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHPClose(FIRE_H);
|
SHPClose(fire_h);
|
||||||
|
|
||||||
if (do_sort)
|
if (do_sort)
|
||||||
n_fires_month += fire_n;
|
n_fires_month += fire_n;
|
||||||
|
|
||||||
all_days[DAY] = std::move(fires);
|
all_days[day] = std::move(fires);
|
||||||
}
|
}
|
||||||
|
|
||||||
all_fires.push_back(month_info{
|
all_fires.push_back(month_info{
|
||||||
n_fires_month,
|
n_fires_month,
|
||||||
MONTH,
|
month,
|
||||||
std::move(all_days),
|
std::move(all_days),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue