summaryrefslogtreecommitdiffstats
path: root/mkindex.pl
diff options
context:
space:
mode:
Diffstat (limited to 'mkindex.pl')
-rwxr-xr-xmkindex.pl35
1 files changed, 34 insertions, 1 deletions
diff --git a/mkindex.pl b/mkindex.pl
index 64600fb..7d670d6 100755
--- a/mkindex.pl
+++ b/mkindex.pl
@@ -257,9 +257,42 @@ foreach my $map (@mapset) {
&debug ("Opening '$name'");
my $ds = Geo::GDAL::Open($name, 'ReadOnly') or exit 1;
- $map->{wkt} = $ds->GetProjection();
+
+ my $stripped;
+ for (my $b=1; $b <= $ds->{RasterCount} && !$stripped; $b++) {
+ my ($bx, $by) = $ds->GetRasterBand($b)->GetBlockSize();
+ $stripped = 1 if ($bx == 1 and $by > 1) or ($bx > 1 and $by == 1);
+ }
+ warn "WARN: '$name' is stripped. Tiled structure is more efficient, especially for wrapping.\n"
+ if $stripped;
+
+ my $notband = $ds->GetMetadata('IMAGE_STRUCTURE')->{INTERLEAVE};
+ undef $notband unless defined $notband and $notband ne 'BAND';
+ warn "WARN: '$name' is '$notband'-interleaved; 'BAND' interleaving is recommended.\n"
+ if $notband;
+
+ if ($stripped or $notband) {
+ warn "WARN: To fix '$name', run the following command in a POSIX-compatible shell.\n";
+ warn "WARN: This is a lossless and usually size-preserving conversion.\n";
+ my $old = $name;
+ my ($new,$path,$suffix) = fileparse ($name, qr/\.[^.]*$/);
+ $new = File::Spec->catfile($path,$new.'_new'.$suffix);
+ my $driver = $ds->GetDriver()->{ShortName};
+ warn "WARN: ".join (' ',
+ map { my $x = $_;
+ $x =~ s/"/\\"/;
+ $x = "\"$x\"" if $x =~ /[ ()';#{}*?~&|`!]/;
+ $x
+ }
+ ( 'gdal_translate', '-of', $driver
+ , (map { ('-co', $_.'='.$gdal_opts->{$_}) } (keys %$gdal_opts))
+ , $old, $new
+ )
+ ). "\n";
+ }
my $srs;
+ $map->{wkt} = $ds->GetProjection();
unless ($config{s_srs}) {
die "Error: Missing projection for '$name'.\n"
unless $map->{wkt} or $config{s_srs};