Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for issue #53, followup to PR #57. #65

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions t/00.t
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
is($p, $ogc_wkt, "Set/get projection string");
my $transform = [10,2,0,20,0,3];
$ds->SetGeoTransform($transform);
my $inv = [0,0,0,0,0,0];
ok(Geo::GDAL::FFI::GDALInvGeoTransform($transform, $inv) && "@$inv" eq "-5 0.5 0 -6.66666666666667 0 0.333333333333333", "Invert geotransform");

Check failure on line 214 in t/00.t

View workflow job for this annotation

GitHub Actions / perl

Perl warning: argument type not a reference to scalar (0)

Check failure on line 214 in t/00.t

View workflow job for this annotation

GitHub Actions / perl

Perl warning: argument type not a reference to scalar (1)

Check failure on line 214 in t/00.t

View workflow job for this annotation

GitHub Actions / perl

Perl warning: argument type not a reference to scalar (0)

Check failure on line 214 in t/00.t

View workflow job for this annotation

GitHub Actions / perl

Perl warning: argument type not a reference to scalar (1)

Check failure on line 214 in t/00.t

View workflow job for this annotation

GitHub Actions / perl

Perl warning: argument type not a reference to scalar (0)

Check failure on line 214 in t/00.t

View workflow job for this annotation

GitHub Actions / perl

Perl warning: argument type not a reference to scalar (1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be split into two tests? Store the result of the transform call into a scalar variable. It can be checked using the is function. Then use an is_deeply test to check the expected array values.

my ($x, $y);
Geo::GDAL::FFI::GDALApplyGeoTransform($transform,5,5,\$x,\$y);
ok($x == 20 && $y == 35, "Applied geotransform to pixel coords");
my $t = $ds->GetGeoTransform;
is_deeply($t, $transform, "Set/get geotransform");

Expand Down
54 changes: 54 additions & 0 deletions t/transform.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use v5.10;
use strict;
use warnings;
use Carp;
use Geo::GDAL::FFI;
use Test::More;

# test about SRS transformations API by using a simple extent (4 points) in UTM33 -> WGS84

if(1) {
my $source_srs = Geo::GDAL::FFI::SpatialReference->new( EPSG => 4326 );
my $target_srs = Geo::GDAL::FFI::SpatialReference->new( EPSG => 32633 );
my $ct = Geo::GDAL::FFI::OCTNewCoordinateTransformation($$source_srs, $$target_srs);

my @extent = (16.509888, 41.006911, 17.084248, 41.370581);

my @ul = ($extent[0], $extent[1]);
my @lr = ($extent[2], $extent[3]);
my @ur = ($lr[0],$ul[1]);
my @ll = ($ul[0],$lr[1]);
my $result = "3358768.81711923 3391240.32068776 3348976.84626544 3401215.87353221 2019470.50927319 2094945.30821076 2088830.64307375 2025411.23009774";

my @x = ($ul[0], $lr[0], $ur[0], $ll[0]);
my @y = ($ul[1], $lr[1], $ur[1], $ll[1]);
my $z = undef;
ok(Geo::GDAL::FFI::OCTTransform($ct, 4, \@x, \@y, \@$z), "Coordinate transformation 3D worked");

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (2)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (3)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (4)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (2)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (3)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (4)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (2)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (3)

Check failure on line 26 in t/transform.t

View workflow job for this annotation

GitHub Actions / perl

argument type not a reference to scalar (4)
ok(qq/@x @y/ eq $result, "Resulting coordinates");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also better done using is_deeply.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for similar cases below.


@x = ($ul[0], $lr[0], $ur[0], $ll[0]);
@y = ($ul[1], $lr[1], $ur[1], $ll[1]);
$z = undef;
my @ps = (0,0,0,0);
ok(Geo::GDAL::FFI::OCTTransformEx($ct, 4, \@x, \@y, \@$z, \@ps), "Coordinate transformation 3D with pabSuccess worked");
ok(qq/@x @y/ eq $result, "Resulting coordinates");
ok(scalar @ps == 4 && qq/@ps/ eq qq/1 1 1 1/, "Resulting pabSuccess is TRUE x 4" );

@x = ($ul[0], $lr[0], $ur[0], $ll[0]);
@y = ($ul[1], $lr[1], $ur[1], $ll[1]);
$z = undef;
my $t = undef;
ok(Geo::GDAL::FFI::OCTTransform4D($ct, 4, \@x, \@y, \@$z, \@$t), "Coordinate transformation 4D worked");
ok(qq/@x @y/ eq $result, "Resulting coordinates");

@x = ($ul[0], $lr[0], $ur[0], $ll[0]);
@y = ($ul[1], $lr[1], $ur[1], $ll[1]);
$z = undef;
$t = undef;
@ps = (0,0,0,0);
ok(Geo::GDAL::FFI::OCTTransform4DWithErrorCodes($ct, 4, \@x, \@y, \@$z, \@$t, \@ps), "Coordinate transformation 4D worked");
ok(qq/@x @y/ eq $result, "Resulting coordinates");
ok(scalar @ps == 4 && qq/@ps/ eq qq/0 0 0 0/, "Resulting pabSuccess is SUCCESS(i.e. 0) x 4" );
}

done_testing();
Loading