From 0dd54962b4cc6a296c9fd68ccbd1e1c69394c50a Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 13 Aug 2013 20:28:10 +0200 Subject: Warn when a suboptimal format is used. --- mkindex.pl | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'mkindex.pl') 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}; -- cgit v1.2.3