diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2013-08-13 20:28:10 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2013-08-13 20:28:10 +0200 |
commit | 0dd54962b4cc6a296c9fd68ccbd1e1c69394c50a (patch) | |
tree | da8a4aa18a63f4cb3c5b67270100809751e53df9 | |
parent | 80f6021f48cc9f9ca997c7f36df20d3465c967ee (diff) |
Warn when a suboptimal format is used.
-rwxr-xr-x | mkindex.pl | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -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}; |