[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kstars-devel
Subject:    [Kstars-devel] KDE/kdeedu/kstars/kstars/skycomponents
From:       Akarsh Simha <akarshsimha () gmail ! com>
Date:       2008-10-08 10:17:33
Message-ID: 1223461053.440013.19615.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 869142 by asimha:

Implement searching by HD Catalog Number. This is still far from ideal
(especially when the simulation clock is running), but provides
something at least. This bit will break on Big Endian systems as
byte-swapping is not implemented.

The stars are not displayed in the Find Dialog, but can be searched by
typing in 'HD<catalog number>' in the find dialog box. Eg: HD142534.

CCMAIL: kstars-devel@kde.org



 M  +5 -0      deepstarcomponent.cpp  
 M  +2 -0      deepstarcomponent.h  
 M  +36 -10    starcomponent.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/deepstarcomponent.cpp #869141:869142
@@ -404,6 +404,11 @@
 }
 
 
+SkyObject *DeepStarComponent::findByHDIndex( int HDnum ) {
+    // Currently, we only handle HD catalog indexes
+    return m_CatalogNumber.value( HDnum, NULL ); // TODO: Maybe, make this more \
general. +}
+
 // 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 #869141:869142
@@ -95,6 +95,8 @@
 
     float faintMagnitude() const { return m_FaintMagnitude; }
 
+    SkyObject* findByHDIndex( int HDnum );
+
     SkyObject* objectNearest(SkyPoint *p, double &maxrad );
 
     inline bool fileOpen() { return fileOpened; }
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #869141:869142
@@ -95,21 +95,19 @@
 
 int StarComponent::loadDeepStarCatalogs() {
     
-    int count = 0;
-
     // Look for the basic unnamed star catalog to mag 8.0
-    count += addDeepStarCatalogIfExists( "unnamedstars.dat", -5.0, true );
+    if( !addDeepStarCatalogIfExists( "unnamedstars.dat", -5.0, true ) )
+        return 0;
 
     // Look for the Tycho-2 add-on with 2.5 million stars to mag 12.5
-    if( !addDeepStarCatalogIfExists( "tycho2.dat" , 8.0 ) )
-        count += addDeepStarCatalogIfExists( "deepstars.dat", 8.0 );
-    else
-        count += 1;
+    if( !addDeepStarCatalogIfExists( "tycho2.dat" , 8.0 ) && \
!addDeepStarCatalogIfExists( "deepstars.dat", 8.0 ) ) +        return 1;
 
     // Look for the USNO NOMAD 1e8 star catalog add-on with stars to mag 16
-    count += addDeepStarCatalogIfExists( "USNO-NOMAD-1e8.dat", 11.0 );
+    if( !addDeepStarCatalogIfExists( "USNO-NOMAD-1e8.dat", 11.0 ) )
+        return 2;
 
-    return count;
+    return 3;
 }
 
 //This function is empty for a reason; we override the normal 
@@ -473,7 +471,6 @@
             star->init( &stardata );
             star->setNames( name, visibleName );
             star->EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
-
             ++nstars;
             
             if ( ! gname.isEmpty() ) m_genName.insert( gname, star );
@@ -529,9 +526,38 @@
 // TODO: Strongly consider including Deep Star Components inside StarComponent
 SkyObject *StarComponent::findByHDIndex( int HDnum ) {
     SkyObject *o;
+    BinFileHelper hdidxReader;
     // First check the hash to see if we have a corresponding StarObject already
     if( ( o = m_HDHash.value( HDnum, NULL ) ) )
         return o;
+    // If we don't have the StarObject here, try it in the DeepStarComponents' \
hashes +    if( m_DeepStarComponents.size() >= 1 )
+        if( ( o = m_DeepStarComponents.at( 0 )->findByHDIndex( HDnum ) ) )
+            return o;
+    if( m_DeepStarComponents.size() >= 2 ) {
+        int32_t offset;
+        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 );
+        if( offset <= 0 )
+            return 0;
+        // TODO: Implement byteswapping
+        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 0;
 }
 
_______________________________________________
Kstars-devel mailing list
Kstars-devel@kde.org
https://mail.kde.org/mailman/listinfo/kstars-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic