proj4rb 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +66 -61
- data/Gemfile +4 -4
- data/Rakefile +27 -27
- data/lib/api/api.rb +110 -83
- data/lib/api/api_4_9.rb +30 -30
- data/lib/api/api_5_0.rb +300 -300
- data/lib/api/api_5_1.rb +6 -6
- data/lib/api/api_5_2.rb +4 -4
- data/lib/api/api_6_0.rb +41 -42
- data/lib/api/api_6_1.rb +4 -4
- data/lib/api/api_6_2.rb +6 -5
- data/lib/area.rb +32 -32
- data/lib/config.rb +69 -69
- data/lib/context.rb +102 -102
- data/lib/coordinate.rb +197 -197
- data/lib/crs.rb +204 -204
- data/lib/ellipsoid.rb +41 -41
- data/lib/error.rb +17 -17
- data/lib/operation.rb +42 -42
- data/lib/pj_object.rb +80 -80
- data/lib/point.rb +72 -72
- data/lib/prime_meridian.rb +39 -39
- data/lib/proj.rb +30 -30
- data/lib/projection.rb +206 -206
- data/lib/transformation.rb +60 -60
- data/lib/unit.rb +53 -53
- data/proj4rb.gemspec +32 -32
- data/test/abstract_test.rb +7 -7
- data/test/context_test.rb +81 -81
- data/test/coordinate_test.rb +34 -34
- data/test/crs_test.rb +372 -372
- data/test/ellipsoid_test.rb +34 -34
- data/test/operation_test.rb +29 -29
- data/test/prime_meridians_test.rb +33 -33
- data/test/proj_test.rb +16 -16
- data/test/projection_test.rb +223 -223
- data/test/transformation_test.rb +67 -67
- data/test/unit_test.rb +47 -47
- metadata +2 -2
    
        data/test/ellipsoid_test.rb
    CHANGED
    
    | @@ -1,34 +1,34 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative './abstract_test'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class EllipsoidTest < AbstractTest
         | 
| 6 | 
            -
              def test_get_all
         | 
| 7 | 
            -
                ellipsoids = Proj::Ellipsoid.list.map {|ellipsoid| ellipsoid.id }
         | 
| 8 | 
            -
                assert(ellipsoids.include?('WGS84'))
         | 
| 9 | 
            -
                assert(ellipsoids.include?('bessel'))
         | 
| 10 | 
            -
                assert(ellipsoids.include?('lerch'))
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              def test_one
         | 
| 14 | 
            -
                ellipsoid = Proj::Ellipsoid.get('bessel')
         | 
| 15 | 
            -
                assert_kind_of Proj::Ellipsoid, ellipsoid
         | 
| 16 | 
            -
                assert_equal('bessel', ellipsoid.id)
         | 
| 17 | 
            -
                assert_equal('a=6377397.155', ellipsoid.major)
         | 
| 18 | 
            -
                assert_equal('rf=299.1528128', ellipsoid.ell)
         | 
| 19 | 
            -
                assert_equal('Bessel 1841', ellipsoid.name)
         | 
| 20 | 
            -
                assert_equal('bessel', ellipsoid.to_s)
         | 
| 21 | 
            -
                assert_equal('#<Proj::Ellipsoid id="bessel", major="a=6377397.155", ell="rf=299.1528128", name="Bessel 1841">', ellipsoid.inspect)
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              def test_equal
         | 
| 25 | 
            -
                e1 = Proj::Ellipsoid.get('bessel')
         | 
| 26 | 
            -
                e2 = Proj::Ellipsoid.get('bessel')
         | 
| 27 | 
            -
                assert e1 == e2
         | 
| 28 | 
            -
              end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
              def test_failed_get
         | 
| 31 | 
            -
                ellipsoid = Proj::Ellipsoid.get('foo')
         | 
| 32 | 
            -
                assert_nil ellipsoid
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
            end
         | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative './abstract_test'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class EllipsoidTest < AbstractTest
         | 
| 6 | 
            +
              def test_get_all
         | 
| 7 | 
            +
                ellipsoids = Proj::Ellipsoid.list.map {|ellipsoid| ellipsoid.id }
         | 
| 8 | 
            +
                assert(ellipsoids.include?('WGS84'))
         | 
| 9 | 
            +
                assert(ellipsoids.include?('bessel'))
         | 
| 10 | 
            +
                assert(ellipsoids.include?('lerch'))
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              def test_one
         | 
| 14 | 
            +
                ellipsoid = Proj::Ellipsoid.get('bessel')
         | 
| 15 | 
            +
                assert_kind_of Proj::Ellipsoid, ellipsoid
         | 
| 16 | 
            +
                assert_equal('bessel', ellipsoid.id)
         | 
| 17 | 
            +
                assert_equal('a=6377397.155', ellipsoid.major)
         | 
| 18 | 
            +
                assert_equal('rf=299.1528128', ellipsoid.ell)
         | 
| 19 | 
            +
                assert_equal('Bessel 1841', ellipsoid.name)
         | 
