Lowercased some consts

This commit is contained in:
eriedaberrie 2024-01-08 22:53:24 -08:00
parent 11ed6e0e7d
commit ffd9247a21

View file

@ -64,12 +64,12 @@ int main(int argc, char *argv[]) {
switch (argc - optind) {
case 0: {
res_loc = NULL;
for (const auto &FE : std::filesystem::directory_iterator(".")) {
if (!FE.is_regular_file())
for (const auto& fe : std::filesystem::directory_iterator(".")) {
if (!fe.is_regular_file())
continue;
const auto FP = FE.path();
if (FP.extension() != ".shp")
const auto fp = fe.path();
if (fp.extension() != ".shp")
continue;
if (res_loc != NULL) {
@ -78,10 +78,10 @@ int main(int argc, char *argv[]) {
break;
}
const std::string FPS = FP;
res_loc = static_cast<char *>(malloc((FPS.size() + 1) * sizeof(*res_loc)));
FPS.copy(res_loc, FPS.size());
res_loc[FPS.size()] = '\0';
const std::string fps = fp;
res_loc = static_cast<char *>(malloc((fps.size() + 1) * sizeof(*res_loc)));
fps.copy(res_loc, fps.size());
res_loc[fps.size()] = '\0';
}
if (res_loc == NULL) {
std::cerr << "Failed to automatically find residents shapefile!" << std::endl;
@ -97,11 +97,11 @@ int main(int argc, char *argv[]) {
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;
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) {
std::cerr << "Expected point data from " << res_loc << "!" << std::endl;
return 1;
@ -109,61 +109,61 @@ int main(int argc, char *argv[]) {
std::vector<std::pair<double, double>> residentials;
for (auto i = 0; i < res_n; i++) {
const auto RES_P = SHPReadObject(RES_H, i);
residentials.push_back(std::make_pair(RES_P->padfX[0], RES_P->padfY[0]));
SHPDestroyObject(RES_P);
const auto res_p = SHPReadObject(res_h, i);
residentials.push_back(std::make_pair(res_p->padfX[0], res_p->padfY[0]));
SHPDestroyObject(res_p);
}
SHPClose(RES_H);
SHPClose(res_h);
std::cout << "Reading fires data..." << std::endl;
std::vector<month_info> all_fires;
for (const auto& MONTH_ENTRY : std::filesystem::directory_iterator(fire_dir)) {
if (!std::filesystem::is_directory(MONTH_ENTRY))
for (const auto& month_entry : std::filesystem::directory_iterator(fire_dir)) {
if (!std::filesystem::is_directory(month_entry))
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;
unsigned long long n_fires_month = 0;
for (const auto& DAY_ENTRY : std::filesystem::directory_iterator(MONTH_ENTRY)) {
const auto FP = DAY_ENTRY.path();
if (FP.extension() != ".shp")
for (const auto& day_entry : std::filesystem::directory_iterator(month_entry)) {
const auto fp = day_entry.path();
if (fp.extension() != ".shp")
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;
SHPGetInfo(FIRE_H, &fire_n, &fire_type, NULL, NULL);
SHPGetInfo(fire_h, &fire_n, &fire_type, NULL, NULL);
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;
}
std::vector<std::pair<double, double>> fires;
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;
bool northp;
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));
SHPDestroyObject(FIRE_P);
SHPDestroyObject(fire_p);
}
SHPClose(FIRE_H);
SHPClose(fire_h);
if (do_sort)
n_fires_month += fire_n;
all_days[DAY] = std::move(fires);
all_days[day] = std::move(fires);
}
all_fires.push_back(month_info{
n_fires_month,
MONTH,
month,
std::move(all_days),
});
}