summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-08-17 10:36:03 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-08-17 10:47:54 (GMT)
commitd51147bce4544b5ece28407d17fbbe4bb2498a9e (patch)
treed5fbced314084bab8c0e318e0903d39635b41aab
parent234259d760a446ca7f1edf07672b7f8c24e6472f (diff)
Parse magnitudes correctly from Sesame XML result
The code parses magnitude tags of two kinds: Returned by SIMBAD: <mag band="B"><v>19.26</v><q>C</q><r>1989ESOLV.C......0L</r></mag> Not returned by any of the databases, but "just in case": <mag band="B">19.26</mag>
-rw-r--r--kstars/tools/nameresolver.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/kstars/tools/nameresolver.cpp b/kstars/tools/nameresolver.cpp
index 7067d34..c517959 100644
--- a/kstars/tools/nameresolver.cpp
+++ b/kstars/tools/nameresolver.cpp
@@ -110,18 +110,38 @@ bool NameResolver::NameResolverInternals::sesameResolver( class CatalogEntryData
attributes = xml.attributes();
char band;
if( attributes.hasAttribute( "band" ) ) {
- attributes.value("band").at(0).toLatin1();
+ band = attributes.value("band").at(0).toLatin1();
}
else {
qWarning() << "Warning: Magnitude of unknown band found while reading output from CDS Sesame";
band = 0;
}
+ float mag = NaN::f;
+ xml.readNext();
+ if( xml.isCharacters() ) {
+ qDebug() << "characters: " << xml.tokenString();
+ mag = xml.tokenString().toFloat();
+ }
+ else if( xml.isStartElement() ) {
+ while( xml.name() != "v" ) {
+ qDebug() << "element: " << xml.name();
+ xml.readNextStartElement();
+ }
+ mag = xml.readElementText().toFloat();
+ qDebug() << "Got " << xml.tokenString() << " mag = " << mag;
+ while( !xml.atEnd() && xml.readNext() && xml.name() != "mag" ); // finish reading the <mag> tag all the way to </mag>
+ }
+ else
+ qWarning() << "Failed to parse Xml token in magnitude element: " << xml.tokenString();
+
if( band == 'V' ) {
- data.magnitude = xml.readElementText().toFloat();
+ data.magnitude = mag;
}
else if( band == 'B' ) {
- data.flux = xml.readElementText().toFloat(); // FIXME: This is bad
+ data.flux = mag; // FIXME: This is bad
+ if( std::isnan( data.magnitude ) )
+ data.magnitude = mag; // FIXME: This is bad too
}
// Don't know what to do with other magnitudes, until we have a magnitude hash
}