Skip to content

Commit

Permalink
Better implementation #42
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed May 8, 2024
1 parent 19770ca commit 5b2a87c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
42 changes: 20 additions & 22 deletions src/LASRcore/LAScatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,25 @@ bool LAScatalog::write_vpc(const std::string& vpcfile, const CRS& crs, bool abso
Rectangle& bbox = bboxes[i];
uint64_t n = npoints[i];
bool index = indexed[i];
std::string date = dates[i];

std::string date;
int year = dates[i].first;
int doy = dates[i].second;
if (year > 0)
{
if (doy == 0) doy = 1;
std::tm timeinfo = {};
timeinfo.tm_year = year - 1900;
timeinfo.tm_mday = doy;
std::mktime(&timeinfo);
char buffer[26];
strftime(buffer, 26, "%Y-%m-%dT%H:%M:%SZ", &timeinfo);
date = std::string(buffer);
}
else
{
date = "0-01-01T00:00:00Z";
}

Rectangle bbwgs84 = bbox;
OGRSpatialReference oTargetSRS;
Expand Down Expand Up @@ -413,27 +431,7 @@ bool LAScatalog::add_file(const std::string& file, bool noprocess)
add_crs(&lasreader->header);
add_bbox(lasreader->header.min_x, lasreader->header.min_y, lasreader->header.max_x, lasreader->header.max_y, lasreader->get_index() || lasreader->get_copcindex(), noprocess);
npoints.push_back(MAX(lasreader->header.number_of_point_records, lasreader->header.extended_number_of_point_records));

int year = lasreader->header.file_creation_year;
int doy = lasreader->header.file_creation_day;
if (year > 0)
{
if (doy == 0) doy = 1;
std::tm timeinfo = {};
timeinfo.tm_year = year - 1900;
timeinfo.tm_mday = doy;
std::mktime(&timeinfo);
char buffer[26];
strftime(buffer, 26, "%Y-%m-%dT%H:%M:%SZ", &timeinfo);
std::string date(buffer);
dates.push_back(date);
print("Y %d, D %d\n", year, doy);
print("%s\n", date.c_str());
}
else
{
dates.push_back("0-01-01T00:00:00Z");
}
dates.push_back({lasreader->header.file_creation_year, lasreader->header.file_creation_day});

lasreader->close();
delete lasreader;
Expand Down
2 changes: 1 addition & 1 deletion src/LASRcore/LAScatalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class LAScatalog
std::vector<bool> noprocess; // the file is not processed and is used only for buffering
std::vector<Rectangle> bboxes; // bounding boxes of the files
std::vector<std::filesystem::path> files; // path to files
std::vector<std::string> dates;
std::vector<std::pair<unsigned short, unsigned short>> dates;

// queries, partial read
LASkdtreeRectangles* laskdtree;
Expand Down

0 comments on commit 5b2a87c

Please sign in to comment.