16
my ($ncols, $nrows, $xllcorner, $yllcorner, $cellsize);
24
$head[$i]=~s/[a-zA-Z_\s]//g;
30
$xllcorner = $head[2]+0;
31
$yllcorner = $head[3]+0;
32
$cellsize = $head[4]+0;
34
return ($xllcorner, $yllcorner, $ncols, $nrows, $cellsize);
39
my ($xstart, $ystart, $ncols, $nrows, $cellsize) = get_header($file);
41
my $xend = $xstart + $ncols * $cellsize;
42
my $yend = $ystart + $nrows * $cellsize;
44
return ($xstart, $ystart, $xend, $yend);
48
my ($file, $xmin, $ymin, $xmax, $ymax, $size) = @_;
49
my ($x1, $y1, $x2, $y2) = get_rectangle($file);
51
# print " $x1, $y1, $x2, $y2\n";
54
if ($x1 < $xmin) { $x1 = $xmin; }
55
if ($x2 > $xmax) { $x2 = $xmax; }
56
if ($y1 < $ymin) { $y1 = $ymin; }
57
if ($y2 > $ymax) { $y2 = $ymax; }
59
# print " $x1, $y1, $x2, $y2\n";
61
if (($x1 >= $x2)||($y1 >= $y2)) {
62
throw Error::Simple("Nothing to process");
65
return ($x1, $y1, $x2, $y2);
72
my ($file, $x1, $y1, $x2, $y2, $size) = @_;
75
($x1, $y1, $x2, $y2) = select_area($file, $x1, $y1, $x2, $y2);
78
print "Skipping file: $file\n";
79
return; # Looks just exiting from block
80
}; # This semicolon is really-really needed.
82
if ($notfound) { return; }
84
print "Processing file: $file\n";
85
printf (" Extract area: (%.2f,%.2f) - (%.2f,%.2f)\n", $x1, $y1, $x2, $y2);
86
for ($yi = $y1; $yi < $y2; $yi += $size) {
87
for ($xi = $x1; $xi < $x2; $xi += $size) {
88
my $xj = (($xi+$size)<$x2)?($xi+$size):$x2;
89
my $yj = (($yi+$size)<$y2)?($yi+$size):$y2;
90
my $qwidth = $xj - $xi;
91
my $qheight = $yj - $yi;
92
my $resfile = sprintf("dem_data/$file.countours.%.2fx%.2f.osm", $xi, $yi);
93
printf (" $file: Qudrate %.2f,%.2f of size %.2fx%.2f\n", $xi, $yi, $qwidth, $qheight);
95
system("$conf{'path'}/extractdata.pl $file $yi $xi $yj $xj > extract.txt");
96
system("$conf{'path'}/mkcntr.pl ./extract.txt $conf{'minor'} $conf{'medium'} $conf{'major'} > $resfile");
102
print "Usage: $0 <directory> [ymin xmin ymax xmax] [size]\n";
103
print " x - longtitude, y - latitude\n";
107
my ($dir, $y1, $x1, $y2, $x2, $size) = @ARGV;
109
switch (int(@ARGV)) {
122
if (!defined($size)) { $size = 1; }
125
my (@files, $f, $cdir);
128
@files = readdir($cdir);
133
if ($f !~ /\.ASC$/) { next; }
134
process_file($f, $x1, $y1, $x2, $y2, $size);
139
#srtm2osm/extractdata.pl srtm_38_02.ASC 50 5 51 6 > extract.txt
140
#srtm2osm/mkcntr.pl ./extract.txt 20 100 200 > countours
142
#for name in *.ASC; do
143
# srtm2osm/extractdata.pl $name 47.24 6.32 54.7 13.46 > extract.txt
144
# srtm2osm/mkcntr.pl ./extract.txt 20 100 200 > $name.countours
147
#46.56 2.8 55.41 17.26
b'\\ No newline at end of file'