Sunday, January 25, 2015

SPS File Generator Perl

#!/usr/bin/perl
$XMIN=753875.0;
$YMIN=3212925.0;
$Xnum=592;
$Ynum=130;
$Xinc=150;
$Yinc=50;
$SLNMIN=3142;
$SPNMIN=7187;

##x coordinate
for $i (0..$Ynum-1)
{
$a=$XMIN+$i*$Xinc;
$ax=$SLNMIN+$i*3;
push @a1, $a;
push @a1x, $ax;

}
@a2=(@a1)x $Xnum;    ###repmat
@a2x=(@a1x)x $Xnum;

@a3=sort {  $a  <=>  $b  } @a2;  ###x
@a3x=sort {  $a  <=>  $b  } @a2x;  ###x

##y coordinate
for $i (0..$Xnum-1)
{
$b=$YMIN+$i*$Yinc;
$bx=$SPNMIN+$i*1;
push @b1, $b;
push @b1x, $bx;
}
@b3=(@b1)x $Ynum;  ### y
@b3x=(@b1x)x $Ynum;  ### y
open OUT," > hasil.txt" or die "$!\n";
for my $i (0..$#a3)
{
   print OUT  "$a3x[$i]";
   print OUT  "$b3x[$i]","\t";
   print OUT  "$a3[$i]","\t";
   print OUT  "$b3[$i]","\n";
}
 

No comments: