[Kstars-devel] branches/kstars/summer/kstars/kstars/comast

Prakash Mohan prak902000 at gmail.com
Tue Jul 14 22:49:25 CEST 2009


SVN commit 996759 by prakash:

Adding support for reading sites from OAL compliant XML logs

CCMAIL: kstars-devel at kde.org


 M  +43 -0     log.cpp  
 M  +2 -0      log.h  
 M  +1 -0      site.h  


--- branches/kstars/summer/kstars/kstars/comast/log.cpp #996758:996759
@@ -393,6 +393,8 @@
                 readTargets();
            else if( reader->name() == "observers" )
                 readObservers();
+           else if( reader->name() == "sites" )
+                readSites();
            else if( reader->name() == "geodate" )
                 readGeoDate();
             else
@@ -433,6 +435,22 @@
     }
 }
 
+void Comast::Log::readSites() {
+    while( ! reader->atEnd() ) {
+        reader->readNext();
+
+        if( reader->isEndElement() )
+            break;
+
+        if( reader->isStartElement() ) {
+            if( reader->name() == "site" )
+                readSite();
+            else
+                readUnknownElement();
+        }
+    }
+}
+
 void Comast::Log::readTarget() {
     SkyObject *o = NULL;
     while( ! reader->atEnd() ) {
@@ -491,6 +509,31 @@
     m_observerList.append( o );
 }
 
+void Comast::Log::readSite() {
+    QString name, latUnit, lonUnit, lat, lon;
+    while( ! reader->atEnd() ) {
+        reader->readNext();
+
+        if( reader->isEndElement() )
+            break;
+
+        if( reader->isStartElement() ) {
+            if( reader->name() == "name" ) {
+                name = reader->readElementText();
+            } else if( reader->name() == "latitude" ) {
+                lat = reader->readElementText() ;
+                latUnit = reader->attributes().value( "unit" ).toString();
+            } else if( reader->name() == "longitude" ) {
+                lon = reader->readElementText() ;
+                lonUnit = reader->attributes().value( "unit" ).toString();
+            } else
+                readUnknownElement();
+        }
+    }
+    Comast::Site *o= new Comast::Site( name, lat.toDouble(), latUnit, lon.toDouble(), lonUnit );
+    m_siteList.append( o );
+}
+
 void Comast::Log::readPosition() {
     while( ! reader->atEnd() ) {
         reader->readNext();
--- branches/kstars/summer/kstars/kstars/comast/log.h #996758:996759
@@ -68,8 +68,10 @@
         void readUnknownElement();
         void readTargets();
         void readObservers();
+        void readSites();
         void readTarget();
         void readObserver();
+        void readSite();
         void readPosition();
         void readGeoDate();
     private:
--- branches/kstars/summer/kstars/kstars/comast/site.h #996758:996759
@@ -24,6 +24,7 @@
 
 class Comast::Site {
     public:
+       Site( QString name, double lat, QString latUnit, double lon, QString lonUnit ) { setSite( name, lat, latUnit, lon, lonUnit ); }
        QString name() { return m_Name; }
        double latitude() { return m_Lat; }
        QString latUnit() { return m_LatUnit; }


More information about the Kstars-devel mailing list