mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
Make more use of temporary string objects in the TimeQuantizer
Add GPU markers to the rendering
This commit is contained in:
@@ -278,9 +278,9 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time&
|
||||
|
||||
switch (type) {
|
||||
case TemporalTileProvider::TimeFormatType::YYYY_MM_DD:
|
||||
return t.ISO8601().substr(0, 10);
|
||||
return std::string(t.ISO8601().substr(0, 10));
|
||||
case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmmss: {
|
||||
std::string ts = t.ISO8601().substr(0, 19);
|
||||
std::string ts = std::string(t.ISO8601().substr(0, 19));
|
||||
|
||||
// YYYY_MM_DDThh_mm_ss -> YYYYMMDD_hhmmss
|
||||
ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end());
|
||||
@@ -289,7 +289,7 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time&
|
||||
return ts;
|
||||
}
|
||||
case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmm: {
|
||||
std::string ts = t.ISO8601().substr(0, 16);
|
||||
std::string ts = std::string(t.ISO8601().substr(0, 16));
|
||||
|
||||
// YYYY_MM_DDThh_mm -> YYYYMMDD_hhmm
|
||||
ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end());
|
||||
@@ -298,9 +298,9 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time&
|
||||
return ts;
|
||||
}
|
||||
case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThhColonmmColonssZ:
|
||||
return t.ISO8601().substr(0, 19) + "Z";
|
||||
return std::string(t.ISO8601().substr(0, 19)) + "Z";
|
||||
case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThh_mm_ssZ: {
|
||||
std::string timeString = t.ISO8601().substr(0, 19) + "Z";
|
||||
std::string timeString = std::string(t.ISO8601().substr(0, 19)) + "Z";
|
||||
replace(timeString.begin(), timeString.end(), ':', '_');
|
||||
return timeString;
|
||||
}
|
||||
@@ -423,7 +423,10 @@ std::string consumeTemporalMetaData(TemporalTileProvider& t, const std::string&
|
||||
}
|
||||
|
||||
try {
|
||||
t.timeQuantizer.setStartEndRange(start.ISO8601(), end.ISO8601());
|
||||
t.timeQuantizer.setStartEndRange(
|
||||
std::string(start.ISO8601()),
|
||||
std::string(end.ISO8601())
|
||||
);
|
||||
t.timeQuantizer.setResolution(timeResolution);
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
|
||||
@@ -137,11 +137,11 @@ std::string RangedTime::clamp(const std::string& checkTime) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string RangedTime::start() const {
|
||||
std::string_view RangedTime::start() const {
|
||||
return _start;
|
||||
}
|
||||
|
||||
std::string RangedTime::end() const {
|
||||
std::string_view RangedTime::end() const {
|
||||
return _end;
|
||||
}
|
||||
|
||||
@@ -174,10 +174,14 @@ std::string DateTime::ISO8601() const {
|
||||
};
|
||||
|
||||
double DateTime::J2000() const {
|
||||
Time t;
|
||||
std::string timeString = ISO8601();
|
||||
t.setTime(timeString);
|
||||
return t.j2000Seconds();
|
||||
char Buffer[20];
|
||||
std::memset(Buffer, 0, 20);
|
||||
fmt::format_to(
|
||||
Buffer,
|
||||
"{:0>4}-{:0>2}-{:0>2}T{:0>2}:{:0>2}:{:0>2}",
|
||||
_year, _month, _day, _hour, _minute, _second
|
||||
);
|
||||
return Time::convertTime(Buffer);
|
||||
}
|
||||
|
||||
void DateTime::operator=(DateTime& src) {
|
||||
@@ -471,7 +475,7 @@ double TimeQuantizer::computeSecondsFromResolution(const int valueIn, const char
|
||||
bool TimeQuantizer::quantize(Time& t, bool clamp) {
|
||||
ZoneScoped
|
||||
|
||||
const std::string unquantizedStr = t.ISO8601();
|
||||
std::string_view unquantizedStr = t.ISO8601();
|
||||
DateTime unquantized(unquantizedStr);
|
||||
// resolutionFraction helps to improve iteration performance
|
||||
constexpr const double ResolutionFraction = 0.7;
|
||||
@@ -514,7 +518,7 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) {
|
||||
return true;
|
||||
}
|
||||
else if (clamp) {
|
||||
const std::string clampedTime = _timerange.clamp(unquantizedStr);
|
||||
const std::string clampedTime = _timerange.clamp(std::string(unquantizedStr));
|
||||
t.setTime(clampedTime);
|
||||
return true;
|
||||
}
|
||||
@@ -612,7 +616,7 @@ std::vector<std::string> TimeQuantizer::quantized(Time& start, Time& end) {
|
||||
|
||||
std::vector<std::string> result;
|
||||
DateTime itr = s;
|
||||
RangedTime range(start.ISO8601(), end.ISO8601());
|
||||
RangedTime range(std::string(start.ISO8601()), std::string(end.ISO8601()));
|
||||
while (range.includes(Time(itr.ISO8601()))) {
|
||||
itr.incrementOnce(static_cast<int>(_resolutionValue), _resolutionUnit);
|
||||
result.push_back(itr.ISO8601());
|
||||
|
||||
@@ -76,14 +76,14 @@ public:
|
||||
*
|
||||
* \returns The ISO8601 date/time string that defines the start of the range
|
||||
*/
|
||||
std::string start() const;
|
||||
std::string_view start() const;
|
||||
|
||||
/*
|
||||
* Get the end date/time of the time range
|
||||
*
|
||||
* \returns The ISO8601 date/time string that defines the end of the range
|
||||
*/
|
||||
std::string end() const;
|
||||
std::string_view end() const;
|
||||
|
||||
/*
|
||||
* Set the start date/time of the time range
|
||||
|
||||
Reference in New Issue
Block a user