forked from CelestiaProject/Celestia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacknames.cpp
More file actions
123 lines (108 loc) · 2.61 KB
/
packnames.cpp
File metadata and controls
123 lines (108 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// packnames.cpp
//
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#include <iostream>
#include <string>
#include "constellation.h"
#include "starname.h"
static char *greekAlphabet[] =
{
"Alpha",
"Beta",
"Gamma",
"Delta",
"Epsilon",
"Zeta",
"Eta",
"Theta",
"Iota",
"Kappa",
"Lambda",
"Mu",
"Nu",
"Xi",
"Omicron",
"Pi",
"Rho",
"Sigma",
"Tau",
"Upsilon",
"Phi",
"Chi",
"Psi",
"Omega"
};
int main(int argc, char *argv[])
{
string s;
for (;;)
{
unsigned int catalogNumber;
char sep;
cin >> catalogNumber;
if (cin.eof())
{
break;
}
if (cin.bad())
{
cerr << "Error reading names file.\n";
break;
}
cin >> sep;
if (sep != ':')
{
cerr < "Missing ':' in names file.\n";
break;
}
// Get the rest of the line
getline(cin, s);
int nextSep = s.find_first_of(':');
if (nextSep == string::npos)
{
cerr << "Missing ':' in names file.\n";
break;
}
string common, designation;
string conAbbr;
string conName;
string bayerLetter;
if (nextSep != 0)
common = s.substr(0, nextSep);
designation = s.substr(nextSep + 1, string::npos);
if (designation != "")
{
nextSep = designation.find_last_of(' ');
if (nextSep != string::npos)
{
bayerLetter = designation.substr(0, nextSep);
conAbbr = designation.substr(nextSep + 1, string::npos);
}
}
Constellation *constel;
for (int i = 0; i < 88; i++)
{
constel = Constellation::getConstellation(i);
if (constel == NULL)
{
cerr << "Error getting constellation " << i << '\n';
break;
}
if (constel->getAbbreviation() == conAbbr)
{
conName = constel->getName();
break;
}
}
if (constel != NULL && bayerLetter != "")
{
StarName sn(common, bayerLetter, constel);
cout << sn.getDesignation() << ' ' << constel->getAbbreviation() << '\n';
}
}
}