exoplanets.pl   exoplanets.pl 
skipping to change at line 50 skipping to change at line 50
$CNT = "./count"; $CNT = "./count";
$CATALOG_FORMAT_VERSION = 1; $CATALOG_FORMAT_VERSION = 1;
$dbname = "exoplanets"; $dbname = "exoplanets";
$dbhost = "localhost"; $dbhost = "localhost";
$dbuser = "exoplanet"; $dbuser = "exoplanet";
$dbpass = "exoplanet"; $dbpass = "exoplanet";
$UA = LWP::UserAgent->new(keep_alive => 1, timeout => 360); $UA = LWP::UserAgent->new(keep_alive => 1, timeout => 360);
$UA->agent("Mozilla/5.0 (Stellarium Exoplanets Catalog Updater 2.1; http:// stellarium.org/)"); $UA->agent("Mozilla/5.0 (Stellarium Exoplanets Catalog Updater 2.7; http:// stellarium.org/)");
$request = HTTP::Request->new('GET', $URL); $request = HTTP::Request->new('GET', $URL);
$responce = $UA->request($request); $responce = $UA->request($request);
if ($responce->is_success) { if ($responce->is_success) {
open(OUT, ">$CSV"); open(OUT, ">$CSV");
$data = $responce->content; $data = $responce->content;
binmode OUT; binmode OUT;
print OUT $data; print OUT $data;
close OUT; close OUT;
} else { } else {
skipping to change at line 78 skipping to change at line 78
open (HCSV, "<$HCSV"); open (HCSV, "<$HCSV");
@habitable = <HCSV>; @habitable = <HCSV>;
close HCSV; close HCSV;
%hs = (); %hs = ();
%hp = (); %hp = ();
for ($i=1;$i<scalar(@habitable);$i++) { for ($i=1;$i<scalar(@habitable);$i++) {
$status = $csvdata->parse($habitable[$i]); $status = $csvdata->parse($habitable[$i]);
@hdata = $csvdata->fields(); @hdata = $csvdata->fields();
%hs = (%hs, $hdata[0], 1); %hs = (%hs, $hdata[1], 1);
%hp = (%hp, $hdata[0]." ".$hdata[1], $habitable[$i]); %hp = (%hp, $hdata[1]." ".$hdata[2], $habitable[$i]);
} }
open (CSV, "<$CSV"); open (CSV, "<$CSV");
@catalog = <CSV>; @catalog = <CSV>;
close CSV; close CSV;
$dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1}); $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
$sth = $dbh->do(q{SET NAMES utf8}); $sth = $dbh->do(q{SET NAMES utf8});
$sth = $dbh->do(q{TRUNCATE stars}); $sth = $dbh->do(q{TRUNCATE stars});
$sth = $dbh->prepare(q{SELECT COUNT(pid) FROM planets}); $sth = $dbh->prepare(q{SELECT COUNT(pid) FROM planets});
skipping to change at line 250 skipping to change at line 250
# insert star data # insert star data
$sth = $dbh->do(q{INSERT INTO stars (ra_coord,dec_co ord,sname,distance,stype,smass,smetal,vmag,sradius,sefftemp,has_habit_plane t) VALUES (?,?,?,?,?,?,?,?,?,?,?)}, undef, $outRA, $outDE, $sname, $sdist, $sstype, $smass, $smetal, $sVmag, $sradius, $sefftemp, $HPflag); $sth = $dbh->do(q{INSERT INTO stars (ra_coord,dec_co ord,sname,distance,stype,smass,smetal,vmag,sradius,sefftemp,has_habit_plane t) VALUES (?,?,?,?,?,?,?,?,?,?,?)}, undef, $outRA, $outDE, $sname, $sdist, $sstype, $smass, $smetal, $sVmag, $sradius, $sefftemp, $HPflag);
$sth = $dbh->prepare(q{SELECT sid,sname FROM stars O RDER BY sid DESC LIMIT 0,1}); $sth = $dbh->prepare(q{SELECT sid,sname FROM stars O RDER BY sid DESC LIMIT 0,1});
$sth->execute(); $sth->execute();
@starDATA = $sth->fetchrow_array(); @starDATA = $sth->fetchrow_array();
$starID = @starDATA[0]; $starID = @starDATA[0];
$starName = @starDATA[1]; $starName = @starDATA[1];
} }
$hclass = ''; $hclass = '';
$hptype = '';
$mstemp = -1; $mstemp = -1;
$eqtemp = -1;
$esi = -1; $esi = -1;
$key = $starName." ".$pname; $key = $starName." ".$pname;
if (exists($hp{$key})) { if (exists($hp{$key})) {
$status = $csvdata->parse($hp{$key}); $status = $csvdata->parse($hp{$key});
($hsname,$hpname,$hclass,$mstemp,$esi) = $csvdata->f ields(); ($hsn,$hsname,$hpname,$hptype,$eqtemp,$esi) = $csvda ta->fields();
} }
# insert planet data # insert planet data
$sth = $dbh->do(q{INSERT INTO planets (sid,pname,pmass,pradi us,pperiod,psemiaxis,pecc,pinc,padistance,discovered,hclass,mstemp,esi) VAL UES (?,?,?,?,?,?,?,?,?,?,?,?,?)}, undef, $starID, $pname, $pmass, $pradius, $pperiod, $paxis, $pecc, $pincl, $angdist, $discovered, $hclass, $mstemp, $esi); $sth = $dbh->do(q{INSERT INTO planets (sid,pname,pmass,pradi us,pperiod,psemiaxis,pecc,pinc,padistance,discovered,hptype,eqtemp,esi) VAL UES (?,?,?,?,?,?,?,?,?,?,?,?,?)}, undef, $starID, $pname, $pmass, $pradius, $pperiod, $paxis, $pecc, $pincl, $angdist, $discovered, $hptype, $eqtemp, $esi);
} }
# else # else
# { # {
# print $sname.": ".$sRA.":".$sDec." [".$currdata."]\n"; # print $sname.": ".$sRA.":".$sDec." [".$currdata."]\n";
# } # }
} }
open (JSON, ">$JSON"); open (JSON, ">$JSON");
print JSON "{\n"; print JSON "{\n";
print JSON "\t\"version\": \"".$CATALOG_FORMAT_VERSION."\",\n"; print JSON "\t\"version\": \"".$CATALOG_FORMAT_VERSION."\",\n";
skipping to change at line 297 skipping to change at line 299
$sname = $stars[3]; $sname = $stars[3];
$sdist = $stars[4]; $sdist = $stars[4];
$sstype = $stars[5]; $sstype = $stars[5];
$smass = $stars[6]; $smass = $stars[6];
$smetal = $stars[7]; $smetal = $stars[7];
$sVmag = $stars[8]; $sVmag = $stars[8];
$sradius = $stars[9]; $sradius = $stars[9];
$sefftemp = $stars[10]; $sefftemp = $stars[10];
$hasHabitPl = $stars[11]; $hasHabitPl = $stars[11];
if ($sname eq "Kapteyn's") {
$sname .= " Star"; # cosmetic fix for translation support
}
$out = "\t\t\"".$sname."\":\n"; $out = "\t\t\"".$sname."\":\n";
$out .= "\t\t{\n"; $out .= "\t\t{\n";
$out .= "\t\t\t\"exoplanets\":\n"; $out .= "\t\t\t\"exoplanets\":\n";
$out .= "\t\t\t[\n"; $out .= "\t\t\t[\n";
$stp = $dbh->prepare(q{SELECT COUNT(pid) FROM planets WHERE sid=?}); $stp = $dbh->prepare(q{SELECT COUNT(pid) FROM planets WHERE sid=?});
$stp->execute($sid); $stp->execute($sid);
@pcountraw = $stp->fetchrow_array(); @pcountraw = $stp->fetchrow_array();
$pcount = @pcountraw[0]; $pcount = @pcountraw[0];
$j = 0; $j = 0;
skipping to change at line 321 skipping to change at line 327
$pid = $planets[0]; $pid = $planets[0];
$pname = $planets[2]; $pname = $planets[2];
$pmass = $planets[3]; $pmass = $planets[3];
$pradius = $planets[4]; $pradius = $planets[4];
$pperiod = $planets[5]; $pperiod = $planets[5];
$psemiax = $planets[6]; $psemiax = $planets[6];
$pecc = $planets[7]; $pecc = $planets[7];
$pinc = $planets[8]; $pinc = $planets[8];
$angdist = $planets[9]; $angdist = $planets[9];
$discovered = $planets[10]; $discovered = $planets[10];
$habitclass = $planets[11]; $hpltype = $planets[11];
$meanstemp = $planets[12]; $eqktemp = $planets[12];
$esindex = $planets[13]; $esindex = $planets[13];
$out .= "\t\t\t{\n"; $out .= "\t\t\t{\n";
if ($pmass ne '') { if ($pmass ne '') {
$out .= "\t\t\t\t\"mass\": ".$pmass.",\n"; $out .= "\t\t\t\t\"mass\": ".$pmass.",\n";
} }
if ($pradius ne '') { if ($pradius ne '') {
$out .= "\t\t\t\t\"radius\": ".$pradius.",\n"; $out .= "\t\t\t\t\"radius\": ".$pradius.",\n";
} }
if ($pperiod ne '') { if ($pperiod ne '') {
skipping to change at line 350 skipping to change at line 356
} }
if ($pinc ne '') { if ($pinc ne '') {
$out .= "\t\t\t\t\"inclination\": ".$pinc.",\n"; $out .= "\t\t\t\t\"inclination\": ".$pinc.",\n";
} }
if ($angdist ne '') { if ($angdist ne '') {
$out .= "\t\t\t\t\"angleDistance\": ".$angdist.",\n" ; $out .= "\t\t\t\t\"angleDistance\": ".$angdist.",\n" ;
} }
if ($discovered ne '') { if ($discovered ne '') {
$out .= "\t\t\t\t\"discovered\": ".$discovered.",\n" ; $out .= "\t\t\t\t\"discovered\": ".$discovered.",\n" ;
} }
if ($habitclass ne '') { if ($hpltype ne '') {
$out .= "\t\t\t\t\"hclass\": \"".$habitclass."\",\n" $out .= "\t\t\t\t\"pclass\": \"".$hpltype."\",\n";
;
} }
if ($meanstemp > 0) { if ($eqktemp > 0) {
$out .= "\t\t\t\t\"MSTemp\": ".$meanstemp.",\n"; $out .= "\t\t\t\t\"EqTemp\": ".$eqktemp.",\n";
} }
if ($esindex > 0) { if ($esindex > 0) {
$out .= "\t\t\t\t\"ESI\": ".$esindex.",\n"; $out .= "\t\t\t\t\"ESI\": ".$esindex.",\n";
} }
if ($pname eq '') { if ($pname eq '') {
$pname = "a"; $pname = "a";
} }
$out .= "\t\t\t\t\"planetName\": \"".$pname."\"\n"; $out .= "\t\t\t\t\"planetName\": \"".$pname."\"\n";
$out .= "\t\t\t}"; $out .= "\t\t\t}";
$j += 1; $j += 1;
 End of changes. 10 change blocks. 
12 lines changed or deleted 17 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/