| 20 | 
            +
                assert_equal('bessel', ellipsoid.to_s)
         | 
| 21 | 
            +
                assert_equal('#<Proj::Ellipsoid id="bessel", major="a=6377397.155", ell="rf=299.1528128", name="Bessel 1841">', ellipsoid.inspect)
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def test_equal
         | 
| 25 | 
            +
                e1 = Proj::Ellipsoid.get('bessel')
         | 
| 26 | 
            +
                e2 = Proj::Ellipsoid.get('bessel')
         | 
| 27 | 
            +
                assert e1 == e2
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def test_failed_get
         | 
| 31 | 
            +
                ellipsoid = Proj::Ellipsoid.get('foo')
         | 
| 32 | 
            +
                assert_nil ellipsoid
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
    
        data/test/operation_test.rb
    CHANGED
    
    | @@ -1,29 +1,29 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative './abstract_test'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class OperationTest < AbstractTest
         | 
| 6 | 
            -
              def test_get_all
         | 
| 7 | 
            -
                operations = Proj::Operation.list.map {|operation| operation.id}
         | 
| 8 | 
            -
                assert(operations.include?('aea'))
         | 
| 9 | 
            -
                assert(operations.include?('wintri'))
         | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              def test_one
         | 
| 13 | 
            -
                operation = Proj::Operation.get('rouss')
         | 
| 14 | 
            -
                assert_kind_of(Proj::Operation, operation)
         | 
| 15 | 
            -
                assert_equal('rouss', operation.id)
         | 
| 16 | 
            -
                assert_equal("Roussilhe Stereographic\n\tAzi, Ell", operation.description)
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              def test_equal
         | 
| 20 | 
            -
                e1 = Proj::Operation.get('rouss')
         | 
| 21 | 
            -
                e2 = Proj::Operation.get('rouss')
         | 
| 22 | 
            -
                assert(e1 == e2)
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              def test_failed_get
         | 
| 26 | 
            -
                operation = Proj::Operation.get('foo')
         | 
| 27 | 
            -
                assert_nil(operation)
         | 
| 28 | 
            -
              end
         | 
| 29 | 
            -
            end
         | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative './abstract_test'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class OperationTest < AbstractTest
         | 
| 6 | 
            +
              def test_get_all
         | 
| 7 | 
            +
                operations = Proj::Operation.list.map {|operation| operation.id}
         | 
| 8 | 
            +
                assert(operations.include?('aea'))
         | 
| 9 | 
            +
                assert(operations.include?('wintri'))
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def test_one
         | 
| 13 | 
            +
                operation = Proj::Operation.get('rouss')
         | 
| 14 | 
            +
                assert_kind_of(Proj::Operation, operation)
         | 
| 15 | 
            +
                assert_equal('rouss', operation.id)
         | 
| 16 | 
            +
                assert_equal("Roussilhe Stereographic\n\tAzi, Ell", operation.description)
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def test_equal
         | 
| 20 | 
            +
                e1 = Proj::Operation.get('rouss')
         | 
| 21 | 
            +
                e2 = Proj::Operation.get('rouss')
         | 
| 22 | 
            +
                assert(e1 == e2)
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def test_failed_get
         | 
| 26 | 
            +
                operation = Proj::Operation.get('foo')
         | 
| 27 | 
            +
                assert_nil(operation)
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -1,33 +1,33 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative './abstract_test'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class PrimeMeridiansTest < AbstractTest
         | 
| 6 | 
            -
              def test_get_all
         | 
| 7 | 
            -
                prime_meridians = Proj::PrimeMeridian.list.sort.collect {|prime_meridian| prime_meridian.id}
         | 
| 8 | 
            -
                assert prime_meridians.index('greenwich')
         | 
| 9 | 
            -
                assert prime_meridians.index('athens')
         | 
| 10 | 
            -
                assert prime_meridians.index('lisbon')
         | 
| 11 | 
            -
                assert prime_meridians.index('rome')
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              def test_one
         | 
| 15 | 
            -
                prime_meridian = Proj::PrimeMeridian.get('lisbon')
         | 
| 16 | 
            -
                assert_kind_of(Proj::PrimeMeridian, prime_meridian)
         | 
| 17 | 
            -
                assert_equal('lisbon', prime_meridian.id)
         | 
| 18 | 
            -
                assert_equal('9d07\'54.862"W', prime_meridian.defn)
         | 
| 19 | 
            -
                assert_equal('#<Proj::PrimeMeridian id="lisbon", defn="9d07\'54.862"W">', prime_meridian.inspect)
         | 
| 20 | 
            -
              end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              def test_compare
         | 
| 23 | 
            -
                u1 = Proj::PrimeMeridian.get('lisbon')
         | 
| 24 | 
            -
                u2 = Proj::PrimeMeridian.get('lisbon')
         | 
| 25 | 
            -
                assert u1 == u2
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              def test_failed_get
         | 
| 29 | 
            -
                prime_meridian = Proj::PrimeMeridian.get('foo')
         | 
