mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Improved error handling
This commit is contained in:
parent
ce57350a55
commit
d307ef4b98
@ -26,6 +26,11 @@ public:
|
|||||||
CalibrationPoint(PointD xy, PointD pp) : _xy(xy), _pp(pp) {}
|
CalibrationPoint(PointD xy, PointD pp) : _xy(xy), _pp(pp) {}
|
||||||
CalibrationPoint(PointD xy, Coordinates c) : _xy(xy), _ll(c) {}
|
CalibrationPoint(PointD xy, Coordinates c) : _xy(xy), _ll(c) {}
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return !(_xy.isNull() || (_pp.isNull() && !_ll.isValid()));
|
||||||
|
}
|
||||||
|
|
||||||
ReferencePoint rp(const Projection &projection) const
|
ReferencePoint rp(const Projection &projection) const
|
||||||
{
|
{
|
||||||
return (_pp.isNull())
|
return (_pp.isNull())
|
||||||
@ -94,7 +99,7 @@ static Projection parseProjection(const QString &str, const GCS *gcs)
|
|||||||
bool RMap::parseIMP(const QByteArray &data)
|
bool RMap::parseIMP(const QByteArray &data)
|
||||||
{
|
{
|
||||||
QStringList lines = QString(data).split("\r\n");
|
QStringList lines = QString(data).split("\r\n");
|
||||||
QList<CalibrationPoint> cp;
|
QList<CalibrationPoint> calibrationPoints;
|
||||||
const GCS *gcs = 0;
|
const GCS *gcs = 0;
|
||||||
QString projection, datum;
|
QString projection, datum;
|
||||||
QRegExp re("^P[0-9]+=");
|
QRegExp re("^P[0-9]+=");
|
||||||
@ -108,23 +113,29 @@ bool RMap::parseIMP(const QByteArray &data)
|
|||||||
datum = line.split("=").at(1);
|
datum = line.split("=").at(1);
|
||||||
else if (line.contains(re)) {
|
else if (line.contains(re)) {
|
||||||
QString point(line.split("=").at(1));
|
QString point(line.split("=").at(1));
|
||||||
cp.append(parseCalibrationPoint(point));
|
CalibrationPoint cp(parseCalibrationPoint(point));
|
||||||
|
if (cp.isValid())
|
||||||
|
calibrationPoints.append(cp);
|
||||||
|
else {
|
||||||
|
_errorString = point + ": invalid calibration point";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(gcs = GCS::gcs(datum))) {
|
if (!(gcs = GCS::gcs(datum))) {
|
||||||
_errorString = datum + ": invalid datum";
|
_errorString = datum + ": unknown/invalid datum";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_projection = parseProjection(projection, gcs);
|
_projection = parseProjection(projection, gcs);
|
||||||
if (!_projection.isValid()) {
|
if (!_projection.isValid()) {
|
||||||
_errorString = projection + ": invalid projection";
|
_errorString = projection + ": unknown/invalid projection";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ReferencePoint> rp;
|
QList<ReferencePoint> rp;
|
||||||
for (int i = 0; i < cp.size(); i++)
|
for (int i = 0; i < calibrationPoints.size(); i++)
|
||||||
rp.append(cp.at(i).rp(_projection));
|
rp.append(calibrationPoints.at(i).rp(_projection));
|
||||||
|
|
||||||
_transform = Transform(rp);
|
_transform = Transform(rp);
|
||||||
if (!_transform.isValid()) {
|
if (!_transform.isValid()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user