Has anyone looked in tools?
src\tools\stardb to be specific.
celdat2txt.cpp might do what you want.
You can also get format information from
src\tools\xindex
buildxindices.pl to be exact.
Then there is stars.txt, which is used to build stars.dat from.
Somewhere in my stuff I have listings of all the database formats from when I made my own.
I can find or reproduce them if needed.
The formats are all simple.
The stars.dat is just a relative position file, a conversion from RaDecDist to XYZ, then saved in binary compact format to speed loading.
In one of my forks I preserved RaDecDist to work with some custom commands I added for looking stars up.
That preconversion is one of the ways early versions of Celestia brought down loading time.
One of the things I have been working toward is conversion directly in the GPU perframe with controlled framerate.
For those who actually care, here is how stars.dat is created.
Exercpt from buildstardb.pl
- Spoiler
Code: Select all
sub WriteDat
{
my $numStars = keys %stars;
print "Writing databases...\n";
print " Writing binary database to $DAT_PATH\n";
local(*DATFILE);
open(DATFILE, '>', $DAT_PATH) or die "ERROR: Could not write to $DAT_PATH\n";
binmode(DATFILE);
print " Writing text database to $TXT_PATH\n";
local(*TXTFILE);
open(TXTFILE, '>', $TXT_PATH) or die "ERROR: Could not write to $TXT_PATH\n";
# write file header
print DATFILE pack('a8ccL', 'CELSTARS', 0, 1, $numStars);
print TXTFILE sprintf("%u\n", $numStars);
# write each star
foreach my $HIP (sort { $a <=> $b } keys %stars)
{
my $dist = PlxToDistance($stars{$HIP}{'Plx'});
my $theta = $stars{$HIP}{'RArad'} + pi;
my $phi = $stars{$HIP}{'DErad'} - pi / 2;
my @xyz = (
$dist * cos($theta) * sin($phi),
$dist * cos($phi),
-$dist * sin($theta) * sin($phi)
);
my $xc = $eqToCel[0][0] * $xyz[0] + $eqToCel[1][0] * $xyz[1] + $eqToCel[2][0] * $xyz[2];
my $yc = $eqToCel[0][1] * $xyz[0] + $eqToCel[1][1] * $xyz[1] + $eqToCel[2][1] * $xyz[2];
my $zc = $eqToCel[0][2] * $xyz[0] + $eqToCel[1][2] * $xyz[1] + $eqToCel[2][2] * $xyz[2];
my $absMag = AppMagToAbsMag($stars{$HIP}{'Vmag'}, $stars{$HIP}{'Plx'});
my $spType = ParseSpType($stars{$HIP}{'SpType'});
print DATFILE pack('LfffsS', $HIP, $xc, $yc, $zc, $absMag * 256, $spType);
print TXTFILE sprintf("%u %.9f %+.9f %.6f %.2f %s\n", $HIP,
rad2deg($stars{$HIP}{'RArad'}), rad2deg($stars{$HIP}{'DErad'}),
$dist, $stars{$HIP}{'Vmag'}, $stars{$HIP}{'SpType'});
}
close(DATFILE);
close(TXTFILE);
print " Wrote a total of $numStars stars.\n";
}
And here is how the CELINDEX files are created.
buildindices.pl
- Spoiler
Code: Select all
#!/usr/bin/perl
# buildcrossidx.pl by Andrew Tribick
# version 1.0 - 2008-08-26
open XIDS, '<', 'crossids.txt';
@HDtoHIP = ();
@HDlevels = ();
@SAOtoHIP = ();
while($curLine = <XIDS>) {
chomp $curLine;
# get Hipparcos designation
$HIP = '';
$HIP = $2 if($curLine =~ m/(^|:)HIP ([0-9]+)(:|$)/);
next if($HIP eq ''); # ignore entries which are not Hipparcos stars
@dList = split(/:/, $curLine);
for($i = 0; $i <= $#dList; $i++) {
# no component identifiers on SAO designations - makes things easy...
$SAOtoHIP{$1} = $HIP if($dList[$i] =~ m/^SAO ([0-9]+)$/);
# only use HD designations with component identifiers A,J or none
if($dList[$i] =~ m/^HD ([0-9]+)([AJ]?)$/) {
$HDnum = $1;
$Level = HDlevel($2);
if(!exists($HDtoHIP{$HDnum})) {
# if this HD number is not already assigned, add it to list
$HDtoHIP{$HDnum} = $HIP;
$HDlevels{$HDnum} = $Level;
} elsif($Level > $HDlevels{$HDnum}) {
# otherwise we prefer A over none over J.
$HDtoHIP{$HDnum} = $HIP;
$HDlevels{$HDnum} = $Level;
}
}
}
}
close XIDS;
# write out HD index file
open HDX, '>', 'hdxindex.dat';
binmode HDX;
print HDX pack('a8S', 'CELINDEX', 0x0100);
foreach $HD (sort { $a <=> $b } keys %HDtoHIP) {
print HDX pack('LL', $HD, $HDtoHIP{$HD});
}
close HDX;
# write out SAO index file
open SAOX, '>', 'saoxindex.dat';
binmode SAOX;
print SAOX pack('a8S', 'CELINDEX', 0x0100);
foreach $SAO (sort { $a <=> $b } keys %SAOtoHIP) {
print SAOX pack('LL', $SAO, $SAOtoHIP{$SAO});
}
close SAOX;
# ---END OF MAIN PROGRAM---
sub HDlevel {
# return a score based on component identifier
my $d = shift;
return 0 if($d eq 'J');
return 1 if($d eq '');
return 2 if($d eq 'A');
return -999;
}
I hope that helps.
Keeping the RaDecDist directly in the db rather than computing it is one of those things I was going to recommend.
However, things stalled out, so I went my own way.
Now that onetwothree is getting things moving, I will bring it up at a later time.
Janus.