[Kstars-devel] KDE/kdeedu/kstars/kstars/skyobjects
Alexey Khudyakov
alexey.skladnoy at gmail.com
Mon Jul 27 00:05:16 CEST 2009
SVN commit 1002763 by khudyakov:
Actual implementation for UIDs for stars and deep-sky objects.
Both are based on hashing of coordinates and magnitude.
CCMAIL: kstars-devel at kde.org
M +22 -0 deepskyobject.cpp
M +1 -0 deepskyobject.h
M +19 -0 starobject.cpp
M +2 -4 starobject.h
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/deepskyobject.cpp #1002762:1002763
@@ -24,6 +24,8 @@
#include <QPainter>
#include <QImage>
+#include <assert.h>
+
#include "kstarsdata.h"
#include "ksutils.h"
#include "dms.h"
@@ -392,3 +394,23 @@
double size = ((majorAxis + minorAxis) / 2.0 ) * scale * dms::PI * Options::zoomFactor()/10800.0;
return 0.5*size + 4.;
}
+
+
+SkyObject::UID DeepSkyObject::getUID() const
+{
+ // mag takes 10 bit
+ SkyObject::UID m = mag()*10;
+ if( m < 0 ) m = 0;
+
+ // Both RA & dec fits in 24-bits
+ SkyObject::UID ra = ra0()->Degrees() * 36000;
+ SkyObject::UID dec = (ra0()->Degrees()+91) * 36000;
+
+ assert("Magnitude is expected to fit into 10bits" && m>=0 && m<(1<<10));
+ assert("RA should fit into 24bits" && ra>=0 && ra <(1<<24));
+ assert("Dec should fit into 24bits" && dec>=0 && dec<(1<<24));
+
+ // Choose kind of
+ SkyObject::UID kind = type() == SkyObject::GALAXY ? SkyObject::UID_GALAXY : SkyObject::UID_DEEPSKY;
+ return (kind << 60) | (m << 48) | (ra << 24) | dec;
+}
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/deepskyobject.h #1002762:1002763
@@ -93,6 +93,7 @@
DeepSkyObject(const DeepSkyObject &o );
virtual DeepSkyObject* clone() const;
+ virtual SkyObject::UID getUID() const;
/** *Destructor */
virtual ~DeepSkyObject() { delete Image; }
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/starobject.cpp #1002762:1002763
@@ -23,6 +23,8 @@
#include <QPixmap>
#include <kdebug.h>
+#include <assert.h>
+
#include "kspopupmenu.h"
#include "ksnumbers.h"
#include "kstarsdata.h"
@@ -705,3 +707,20 @@
return SkyMap::Instance()->scale() *
(6. + 0.5*( 5.0 - mag() ) + 0.01*( Options::zoomFactor()/500. ) );
}
+
+SkyObject::UID StarObject::getUID() const
+{
+ // mag takes 10 bit
+ SkyObject::UID m = mag()*10;
+ if( m < 0 ) m = 0;
+
+ // Both RA & dec fits in 24-bits
+ SkyObject::UID ra = ra0()->Degrees() * 36000;
+ SkyObject::UID dec = (ra0()->Degrees()+91) * 36000;
+
+ assert("Magnitude is expected to fit into 10bits" && m>=0 && m<(1<<10));
+ assert("RA should fit into 24bits" && ra>=0 && ra <(1<<24));
+ assert("Dec should fit into 24bits" && dec>=0 && dec<(1<<24));
+
+ return (SkyObject::UID_STAR << 60) | (m << 48) | (ra << 24) | dec;
+}
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/starobject.h #1002762:1002763
@@ -91,7 +91,8 @@
double par=0.0, bool mult=false, bool var=false, int hd=0 );
virtual StarObject* clone() const;
-
+ virtual UID getUID() const;
+
/** Copy constructor */
StarObject(const StarObject& o);
@@ -110,7 +111,6 @@
*@param stardata Pointer to starData object containing required data (except name and gname)
*@return Nothing
*/
-
void init( const starData *stardata );
/**
@@ -119,7 +119,6 @@
*@param stardata Pointer to deepStarData object containing the available data
*@return Nothing
*/
-
void init( const deepStarData *stardata );
/**
@@ -128,7 +127,6 @@
*@param name Common name
*@param name2 Genetive name
*/
-
void setNames( QString name, QString name2 );
/**
More information about the Kstars-devel
mailing list