1use strict; 2use warnings; 3use Scalar::Util 'blessed'; 4use Test::More qw(no_plan); 5BEGIN { use_ok('Geo::GDAL') }; 6 7my $t = Geo::GDAL::GeoTransform->new; 8 9is_deeply($t, [0,1,0,0,0,1], "Default geotransform is 0,1,0, 0,0,1"); 10 11$t = Geo::GDAL::GeoTransform->new([0,1,0,0,0,1]); 12 13is_deeply($t, [0,1,0,0,0,1], "Create from array ref"); 14 15$t = Geo::GDAL::GeoTransform->new(Geo::GDAL::GeoTransform->new); 16 17is_deeply($t, [0,1,0,0,0,1], "Create from another geotransform"); 18 19$t = Geo::GDAL::GeoTransform->new(0,1,0,0,0,1); 20 21is_deeply($t, [0,1,0,0,0,1], "Create from array"); 22 23ok($t->NorthUp, "Default is north up"); 24 25my @gcps; 26{ 27 my @gcp_data = ( 28 [0,6,0, 0,0], 29 [4,1,0, 4,5], 30 [0,3,0, 0,3]); 31 32 for my $gcp (@gcp_data) { 33 push @gcps, Geo::GDAL::GCP->new(@$gcp); 34 } 35} 36 37$t = Geo::GDAL::GeoTransform->new(GCPs => \@gcps); 38@$t = round(@$t); 39is_deeply($t, [0,1,0,6,0,-1], "Create from GCPs"); 40 41$t = Geo::GDAL::GeoTransform->new(Extent => [0,0,20,20], CellSize => 1); 42is_deeply($t, [0,1,0,20,0,-1], "Create from extent and cell size"); 43 44# from Math::Round 45sub round { 46 my $x; 47 my $half = 0.50000000000008; 48 my @res = map { 49 if ($_ >= 0) { POSIX::floor($_ + $half); } 50 else { POSIX::ceil($_ - $half); } 51 } @_; 52 return (wantarray) ? @res : $res[0]; 53} 54