[Kst] branches/kstars/summer/kdeedu/kstars/kstars/data/tools
Akarsh Simha
akarshsimha at gmail.com
Mon Jun 2 00:49:03 CEST 2008
SVN commit 815487 by asimha:
+ Adding new makefile target to generate the data files
+ Updating documentation
+ Making minor changes to mysql2bin.c
CCMAIL: kstars-devel at kde.org
M +10 -1 Makefile
M +55 -0 README.tools
M +7 -4 mysql2bin.c
--- branches/kstars/summer/kdeedu/kstars/kstars/data/tools/Makefile #815486:815487
@@ -9,6 +9,9 @@
#
MYSQL_CONFIG=/usr/bin/mysql_config
+KSTARS_MYSQL_DB_TO_BIN=./mysql2bin
+KSTARS_MYSQL_DB_DB=$(KSTARS_MYSQL_DB_USER)
+KSTARS_MYSQL_DB_TBL=allstars
all: mysql2bin binfiletester
@@ -20,6 +23,12 @@
clean:
-rm binfiletester mysql2bin
-
+datafiles: mysql2bin
+ echo "If this step hangs, please reduce the value of MYSQL_STARS_PER_QUERY in mysql2bin.c and try again."
+ ./mysql2bin $(KSTARS_MYSQL_DB_USER) $(KSTARS_MYSQL_DB_PASS) usdf ushf nsdf nshf nf $(KSTARS_MYSQL_DB_DB) $(KSTARS_MYSQL_DB_TBL)
+ cat ushf usdf > ../deepstars.dat
+ cat nshf nsdf > ../shallowstars.dat
+ cat nf > ../starnames.dat
+ rm ushf usdf nshf nsdf nf
install:
# Install nothing
--- branches/kstars/summer/kdeedu/kstars/kstars/data/tools/README.tools #815486:815487
@@ -1,28 +1,83 @@
This directory contains tools used to analyse the data
+DESCRIPTIONS OF FILES:
+----------------------
+
read-hippo.pl Reads the Hiparcos catalog files
+
reformat-hip.pl Converts old format star data files into the new format,
where the fixed length Genetive name comes before the
variable length long name
+
mag-linenum.pl Write the line number magnitude index file
+
max-length.pl Find the longest line in a file
+
sort-hip-by-pm.pl Sort the Hiparcos catalog data by proper motion
+
datatomysql.pl Reads star catalog files and puts them into a MySQL
database (server on localhost)
+
binfiletester.c C Program to test KStars' star data in binary format
+
mysql2bin.c C Program to put data from the MySQL database (generated
using datatomysql.pl) into the binary data format defined
by KStars. [See README.fileformat in the kstars/data
directory]. To make this, you will need to have the
libmysqlclient-dev package or equivalent installed
+
+BUILDING THE PROGRAMS:
+----------------------
+
To build both the C programs, use:
+
make
+
To build only mysql2bin, use: [Requires MySQL client library]
+
make mysql2bin
+
To build only binfiletester, use:
+
make binfiletester
+
To clean up, use:
+
make clean
+CREATING THE DATA FILES:
+------------------------
+
+To create and put the binary data files in kstars/data, first export
+your MySQL DB username and password:
+
+ export KSTARS_MYSQL_DB_USER='<your DB username>'
+ export KSTARS_MYSQL_DB_PASS='<your DB password>'
+
+If the database in which the star data table is stored is not
+identical to the DB username, export that too:
+
+ export KSTARS_MYSQL_DB_DB='<the DB name>'
+
+If the table in which the data is present is not allstars (default if
+you used datatomysql.pl to generate the tables), then export that too:
+
+ export KSTARS_MYSQL_DB_TBL='<table name>'
+
+Then, finally do:
+
+ make datafiles
+
+This will build mysql2bin, collect the data, and put it in
+kstars/data.
+
+If 'make datafiles' hangs (it typically takes about 5 - 10 minutes),
+then you should first double check that it is really hanging by
+setting VERBOSE to 1 on line 17 of mysql2bin.c and retry. If it shows
+no progress, reduce the value of MYSQL_STARS_PER_QUERY in the #define
+directive on line 24 of mysql2bin.c till it works. This is because the
+database query may hang if the query results are too large in size. I
+don't know why this happens, but it seems to work that way.
+
-- Akarsh Simha <akarshsimha at gmail.com>
\ No newline at end of file
--- branches/kstars/summer/kdeedu/kstars/kstars/data/tools/mysql2bin.c #815486:815487
@@ -21,6 +21,7 @@
#define NTRIXELS 512
#define INDEX_ENTRY_SIZE 8
#define GLOBAL_MAG_LIMIT 8.00
+#define MYSQL_STARS_PER_QUERY 400
/*
* struct to store star data, to be written in this format, into the binary file.
@@ -446,11 +447,13 @@
nsf_trix_begin = usf_trix_begin = 0;
ntrixels = 0;
- /* Recurse over every 500 DB entries */
+ /* Recurse over every MYSQL_STARS_PER_QUERY DB entries */
while(!exitflag) {
- /* Build MySQL query for next 500 stars */
- sprintf(query, "SELECT `trixel`, `ra`, `dec`, `dra`, `ddec`, `parallax`, `mag`, `bv_index`, `spec_type`, `mult`, `var_range`, `var_period`, `UID`, `name`, `gname` FROM `%s` ORDER BY `trixel`, `mag` ASC LIMIT %ld, 500", (argc >= 10) ? argv[9] : DB_TBL, lim);
+ /* Build MySQL query for next MYSQL_STARS_PER_QUERY stars */
+ sprintf(query,
+ "SELECT `trixel`, `ra`, `dec`, `dra`, `ddec`, `parallax`, `mag`, `bv_index`, `spec_type`, `mult`, `var_range`, `var_period`, `UID`, `name`, `gname` FROM `%s` ORDER BY `trixel`, `mag` ASC LIMIT %ld, %d",
+ (argc >= 10) ? argv[9] : DB_TBL, lim, MYSQL_STARS_PER_QUERY);
if(VERBOSE) { fprintf(stderr, "SQL Query: %s\n", query); }
@@ -568,7 +571,7 @@
}
mysql_free_result(result);
- lim += 500;
+ lim += MYSQL_STARS_PER_QUERY;
}
do {
More information about the Kst
mailing list