| 30 | 
            -
                assert_nil prime_meridian
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
            end
         | 
| 33 | 
            -
             | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative './abstract_test'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class PrimeMeridiansTest < AbstractTest
         | 
| 6 | 
            +
              def test_get_all
         | 
| 7 | 
            +
                prime_meridians = Proj::PrimeMeridian.list.sort.collect {|prime_meridian| prime_meridian.id}
         | 
| 8 | 
            +
                assert prime_meridians.index('greenwich')
         | 
| 9 | 
            +
                assert prime_meridians.index('athens')
         | 
| 10 | 
            +
                assert prime_meridians.index('lisbon')
         | 
| 11 | 
            +
                assert prime_meridians.index('rome')
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def test_one
         | 
| 15 | 
            +
                prime_meridian = Proj::PrimeMeridian.get('lisbon')
         | 
| 16 | 
            +
                assert_kind_of(Proj::PrimeMeridian, prime_meridian)
         | 
| 17 | 
            +
                assert_equal('lisbon', prime_meridian.id)
         | 
| 18 | 
            +
                assert_equal('9d07\'54.862"W', prime_meridian.defn)
         | 
| 19 | 
            +
                assert_equal('#<Proj::PrimeMeridian id="lisbon", defn="9d07\'54.862"W">', prime_meridian.inspect)
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def test_compare
         | 
| 23 | 
            +
                u1 = Proj::PrimeMeridian.get('lisbon')
         | 
| 24 | 
            +
                u2 = Proj::PrimeMeridian.get('lisbon')
         | 
| 25 | 
            +
                assert u1 == u2
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def test_failed_get
         | 
| 29 | 
            +
                prime_meridian = Proj::PrimeMeridian.get('foo')
         | 
| 30 | 
            +
                assert_nil prime_meridian
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
    
        data/test/proj_test.rb
    CHANGED
    
    | @@ -1,17 +1,17 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative './abstract_test'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class ProjTest < AbstractTest
         | 
| 6 | 
            -
              def test_info
         | 
| 7 | 
            -
                info = Proj.info
         | 
| 8 | 
            -
                assert_equal(6, info[:major])
         | 
| 9 | 
            -
                assert_equal(2, info[:minor])
         | 
| 10 | 
            -
                assert_equal(1, info[:patch])
         | 
| 11 | 
            -
                assert_equal('Rel. 6.2.1, November 1st, 2019', info[:release])
         | 
| 12 | 
            -
                assert_equal('6.2.1', info[:version])
         | 
| 13 | 
            -
                refute_nil(info[:searchpath])
         | 
| 14 | 
            -
                refute(info[:paths].null?)
         | 
| 15 | 
            -
                assert_equal(1, info[:path_count])
         | 
| 16 | 
            -
              end
         | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative './abstract_test'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class ProjTest < AbstractTest
         | 
| 6 | 
            +
              def test_info
         | 
| 7 | 
            +
                info = Proj.info
         | 
| 8 | 
            +
                assert_equal(6, info[:major])
         | 
| 9 | 
            +
                assert_equal(2, info[:minor])
         | 
| 10 | 
            +
                assert_equal(1, info[:patch])
         | 
| 11 | 
            +
                assert_equal('Rel. 6.2.1, November 1st, 2019', info[:release])
         | 
| 12 | 
            +
                assert_equal('6.2.1', info[:version])
         | 
| 13 | 
            +
                refute_nil(info[:searchpath])
         | 
| 14 | 
            +
                refute(info[:paths].null?)
         | 
| 15 | 
            +
                assert_equal(1, info[:path_count])
         | 
| 16 | 
            +
              end
         | 
| 17 17 | 
             
            end
         | 
    
        data/test/projection_test.rb
    CHANGED
    
    | @@ -1,224 +1,224 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative './abstract_test'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class ProjectionTest < AbstractTest
         | 
| 6 | 
            -
              PRECISION = 0.1 ** 4
         | 
| 7 | 
            -
              
         | 
| 8 | 
            -
              def setup
         | 
| 9 | 
            -
                @proj_wgs84 = Proj::Projection.new(["init=epsg:4326"])       # WGS84
         | 
| 10 | 
            -
                @proj_gk = Proj::Projection.new(["+init=epsg:31467"])      # Gauss-Kruger Zone 3
         | 
| 11 | 
            -
                @proj_merc  = Proj::Projection.new(["proj=merc"])
         | 
| 12 | 
            -
                @proj_conakry = Proj::Projection.new(["+init=epsg:31528"])      # Conakry 1905 / UTM zone 28N
         | 
| 13 | 
            -
                @proj_ortel = Proj::Projection.new(["+proj=ortel", "+lon_0=90w"])  # Ortelius Oval Projection
         | 
| 14 | 
            -
                @epsg2029i = ['+init=epsg:2029']
         | 
| 15 | 
            -
                @epsg2029_args = ['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs']
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              def test_arg_fail
         | 
| 19 | 
            -
                assert_raises ArgumentError do
         | 
