1use strict;
2use warnings;
3use Test::More qw(no_plan);
4BEGIN { use_ok('Geo::GDAL') };
5
6SKIP: {
7    my $srs1 = Geo::OSR::SpatialReference->new(EPSG=>32631);
8    my $srs2 = Geo::OSR::SpatialReference->new(Text=>$srs1->AsText);
9    ok($srs1->ExportToProj4 eq $srs2->ExportToProj4, "new EPSG, Text, Proj4");
10
11    my $src = Geo::OSR::SpatialReference->new(EPSG => 2392);
12    my $dst = Geo::OSR::SpatialReference->new(EPSG => 2393);
13    ok(($src and $dst), "new Geo::OSR::SpatialReference");
14}
15
16SKIP: {
17    my $src = Geo::OSR::SpatialReference->new(EPSG => 2392);
18    my $dst = Geo::OSR::SpatialReference->new(EPSG => 2393);
19
20    my ($t1, $t2);
21    eval {
22	$t1 = Geo::OSR::CoordinateTransformation->new($src, $dst);
23	$t2 = Geo::OSR::CoordinateTransformation->new($dst, $src);
24    };
25    skip "Unable to load PROJ.4 library", 3 if $@ =~ /Unable to load/;
26
27    ok($t1, "new Geo::OSR::CoordinateTransformation $@");
28
29    skip "new Geo::OSR::CoordinateTransformation failed", 2 unless ($t1 and $t2);
30
31    # northing, easting order
32    my @points = ([6830493.772, 2492055.205],
33		  [6830483.772, 2492065.205],
34		  [6830483.772, 2492075.205]);
35
36    my $p1 = $points[0][0];
37
38    my @polygon = ([[6830483.772, 2492055.205],
39		    [6830483.772, 2492075.205],
40		    [6830493.772, 2492075.205],
41		    [6830483.772, 2492055.205]]);
42
43    my $p2 = $polygon[0][0][0];
44
45    $t1->TransformPoints(\@points);
46    $t1->TransformPoints(\@polygon);
47
48    $t2->TransformPoints(\@points);
49    $t2->TransformPoints(\@polygon);
50
51    ok(int($p1) == int($points[0][0]), "from EPSG 2392 to 2393 and back in line");
52    ok(int($p2) == int($polygon[0][0][0]), "from EPSG 2392 to 2393 and back in polygon");
53
54}
55