[Kstars-devel] KDE/kdeedu/kstars/kstars/skycomponents

Akarsh Simha akarshsimha at gmail.com
Wed Oct 8 13:07:59 CEST 2008


SVN commit 869148 by asimha:

Improving search by HD number. The earlier version used to create a
copy of the real StarObject and center on that, which would cause
problems if the simulation clock was running. This commit hopes to fix
that by finding the "real" StarObject with the given HD number, using
the copy to make the match.

CCMAIL: kstars-devel at kde.org



 M  +37 -0     deepstarcomponent.cpp  
 M  +2 -0      deepstarcomponent.h  
 M  +7 -7      starcomponent.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/deepstarcomponent.cpp #869147:869148
@@ -409,6 +409,43 @@
     return m_CatalogNumber.value( HDnum, NULL ); // TODO: Maybe, make this more general.
 }
 
+SkyObject *DeepStarComponent::findByData( starData &stardata ) {
+    Trixel trixel;
+    StarObject m_starObject;
+
+    m_starObject.init( &stardata );
+    // Which trixel is this star in?
+    trixel = m_skyMesh->indexStar( &m_starObject );
+    // Fill the required trixel
+    m_starBlockList.at( trixel )->fillToMag( m_starObject.mag() );
+    for( int i = 0; i < m_starBlockList.at( trixel )->getBlockCount(); ++i ) {
+        StarBlock *block = m_starBlockList.at( trixel )->block( i );
+        for( int j = 0; j < block->getStarCount(); ++j ) {
+            //            int match = 0;
+            StarObject *star = block->star( j );
+            if( !star )
+                continue;
+            if( star->getHDIndex() == m_starObject.getHDIndex() && star->getHDIndex() != 0 ) {
+                // 100% match
+                return star;
+            }
+            /*
+            // Unused code
+            if( star->mag() == m_starObject.mag() )
+                ++match;
+            if( abs( star->ra()->Degrees() - m_starObject.ra()->Degrees() ) < 0.05 )
+                ++match;
+            if( abs( star->dec()->Degrees() - m_starObject.dec()->Degrees() ) < 0.05 )
+                ++match;
+
+            */
+        }
+    }
+    return NULL;
+}
+
+    
+
 // This uses the main star index for looking up nearby stars but then
 // filters out objects with the generic name "star".  We could easily
 // build an index for just the named stars which would make this go
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/deepstarcomponent.h #869147:869148
@@ -97,6 +97,8 @@
 
     SkyObject* findByHDIndex( int HDnum );
 
+    SkyObject* findByData( starData &stardata );
+
     SkyObject* objectNearest(SkyPoint *p, double &maxrad );
 
     inline bool fileOpen() { return fileOpened; }
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #869147:869148
@@ -539,23 +539,23 @@
         FILE *hdidxFile = hdidxReader.openFile( "Henry-Draper.idx" );
         if( !hdidxFile )
             return 0;
-        FILE *dataFile;
         KDE_fseek( hdidxFile, (HDnum - 1) * 4, SEEK_SET );
         fread( &offset, 4, 1, hdidxFile );
+        hdidxReader.closeFile();
+
         if( offset <= 0 )
             return 0;
+
         // TODO: Implement byteswapping
+        FILE *dataFile;
         dataFile = m_DeepStarComponents.at( 1 )->getStarReader()->getFileHandle();
+
         KDE_fseek( dataFile, offset, SEEK_SET );
         fread( &stardata, sizeof( starData ), 1, dataFile );
         // TODO: Implement byteswapping
         // byteSwap( &stardata );
-        m_starObject.init( &stardata );
-        m_starObject.EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
-        m_starObject.JITupdate( data() );
-        hdidxReader.closeFile();
-        // TODO: Lots of trouble since we are returning a copy. Can we fix that?
-        return &m_starObject;
+
+        return m_DeepStarComponents.at( 1 )->findByData( stardata );
     }
         
     return 0;


More information about the Kstars-devel mailing list