1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Improved error handling

This commit is contained in:
Martin Tůma 2018-01-21 01:01:58 +01:00
parent 6ffc71fd36
commit da220c4b62

View File

@ -65,22 +65,28 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
setup.setStandardParallel2(au.toDegrees(val));} setup.setStandardParallel2(au.toDegrees(val));}
return true; return true;
default: default:
return true; return false;
} }
} }
static int projectionSetup(const QList<QByteArray> &list, static int projectionSetup(const QList<QByteArray> &list,
Projection::Setup &setup) Projection::Setup &setup)
{ {
bool res; bool r1, r2, r3;
for (int i = 6; i < 27; i += 3) { for (int i = 6; i < 27; i += 3) {
int key = list[i].trimmed().toInt(&res); QString ks = list[i].trimmed();
double val = list[i+1].trimmed().toDouble(&res); if (ks.isEmpty())
int un = list[i+2].trimmed().toInt(&res); break;
int key = ks.toInt(&r1);
double val = list[i+1].trimmed().toDouble(&r2);
int un = list[i+2].trimmed().toInt(&r3);
if (!r1 || !r2 || !r3)
return (i - 6)/3 + 1;
if (!parameter(key, val, un, setup)) if (!parameter(key, val, un, setup))
return (i - 6)/3; return (i - 6)/3 + 1;
} }
return 0; return 0;