#!/usr/bin/perl -w

# Dumb little utility to create ds9 region files (for magic investigations)

# takes as input *skycell.xxxx.xxx.streaks and creates a ds9 region file for them (as stdout)




print "\n";
print "# Region file format: DS9 version 4.1\n";
print "global color=green dashlist=8 3 width=1 font=\"helvetica 10 normal\" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1\n";
print "fk5\n";
print "\n";

foreach $item  (<>) {
    chomp($item);
my @npiece = split / /,$item;
    
    if ($#npiece > 1){
	my $ra1= $npiece[0]*180.0/3.141527;
	my $ra2= $npiece[2]*180.0/3.141527;
	my $dec1= $npiece[1]*180.0/3.141527;
	my $dec2= $npiece[3]*180.0/3.141527;
#	print "polygon($ra1, $dec1, $ra1, $dec2, $ra2, $dec2, $ra2, $dec1)\n"; 

	print "line($ra1, $dec1, $ra2, $dec2)\n";
    }

   
}
