Remove some warnings

This commit is contained in:
Alexander Bock
2021-10-11 13:38:00 +02:00
parent aa2c94fa4c
commit 7c7e5b2999
4 changed files with 78 additions and 61 deletions

View File

@@ -891,7 +891,9 @@ bool initialize(TileProvider& tp) {
ghoul_assert(!tp.isInitialized, "TileProvider can only be initialized once.");
if (TileProvider::NumTileProviders > std::numeric_limits<uint16_t>::max() - 1) {
if (TileProvider::NumTileProviders >
static_cast<unsigned int>(std::numeric_limits<uint16_t>::max()) - 1)
{
LERRORC(
"TileProvider",
"Number of tile providers exceeds 65535. Something will break soon"

View File

@@ -67,7 +67,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
void (*grad)(double *, double *, int, void *, LMstat*),
void *fdata, LMstat *lmstat) {
int x, i, j, it, nit, ill;
int x, j, it, nit, ill;
bool verbose;
std::string data;
double lambda, up, down, mult, weight, err, newerr, derr, target_derr;
@@ -86,7 +86,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
defer {
// deallocate the arrays
for (i = 0; i < npar; i++) {
for (int i = 0; i < npar; i++) {
delete[] h[i];
delete[] ch[i];
}
@@ -109,7 +109,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
if (verbose) {
std::ostringstream qs, gs, ds, ps, oss;
for (i = 0; i < npar; ++i) {
for (int i = 0; i < npar; ++i) {
qs << "q" << i;
gs << "g" << i;
ds << "d" << i;
@@ -119,7 +119,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
ds << ",";
}
}
for (i = 0; i < ny; ++i) {
for (int i = 0; i < ny; ++i) {
for (j = 0; j < 2; ++j) {
std::string s = (j == 0) ? "x" : "y";
ps << "p" << i << s;
@@ -153,7 +153,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
}
// calculate the approximation to the Hessian and the "derivative" d
for (i = 0; i < npar; i++) {
for (int i = 0; i < npar; i++) {
d[i] = 0;
for (j = 0; j <= i; j++) {
h[i][j] = 0;
@@ -164,7 +164,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
weight = 1 / dysq[x]; // for weighted least-squares
}
grad(g, par, x, fdata, lmstat);
for (i = 0; i < npar; i++) {
for (int i = 0; i < npar; i++) {
d[i] += (0.0 - func(par, x, fdata, lmstat)) * g[i] * weight; //(y[x] - func(par, x, fdata)) * g[i] * weight;
for (j = 0; j <= i; j++) {
h[i][j] += g[i] * g[j] * weight;
@@ -175,13 +175,13 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
mult = 1 + lambda;
ill = 1; // ill-conditioned?
while (ill && (it < nit)) {
for (i = 0; i < npar; i++) {
for (int i = 0; i < npar; i++) {
h[i][i] = h[i][i] * mult;
}
ill = cholesky_decomp(npar, ch, h);
if (!ill) {
solve_axb_cholesky(npar, ch, delta, d);
for (i = 0; i < npar; i++) {
for (int i = 0; i < npar; i++) {
newpar[i] = par[i] + delta[i];
}
lmstat->pos.clear();
@@ -197,7 +197,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
printf("\n");*/
std::ostringstream gString, qString, dString, pString, os;
for (i = 0; i < npar; ++i) {
for (int i = 0; i < npar; ++i) {
gString << g[i];
qString << par[i];
dString << d[i];
@@ -207,7 +207,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
dString << ",";
}
}
for (i = 0; i < ny; ++i) {
for (int i = 0; i < ny; ++i) {
pString << lmstat->pos.at(i).x << "," << lmstat->pos.at(i).y;
if (i + 1 < ny) {
pString << ",";
@@ -222,7 +222,7 @@ bool levmarq(int npar, double *par, int ny, double *dysq,
it++;
}
}
for (i = 0; i < npar; i++) {
for (int i = 0; i < npar; i++) {
par[i] = newpar[i];
}
err = newerr;

View File

@@ -758,7 +758,7 @@ void Scene::processPropertyValueTableEntries(ghoul::lua::LuaState& L,
try {
table.push_back(std::get<T>(tableElement));
}
catch (std::bad_variant_access& e) {
catch (std::bad_variant_access&) {
LERROR(fmt::format(
"Error attempting to parse profile property setting for "
"{} using value = {}", _profilePropertyName, value

View File

@@ -51,7 +51,8 @@ namespace {
{
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Ra or Dec '{}' format is incorrect. Correct format is: Ra 'XhYmZs', "
"and Dec 'XdYmZs'", str));
"and Dec 'XdYmZs'", str
));
}
// Construct the number strings
@@ -66,7 +67,8 @@ namespace {
if (std::floor(temp) != temp) {
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Ra or Dec '{}' format is incorrect. Correct format is: Ra 'XhYmZs', "
"and Dec 'XdYmZs', where X must be an integer", str));
"and Dec 'XdYmZs', where X must be an integer", str
));
}
hoursOrDegrees = std::stoi(sHoursOrDegrees);
@@ -75,83 +77,90 @@ namespace {
if (std::floor(temp) != temp) {
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Ra or Dec '{}' format is incorrect. Correct format is: Ra 'XhYmZs', "
"and Dec 'XdYmZs', where Y must be an integer", str));
"and Dec 'XdYmZs', where Y must be an integer", str
));
}
minutes = std::stoi(sMinutes);
// Seconds is a double
seconds = std::stod(sSeconds);
} catch (const std::invalid_argument& ia) {
}
catch (const std::invalid_argument&) {
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Ra or Dec '{}' format is incorrect. Correct format is: Ra 'XhYmZs', "
"and Dec 'XdYmZs'", str));
"and Dec 'XdYmZs'", str
));
}
}
void parseRa(const std::string& ra, int& hours, int& minutes, double& seconds) {
if (ra.find('d') != std::string::npos) {
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Ra '{}' format is incorrect. Correct format is: 'XhYmZs'", ra));
"Ra '{}' format is incorrect. Correct format is: 'XhYmZs'", ra
));
}
parseString(ra, hours, minutes, seconds);
}
void parseDec(const std::string& dec, int& degrees, int& minutes,
double& seconds)
{
void parseDec(const std::string& dec, int& degrees, int& minutes, double& seconds) {
if (dec.find('h') != std::string::npos) {
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Dec '{}' format is incorrect. Correct format is: 'XdYmZs'", dec));
"Dec '{}' format is incorrect. Correct format is: 'XdYmZs'", dec
));
}
parseString(dec, degrees, minutes, seconds);
}
bool isRaDecValid(int raH, int raM, double raS, int decD,
int decM, double decS)
{
bool isRaDecValid(int raH, int raM, double raS, int decD, int decM, double decS) {
// Ra
if (raH < 0.0 || raH >= 24.0) {
LWARNING(fmt::format("Right ascension hours '{}' is outside the allowed "
"range of 0 to 24 hours (exclusive)", raH)
);
LWARNING(fmt::format(
"Right ascension hours '{}' is outside the allowed range of 0 to 24 "
"hours (exclusive)", raH
));
return false;
}
if (raM < 0.0 || raM >= 60.0) {
LWARNING(fmt::format("Right ascension minutes '{}' is outside the allowed "
"range of 0 to 60 minutes (exclusive)", raM)
);
LWARNING(fmt::format(
"Right ascension minutes '{}' is outside the allowed range of 0 to 60 "
"minutes (exclusive)", raM
));
return false;
}
if (raS < 0.0 || raS >= 60.0) {
LWARNING(fmt::format("Right ascension seconds '{}' is outside the allowed "
"range of 0 to 60 seconds (exclusive)", raS)
);
LWARNING(fmt::format(
"Right ascension seconds '{}' is outside the allowed "
"range of 0 to 60 seconds (exclusive)", raS
));
return false;
}
// Dec
if (decD < -90.0 || decD > 90.0) {
LWARNING(fmt::format("Declination degrees '{}' is outside the allowed range "
"of -90 to 90 degrees (inclusive)", decD)
);
"of -90 to 90 degrees (inclusive)", decD
));
return false;
}
else if ((decD == -90.0 || decD == 90.0) && (decM != 0 || decS != 0)) {
LWARNING("Total declination is outside the allowed range of -90 to 90 "
"degrees (inclusive)"
LWARNING(
"Total declination is outside the allowed range of -90 to 90 degrees "
"(inclusive)"
);
return false;
}
if (decM < 0.0 || decM >= 60.0) {
LWARNING(fmt::format("Declination minutes '{}' is outside the allowed range "
"of 0 to 60 minutes (exclusive)", decM)
);
LWARNING(fmt::format(
"Declination minutes '{}' is outside the allowed range of 0 to 60 "
"minutes (exclusive)", decM
));
return false;
}
if (decS < 0.0 || decS >= 60.0) {
LWARNING(fmt::format("Declination seconds '{}' is outside the allowed range "
"of 0 to 60 seconds (exclusive)", decS)
);
LWARNING(fmt::format(
"Declination seconds '{}' is outside the allowed range of 0 to 60 "
"seconds (exclusive)", decS
));
return false;
}
@@ -191,12 +200,14 @@ glm::dvec3 icrsToGalacticCartesian(double ra, double dec, double distance) {
// Dec format 'XdYmZs', where X is a signed integer, Y is a positive integer and Z is a
// positive double
// Reference:
// https://math.stackexchange.com/questions/15323/how-do-i-calculate-the-cartesian-coordinates-of-stars
// https://math.stackexchange.com/questions/15323/how-do-i-calculate-the-cartesian-
// coordinates-of-stars
glm::dvec2 icrsToDecimalDegrees(const std::string& ra, const std::string& dec) {
if (ra.size() < 6 || dec.size() < 6) {
throw ghoul::lua::LuaRuntimeException(fmt::format(
"Ra '{}' or Dec '{}' format is incorrect. Correct format is: Ra 'XhYmZs', "
"and Dec 'XdYmZs'", ra, dec));
"and Dec 'XdYmZs'", ra, dec
));
}
// Parse right ascension
@@ -218,9 +229,10 @@ glm::dvec2 icrsToDecimalDegrees(const std::string& ra, const std::string& dec) {
);
if (!isValid) {
LWARNING(fmt::format("Ra '{}' or Dec '{}' is outside the allowed range, "
"result may be incorrect", ra, dec)
);
LWARNING(fmt::format(
"Ra '{}' or Dec '{}' is outside the allowed range, result may be incorrect",
ra, dec
));
}
// Convert from hours/degrees, minutes, seconds to decimal degrees
@@ -266,7 +278,8 @@ glm::dvec3 galacticCartesianToIcrs(double x, double y, double z) {
// Return a pair with two formatted strings from the decimal degrees ra and dec
// References:
// https://www.rapidtables.com/convert/number/degrees-to-degrees-minutes-seconds.html,
// https://math.stackexchange.com/questions/15323/how-do-i-calculate-the-cartesian-coordinates-of-stars
// https://math.stackexchange.com/questions/15323/how-do-i-calculate-the-cartesian-
// coordinates-of-stars
std::pair<std::string, std::string> decimalDegreesToIcrs(double ra, double dec) {
// Radians to degrees
double raDeg = ra;
@@ -274,21 +287,22 @@ std::pair<std::string, std::string> decimalDegreesToIcrs(double ra, double dec)
// Check input
if (raDeg < 0 || raDeg > 360 || decDeg < -90 || decDeg > 90) {
LWARNING(fmt::format("Given Ra '{}' or Dec '{}' is outside the allowed range, "
"result may be incorrect", ra, dec)
);
LWARNING(fmt::format(
"Ra '{}' or Dec '{}' is outside the allowed range, result may be incorrect",
ra, dec
));
}
// Calculate Ra
int raHours = std::trunc(raDeg) / 15.0;
int raHours = static_cast<int>(std::trunc(raDeg) / 15.0);
double raMinutesFull = (raDeg - raHours * 15.0) * 60.0 / 15.0;
int raMinutes = std::trunc(raMinutesFull);
int raMinutes = static_cast<int>(std::trunc(raMinutesFull));
double raSeconds = (raMinutesFull - raMinutes) * 60.0;
// Calculate Dec
int decDegrees = std::trunc(decDeg);
int decDegrees = static_cast<int>(std::trunc(decDeg));
double decMinutesFull = (abs(decDeg) - abs(decDegrees)) * 60.0;
int decMinutes = std::trunc(decMinutesFull);
int decMinutes = static_cast<int>(std::trunc(decMinutesFull));
double decSeconds = (decMinutesFull - decMinutes) * 60.0;
// Construct strings
@@ -311,9 +325,10 @@ std::pair<std::string, std::string> decimalDegreesToIcrs(double ra, double dec)
);
if (!isValid) {
LWARNING(fmt::format("Resulting Ra '{}' or Dec '{}' is outside the allowed range, "
"result may be incorrect", result.first, result.second)
);
LWARNING(fmt::format(
"Resulting Ra '{}' or Dec '{}' is outside the allowed range, result may be "
"incorrect", result.first, result.second
));
}
return result;
}