| 20 | 
            -
                  Proj::Projection.parse()
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
                assert_raises ArgumentError do
         | 
| 23 | 
            -
                  Proj::Projection.parse(nil)
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
                assert_raises ArgumentError do
         | 
| 26 | 
            -
                  Proj::Projection.parse(1)
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
              end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
              def test_arg_string
         | 
| 31 | 
            -
                args = Proj::Projection.parse('+init=epsg:2029')
         | 
| 32 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 33 | 
            -
                args = Proj::Projection.parse('  +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs  ')
         | 
| 34 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
              def test_arg_string_with_plus
         | 
| 38 | 
            -
                args = Proj::Projection.parse('+init=epsg:2029')
         | 
| 39 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 40 | 
            -
                args = Proj::Projection.parse('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
         | 
| 41 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 42 | 
            -
              end
         | 
| 43 | 
            -
             | 
| 44 | 
            -
              def test_arg_array
         | 
| 45 | 
            -
                args = Proj::Projection.parse(['+init=epsg:2029'])
         | 
| 46 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 47 | 
            -
                args = Proj::Projection.parse(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
         | 
| 48 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
              def test_arg_array_with_plus
         | 
| 52 | 
            -
                args = Proj::Projection.parse(['+init=epsg:2029'])
         | 
| 53 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 54 | 
            -
                args = Proj::Projection.parse(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
         | 
| 55 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 56 | 
            -
              end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
              def test_arg_hash_with_string
         | 
| 59 | 
            -
                args = Proj::Projection.parse('init' => 'epsg:2029')
         | 
| 60 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 61 | 
            -
                args = Proj::Projection.parse('proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil)
         | 
| 62 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 63 | 
            -
              end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
              def test_arg_hash_with_symbol
         | 
| 66 | 
            -
                args = Proj::Projection.parse(:init => 'epsg:2029')
         | 
| 67 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 68 | 
            -
                args = Proj::Projection.parse(:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil)
         | 
| 69 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 70 | 
            -
              end
         | 
| 71 | 
            -
             | 
| 72 | 
            -
              def test_arg_hash_with_symbol_simple
         | 
| 73 | 
            -
                args = Proj::Projection.parse(:init => 'epsg:2029')
         | 
| 74 | 
            -
                assert_equal(@epsg2029i, args)
         | 
| 75 | 
            -
                args = Proj::Projection.parse(:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil)
         | 
| 76 | 
            -
                assert_equal(@epsg2029_args, args)
         | 
| 77 | 
            -
              end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
              def test_arg_projection
         | 
| 80 | 
            -
                proj = Proj::Projection.new(['+init=epsg:2029'])
         | 
| 81 | 
            -
                args = Proj::Projection.parse(proj)
         | 
| 82 | 
            -
                assert_equal(["+init=epsg:2029", "+proj=utm", "+zone=17", "+ellps=clrk66", "+units=m", "+no_defs"], args)
         | 
| 83 | 
            -
              end
         | 
| 84 | 
            -
             | 
| 85 | 
            -
              def test_init_arg_string
         | 
| 86 | 
            -
                proj = Proj::Projection.new('+init=epsg:2029')
         | 
| 87 | 
            -
                assert_equal(' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
         | 
| 88 | 
            -
              end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
              def test_init_arg_array
         | 
| 91 | 
            -
                proj = Proj::Projection.new(['+init=epsg:2029'])
         | 
| 92 | 
            -
                assert_equal(' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
         | 
| 93 | 
            -
              end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
              def test_init_arg_hash
         | 
| 96 | 
            -
                proj = Proj::Projection.new(:proj => 'utm', 'zone' => '17', 'ellps' => 'clrk66', :units => 'm', :no_defs => nil)
         | 
| 97 | 
            -
                assert_equal(' +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
         | 
| 98 | 
            -
              end
         | 
| 99 | 
            -
             | 
| 100 | 
            -
              def test_init_arg_fail
         | 
| 101 | 
            -
                assert_raises Proj::Error do
         | 
| 102 | 
            -
                  Proj::Projection.new(:proj => 'xxxx')
         | 
| 103 | 
            -
                end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                assert_raises Proj::Error do
         | 
| 106 | 
            -
                  Proj::Projection.new(:foo => 'xxxx')
         | 
| 107 | 
            -
                end
         | 
| 108 | 
            -
              end
         | 
| 109 | 
            -
             | 
| 110 | 
            -
              def test_is_latlong
         | 
| 111 | 
            -
                assert(@proj_wgs84.isLatLong?)
         | 
| 112 | 
            -
                refute(@proj_gk.isLatLong?)
         | 
| 113 | 
            -
                refute(@proj_conakry.isLatLong?)
         | 
| 114 | 
            -
                refute(@proj_ortel.isLatLong?)
         | 
| 115 | 
            -
              end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
              def test_is_geocent
         | 
| 118 | 
            -
                assert_equal(@proj_gk.isGeocent?, @proj_gk.isGeocentric?)  # two names for same method
         | 
| 119 | 
            -
                refute(@proj_wgs84.isGeocent?)
         | 
| 120 | 
            -
                refute(@proj_gk.isGeocent?)
         | 
| 121 | 
            -
                refute(@proj_conakry.isGeocent?)
         | 
| 122 | 
            -
                refute(@proj_ortel.isGeocent?)
         | 
| 123 | 
            -
              end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
              def test_get_def
         | 
| 126 | 
            -
                assert_equal(' +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0', @proj_wgs84.getDef)
         | 
| 127 | 
            -
                assert_equal(' +init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +units=m +no_defs', @proj_gk.getDef)
         | 
| 128 | 
            -
                assert_equal('+proj=ortel +lon_0=90w +ellps=GRS80', @proj_ortel.getDef.strip)
         | 
| 129 | 
            -
              end
         | 
| 130 | 
            -
             | 
| 131 | 
            -
              def test_to_s
         | 
| 132 | 
            -
                assert_equal('#<Proj::Projection +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0>', @proj_wgs84.to_s)
         | 
| 133 | 
            -
              end
         | 
| 134 | 
            -
             | 
| 135 | 
            -
              def test_projection
         | 
| 136 | 
            -
                assert_equal('longlat', @proj_wgs84.projection)
         | 
| 137 | 
            -
                assert_equal('tmerc', @proj_gk.projection)
         | 
| 138 | 
            -
                assert_equal('utm', @proj_conakry.projection)
         | 
| 139 | 
            -
                assert_equal('ortel', @proj_ortel.projection)
         | 
| 140 | 
            -
              end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
              def test_datum
         | 
| 143 | 
            -
                assert_equal('WGS84', @proj_wgs84.datum)
         | 
| 144 | 
            -
                assert_nil(@proj_gk.datum)
         | 
| 145 | 
            -
                assert_nil(@proj_conakry.datum)
         | 
| 146 | 
            -
              end
         | 
| 147 | 
            -
             | 
| 148 | 
            -
              # echo "8.4302123334 48.9906726079" | proj +init=epsg:31467 -
         | 
| 149 | 
            -
              def test_forward_gk
         | 
| 150 | 
            -
                point = Proj::Point.new(8.4302123334, 48.9906726079)
         | 
| 151 | 
            -
                result = @proj_gk.forward(point.to_radians)
         | 
| 152 | 
            -
                assert_in_delta(3458305.0, result.x, 0.1)
         | 
| 153 | 
            -
                assert_in_delta(5428192.0, result.y, 0.1)
         | 
| 154 | 
            -
              end
         | 
| 155 | 
            -
             | 
| 156 | 
            -
              def test_forward_gk_degrees
         | 
| 157 | 
            -
                point = Proj::Point.new(8.4302123334, 48.9906726079)
         | 
| 158 | 
            -
                result = @proj_gk.forwardDeg(point)
         | 
| 159 | 
            -
                assert_in_delta(3458305.0, result.x, 0.1)
         | 
| 160 | 
            -
                assert_in_delta(5428192.0, result.y, 0.1)
         | 
| 161 | 
            -
              end
         | 
| 162 | 
            -
             | 
| 163 | 
            -
              # echo "3458305 5428192" | invproj -f '%.10f' +init=epsg:31467 -
         | 
| 164 | 
            -
              def test_inverse_gk
         | 
| 165 | 
            -
                point = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 166 | 
            -
                result = @proj_gk.inverse(point).to_degrees
         | 
| 167 | 
            -
                assert_in_delta(result.x, 8.4302123334, PRECISION)
         | 
| 168 | 
            -
                assert_in_delta(result.y, 48.9906726079, PRECISION)
         | 
| 169 | 
            -
              end
         | 
| 170 | 
            -
             | 
| 171 | 
            -
              def test_inverse_gk_degrees
         | 
| 172 | 
            -
                point = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 173 | 
            -
                result = @proj_gk.inverseDeg(point)
         | 
| 174 | 
            -
                assert_in_delta(result.x, 8.4302123334, PRECISION)
         | 
| 175 | 
            -
                assert_in_delta(result.y, 48.9906726079, PRECISION)
         | 
| 176 | 
            -
              end
         | 
| 177 | 
            -
             | 
| 178 | 
            -
              # echo "190 92" | proj +init=epsg:31467 -
         | 
| 179 | 
            -
              def test_out_of_bounds
         | 
| 180 | 
            -
                error = assert_raises(Proj::Error) do
         | 
| 181 | 
            -
                  point = Proj::Point.new(190, 92).to_radians
         | 
| 182 | 
            -
                  @proj_gk.forward(point)
         | 
| 183 | 
            -
                end
         | 
| 184 | 
            -
                assert_equal('latitude or longitude exceeded limits', error.message)
         | 
| 185 | 
            -
              end
         | 
| 186 | 
            -
             | 
| 187 | 
            -
              # echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
         | 
| 188 | 
            -
              def test_gk_to_wgs84
         | 
| 189 | 
            -
                from = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 190 | 
            -
                to = @proj_gk.transform(@proj_wgs84, from).to_degrees
         | 
| 191 | 
            -
                assert_in_delta(8.4302123334, to.x, PRECISION)
         | 
| 192 | 
            -
                assert_in_delta(48.9906726079, to.y, PRECISION)
         | 
| 193 | 
            -
              end
         | 
| 194 | 
            -
             | 
| 195 | 
            -
              # echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
         | 
| 196 | 
            -
              def test_wgs84_to_gk
         | 
| 197 | 
            -
                from = Proj::Point.new(8.4302123334, 48.9906726079)
         | 
| 198 | 
            -
                to = @proj_wgs84.transform(@proj_gk, from.to_radians)
         | 
| 199 | 
            -
                assert_in_delta(3458305.0, to.x, PRECISION)
         | 
| 200 | 
            -
                assert_in_delta(5428192.0, to.y, PRECISION)
         | 
| 201 | 
            -
              end
         | 
| 202 | 
            -
             | 
| 203 | 
            -
              def test_mercator_at_pole_raise
         | 
| 204 | 
            -
                from = Proj::Point.new(0, 90)
         | 
| 205 | 
            -
                assert_raises(Proj::Error) do
         | 
| 206 | 
            -
                  @proj_wgs84.transform(@proj_merc, from.to_radians)
         | 
| 207 | 
            -
                end
         | 
| 208 | 
            -
              end
         | 
| 209 | 
            -
             | 
| 210 | 
            -
              def test_collection
         | 
| 211 | 
            -
                from0 = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 212 | 
            -
                from1 = Proj::Point.new(0, 0)
         | 
| 213 | 
            -
                collection = @proj_gk.transform_all(@proj_wgs84, [from0, from1])
         | 
| 214 | 
            -
             | 
| 215 | 
            -
                to0 = collection[0].to_degrees
         | 
| 216 | 
            -
                to1 = collection[1].to_degrees
         | 
| 217 | 
            -
             | 
| 218 | 
            -
                assert_in_delta(8.4302123334, to0.x, PRECISION)
         | 
| 219 | 
            -
                assert_in_delta(48.9906726079, to0.y, PRECISION)
         | 
| 220 | 
            -
             | 
| 221 | 
            -
                assert_in_delta(-20.9657785647, to1.x, PRECISION)
         | 
| 222 | 
            -
                assert_in_delta(0, to1.y, PRECISION)
         | 
| 223 | 
            -
              end
         | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative './abstract_test'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class ProjectionTest < AbstractTest
         | 
| 6 | 
            +
              PRECISION = 0.1 ** 4
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              def setup
         | 
| 9 | 
            +
                @proj_wgs84 = Proj::Projection.new(["init=epsg:4326"])       # WGS84
         | 
| 10 | 
            +
                @proj_gk = Proj::Projection.new(["+init=epsg:31467"])      # Gauss-Kruger Zone 3
         | 
| 11 | 
            +
                @proj_merc  = Proj::Projection.new(["proj=merc"])
         | 
| 12 | 
            +
                @proj_conakry = Proj::Projection.new(["+init=epsg:31528"])      # Conakry 1905 / UTM zone 28N
         | 
| 13 | 
            +
                @proj_ortel = Proj::Projection.new(["+proj=ortel", "+lon_0=90w"])  # Ortelius Oval Projection
         | 
| 14 | 
            +
                @epsg2029i = ['+init=epsg:2029']
         | 
| 15 | 
            +
                @epsg2029_args = ['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs']
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def test_arg_fail
         | 
| 19 | 
            +
                assert_raises ArgumentError do
         | 
| 20 | 
            +
                  Proj::Projection.parse()
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
                assert_raises ArgumentError do
         | 
| 23 | 
            +
                  Proj::Projection.parse(nil)
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
                assert_raises ArgumentError do
         | 
| 26 | 
            +
                  Proj::Projection.parse(1)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def test_arg_string
         | 
| 31 | 
            +
                args = Proj::Projection.parse('+init=epsg:2029')
         | 
| 32 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 33 | 
            +
                args = Proj::Projection.parse('  +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs  ')
         | 
| 34 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              def test_arg_string_with_plus
         | 
| 38 | 
            +
                args = Proj::Projection.parse('+init=epsg:2029')
         | 
| 39 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 40 | 
            +
                args = Proj::Projection.parse('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
         | 
| 41 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def test_arg_array
         | 
| 45 | 
            +
                args = Proj::Projection.parse(['+init=epsg:2029'])
         | 
| 46 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 47 | 
            +
                args = Proj::Projection.parse(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
         | 
| 48 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              def test_arg_array_with_plus
         | 
| 52 | 
            +
                args = Proj::Projection.parse(['+init=epsg:2029'])
         | 
| 53 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 54 | 
            +
                args = Proj::Projection.parse(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
         | 
| 55 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              def test_arg_hash_with_string
         | 
| 59 | 
            +
                args = Proj::Projection.parse('init' => 'epsg:2029')
         | 
| 60 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 61 | 
            +
                args = Proj::Projection.parse('proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil)
         | 
| 62 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              def test_arg_hash_with_symbol
         | 
| 66 | 
            +
                args = Proj::Projection.parse(:init => 'epsg:2029')
         | 
| 67 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 68 | 
            +
                args = Proj::Projection.parse(:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil)
         | 
| 69 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              def test_arg_hash_with_symbol_simple
         | 
| 73 | 
            +
                args = Proj::Projection.parse(:init => 'epsg:2029')
         | 
| 74 | 
            +
                assert_equal(@epsg2029i, args)
         | 
| 75 | 
            +
                args = Proj::Projection.parse(:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil)
         | 
| 76 | 
            +
                assert_equal(@epsg2029_args, args)
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              def test_arg_projection
         | 
| 80 | 
            +
                proj = Proj::Projection.new(['+init=epsg:2029'])
         | 
| 81 | 
            +
                args = Proj::Projection.parse(proj)
         | 
| 82 | 
            +
                assert_equal(["+init=epsg:2029", "+proj=utm", "+zone=17", "+ellps=clrk66", "+units=m", "+no_defs"], args)
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
              def test_init_arg_string
         | 
| 86 | 
            +
                proj = Proj::Projection.new('+init=epsg:2029')
         | 
| 87 | 
            +
                assert_equal(' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
              def test_init_arg_array
         | 
| 91 | 
            +
                proj = Proj::Projection.new(['+init=epsg:2029'])
         | 
| 92 | 
            +
                assert_equal(' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
         | 
| 93 | 
            +
              end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              def test_init_arg_hash
         | 
| 96 | 
            +
                proj = Proj::Projection.new(:proj => 'utm', 'zone' => '17', 'ellps' => 'clrk66', :units => 'm', :no_defs => nil)
         | 
| 97 | 
            +
                assert_equal(' +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
         | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
              def test_init_arg_fail
         | 
| 101 | 
            +
                assert_raises Proj::Error do
         | 
| 102 | 
            +
                  Proj::Projection.new(:proj => 'xxxx')
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                assert_raises Proj::Error do
         | 
| 106 | 
            +
                  Proj::Projection.new(:foo => 'xxxx')
         | 
| 107 | 
            +
                end
         | 
| 108 | 
            +
              end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
              def test_is_latlong
         | 
| 111 | 
            +
                assert(@proj_wgs84.isLatLong?)
         | 
| 112 | 
            +
                refute(@proj_gk.isLatLong?)
         | 
| 113 | 
            +
                refute(@proj_conakry.isLatLong?)
         | 
| 114 | 
            +
                refute(@proj_ortel.isLatLong?)
         | 
| 115 | 
            +
              end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              def test_is_geocent
         | 
| 118 | 
            +
                assert_equal(@proj_gk.isGeocent?, @proj_gk.isGeocentric?)  # two names for same method
         | 
| 119 | 
            +
                refute(@proj_wgs84.isGeocent?)
         | 
| 120 | 
            +
                refute(@proj_gk.isGeocent?)
         | 
| 121 | 
            +
                refute(@proj_conakry.isGeocent?)
         | 
| 122 | 
            +
                refute(@proj_ortel.isGeocent?)
         | 
| 123 | 
            +
              end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
              def test_get_def
         | 
| 126 | 
            +
                assert_equal(' +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0', @proj_wgs84.getDef)
         | 
| 127 | 
            +
                assert_equal(' +init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +units=m +no_defs', @proj_gk.getDef)
         | 
| 128 | 
            +
                assert_equal('+proj=ortel +lon_0=90w +ellps=GRS80', @proj_ortel.getDef.strip)
         | 
| 129 | 
            +
              end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
              def test_to_s
         | 
| 132 | 
            +
                assert_equal('#<Proj::Projection +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0>', @proj_wgs84.to_s)
         | 
| 133 | 
            +
              end
         | 
| 134 | 
            +
             | 
| 135 | 
            +
              def test_projection
         | 
| 136 | 
            +
                assert_equal('longlat', @proj_wgs84.projection)
         | 
| 137 | 
            +
                assert_equal('tmerc', @proj_gk.projection)
         | 
| 138 | 
            +
                assert_equal('utm', @proj_conakry.projection)
         | 
| 139 | 
            +
                assert_equal('ortel', @proj_ortel.projection)
         | 
| 140 | 
            +
              end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
              def test_datum
         | 
| 143 | 
            +
                assert_equal('WGS84', @proj_wgs84.datum)
         | 
| 144 | 
            +
                assert_nil(@proj_gk.datum)
         | 
| 145 | 
            +
                assert_nil(@proj_conakry.datum)
         | 
| 146 | 
            +
              end
         | 
| 147 | 
            +
             | 
| 148 | 
            +
              # echo "8.4302123334 48.9906726079" | proj +init=epsg:31467 -
         | 
| 149 | 
            +
              def test_forward_gk
         | 
| 150 | 
            +
                point = Proj::Point.new(8.4302123334, 48.9906726079)
         | 
| 151 | 
            +
                result = @proj_gk.forward(point.to_radians)
         | 
| 152 | 
            +
                assert_in_delta(3458305.0, result.x, 0.1)
         | 
| 153 | 
            +
                assert_in_delta(5428192.0, result.y, 0.1)
         | 
| 154 | 
            +
              end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
              def test_forward_gk_degrees
         | 
| 157 | 
            +
                point = Proj::Point.new(8.4302123334, 48.9906726079)
         | 
| 158 | 
            +
                result = @proj_gk.forwardDeg(point)
         | 
| 159 | 
            +
                assert_in_delta(3458305.0, result.x, 0.1)
         | 
| 160 | 
            +
                assert_in_delta(5428192.0, result.y, 0.1)
         | 
| 161 | 
            +
              end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
              # echo "3458305 5428192" | invproj -f '%.10f' +init=epsg:31467 -
         | 
| 164 | 
            +
              def test_inverse_gk
         | 
| 165 | 
            +
                point = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 166 | 
            +
                result = @proj_gk.inverse(point).to_degrees
         | 
| 167 | 
            +
                assert_in_delta(result.x, 8.4302123334, PRECISION)
         | 
| 168 | 
            +
                assert_in_delta(result.y, 48.9906726079, PRECISION)
         | 
| 169 | 
            +
              end
         | 
| 170 | 
            +
             | 
| 171 | 
            +
              def test_inverse_gk_degrees
         | 
| 172 | 
            +
                point = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 173 | 
            +
                result = @proj_gk.inverseDeg(point)
         | 
| 174 | 
            +
                assert_in_delta(result.x, 8.4302123334, PRECISION)
         | 
| 175 | 
            +
                assert_in_delta(result.y, 48.9906726079, PRECISION)
         | 
| 176 | 
            +
              end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
              # echo "190 92" | proj +init=epsg:31467 -
         | 
| 179 | 
            +
              def test_out_of_bounds
         | 
| 180 | 
            +
                error = assert_raises(Proj::Error) do
         | 
| 181 | 
            +
                  point = Proj::Point.new(190, 92).to_radians
         | 
| 182 | 
            +
                  @proj_gk.forward(point)
         | 
| 183 | 
            +
                end
         | 
| 184 | 
            +
                assert_equal('latitude or longitude exceeded limits', error.message)
         | 
| 185 | 
            +
              end
         | 
| 186 | 
            +
             | 
| 187 | 
            +
              # echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
         | 
| 188 | 
            +
              def test_gk_to_wgs84
         | 
| 189 | 
            +
                from = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 190 | 
            +
                to = @proj_gk.transform(@proj_wgs84, from).to_degrees
         | 
| 191 | 
            +
                assert_in_delta(8.4302123334, to.x, PRECISION)
         | 
| 192 | 
            +
                assert_in_delta(48.9906726079, to.y, PRECISION)
         | 
| 193 | 
            +
              end
         | 
| 194 | 
            +
             | 
| 195 | 
            +
              # echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
         | 
| 196 | 
            +
              def test_wgs84_to_gk
         | 
| 197 | 
            +
                from = Proj::Point.new(8.4302123334, 48.9906726079)
         | 
| 198 | 
            +
                to = @proj_wgs84.transform(@proj_gk, from.to_radians)
         | 
| 199 | 
            +
                assert_in_delta(3458305.0, to.x, PRECISION)
         | 
| 200 | 
            +
                assert_in_delta(5428192.0, to.y, PRECISION)
         | 
| 201 | 
            +
              end
         | 
| 202 | 
            +
             | 
| 203 | 
            +
              def test_mercator_at_pole_raise
         | 
| 204 | 
            +
                from = Proj::Point.new(0, 90)
         | 
| 205 | 
            +
                assert_raises(Proj::Error) do
         | 
| 206 | 
            +
                  @proj_wgs84.transform(@proj_merc, from.to_radians)
         | 
| 207 | 
            +
                end
         | 
| 208 | 
            +
              end
         | 
| 209 | 
            +
             | 
| 210 | 
            +
              def test_collection
         | 
| 211 | 
            +
                from0 = Proj::Point.new(3458305.0, 5428192.0)
         | 
| 212 | 
            +
                from1 = Proj::Point.new(0, 0)
         | 
| 213 | 
            +
                collection = @proj_gk.transform_all(@proj_wgs84, [from0, from1])
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                to0 = collection[0].to_degrees
         | 
| 216 | 
            +
                to1 = collection[1].to_degrees
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                assert_in_delta(8.4302123334, to0.x, PRECISION)
         | 
| 219 | 
            +
                assert_in_delta(48.9906726079, to0.y, PRECISION)
         | 
| 220 | 
            +
             | 
| 221 | 
            +
                assert_in_delta(-20.9657785647, to1.x, PRECISION)
         | 
| 222 | 
            +
                assert_in_delta(0, to1.y, PRECISION)
         | 
| 223 | 
            +
              end
         | 
| 224 224 | 
             
            end
         |