proj4rb 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/projrb.c +0 -2
- data/lib/proj4.rb +417 -410
- data/test/test_constants.rb +12 -14
- data/test/test_create_projection.rb +57 -58
- data/test/test_datums.rb +38 -37
- data/test/test_ellipsoids.rb +38 -37
- data/test/test_errors.rb +50 -54
- data/test/test_init_projection.rb +94 -93
- data/test/test_prime_meridians.rb +37 -36
- data/test/test_projection_type.rb +36 -35
- data/test/test_simple_projection.rb +50 -49
- data/test/test_suite.rb +14 -0
- data/test/test_transform.rb +99 -98
- data/test/test_units.rb +38 -37
- metadata +6 -4
data/test/test_constants.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
class ConstantsTest < Test::Unit::TestCase
|
7
|
+
def test_version
|
8
|
+
assert 440 < Proj4::LIBVERSION
|
9
|
+
end
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def test_deg
|
12
|
-
assert_equal Math::PI/180, Proj4::DEG_TO_RAD
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_rad
|
16
|
-
assert_equal 180/Math::PI, Proj4::RAD_TO_DEG
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
11
|
+
def test_deg
|
12
|
+
assert_equal Math::PI/180, Proj4::DEG_TO_RAD
|
13
|
+
end
|
20
14
|
|
15
|
+
def test_rad
|
16
|
+
assert_equal 180/Math::PI, Proj4::RAD_TO_DEG
|
17
|
+
end
|
18
|
+
end
|
@@ -1,64 +1,63 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
class CreateProjectionTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
7
|
+
def setup
|
8
|
+
@proj_wgs84 = Proj4::Projection.new(["init=epsg:4326"]) # WGS84
|
9
|
+
@proj_gk = Proj4::Projection.new(["init=epsg:31467"]) # Gauss-Kruger Zone 3
|
10
|
+
@proj_conakry = Proj4::Projection.new(["init=epsg:31528"]) # Conakry 1905 / UTM zone 28N
|
11
|
+
@proj_ortel = Proj4::Projection.new(["proj=ortel", "lon_0=90w"]) # Ortelius Oval Projection
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_has_inverse
|
15
|
+
assert @proj_wgs84.hasInverse?
|
16
|
+
assert @proj_gk.hasInverse?
|
17
|
+
assert @proj_conakry.hasInverse?
|
18
|
+
assert ! @proj_ortel.hasInverse?
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_is_latlong
|
22
|
+
assert @proj_wgs84.isLatLong?
|
23
|
+
assert ! @proj_gk.isLatLong?
|
24
|
+
assert ! @proj_conakry.isLatLong?
|
25
|
+
assert ! @proj_ortel.isLatLong?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_is_geocent
|
29
|
+
assert_equal @proj_gk.isGeocent?, @proj_gk.isGeocentric? # two names for same method
|
30
|
+
assert ! @proj_wgs84.isGeocent?
|
31
|
+
assert ! @proj_gk.isGeocent?
|
32
|
+
assert ! @proj_conakry.isGeocent?
|
33
|
+
assert ! @proj_ortel.isGeocent?
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_def
|
37
|
+
assert_equal '+init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0', @proj_wgs84.getDef.strip
|
38
|
+
d = @proj_gk.getDef.strip
|
39
|
+
assert ('+init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs +towgs84=606.0,23.0,413.0' == d || '+init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1.000000 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs +towgs84=606.0,23.0,413.0' == d)
|
40
|
+
assert_equal '+init=epsg:31528 +proj=utm +zone=28 +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0 +units=m +no_defs', @proj_conakry.getDef.strip
|
41
|
+
assert_equal '+proj=ortel +lon_0=90w +ellps=WGS84', @proj_ortel.getDef.strip
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_inspect
|
45
|
+
assert_equal '#<Proj4::Projection +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0>', @proj_wgs84.to_s
|
46
|
+
assert_equal '#<Proj4::Projection +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0>', @proj_wgs84.inspect
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_projection
|
50
|
+
assert_equal 'longlat', @proj_wgs84.projection
|
51
|
+
assert_equal 'tmerc', @proj_gk.projection
|
52
|
+
assert_equal 'utm', @proj_conakry.projection
|
53
|
+
assert_equal 'ortel', @proj_ortel.projection
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_datum
|
57
|
+
assert_equal 'WGS84', @proj_wgs84.datum
|
58
|
+
assert_equal 'potsdam', @proj_gk.datum
|
59
|
+
assert_nil @proj_conakry.datum
|
60
|
+
assert_nil @proj_ortel.datum
|
61
|
+
end
|
63
62
|
end
|
64
63
|
|
data/test/test_datums.rb
CHANGED
@@ -1,44 +1,45 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
if Proj4::LIBVERSION >= 449
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def test_compare
|
27
|
-
u1 = Proj4::Datum.get('potsdam')
|
28
|
-
u2 = Proj4::Datum.get('potsdam')
|
29
|
-
assert u1 == u2
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_failed_get
|
33
|
-
datum = Proj4::Datum.get('foo')
|
34
|
-
assert_nil datum
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_new
|
38
|
-
assert_raise TypeError do
|
39
|
-
Proj4::Datum.new
|
40
|
-
end
|
41
|
-
end
|
7
|
+
class DatumsTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_get_all
|
10
|
+
datums = Proj4::Datum.list.sort.collect{ |u| u.id }
|
11
|
+
assert datums.index('WGS84')
|
12
|
+
assert datums.index('potsdam')
|
13
|
+
assert datums.index('ire65')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_one
|
17
|
+
datum = Proj4::Datum.get('potsdam')
|
18
|
+
assert_kind_of Proj4::Datum, datum
|
19
|
+
assert_equal 'potsdam', datum.id
|
20
|
+
assert_equal 'potsdam', datum.to_s
|
21
|
+
assert_equal 'bessel', datum.ellipse_id
|
22
|
+
assert_equal 'towgs84=606.0,23.0,413.0', datum.defn
|
23
|
+
assert_equal 'Potsdam Rauenberg 1950 DHDN', datum.comments
|
24
|
+
assert_equal '#<Proj4::Datum id="potsdam", ellipse_id="bessel", defn="towgs84=606.0,23.0,413.0", comments="Potsdam Rauenberg 1950 DHDN">', datum.inspect
|
25
|
+
end
|
42
26
|
|
27
|
+
def test_compare
|
28
|
+
u1 = Proj4::Datum.get('potsdam')
|
29
|
+
u2 = Proj4::Datum.get('potsdam')
|
30
|
+
assert u1 == u2
|
43
31
|
end
|
32
|
+
|
33
|
+
def test_failed_get
|
34
|
+
datum = Proj4::Datum.get('foo')
|
35
|
+
assert_nil datum
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_new
|
39
|
+
assert_raise TypeError do
|
40
|
+
Proj4::Datum.new
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
44
45
|
end
|
data/test/test_ellipsoids.rb
CHANGED
@@ -1,45 +1,46 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
if Proj4::LIBVERSION >= 449
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def test_compare
|
27
|
-
e1 = Proj4::Ellipsoid.get('bessel')
|
28
|
-
e2 = Proj4::Ellipsoid.get('bessel')
|
29
|
-
assert e1 == e2
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_failed_get
|
33
|
-
ellipsoid = Proj4::Ellipsoid.get('foo')
|
34
|
-
assert_nil ellipsoid
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_new
|
38
|
-
assert_raise TypeError do
|
39
|
-
Proj4::Ellipsoid.new
|
40
|
-
end
|
41
|
-
end
|
7
|
+
class EllipsoidsTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_get_all
|
10
|
+
ellipsoids = Proj4::Ellipsoid.list.sort.collect{ |u| u.id }
|
11
|
+
assert ellipsoids.index('WGS84')
|
12
|
+
assert ellipsoids.index('bessel')
|
13
|
+
assert ellipsoids.index('lerch')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_one
|
17
|
+
ellipsoid = Proj4::Ellipsoid.get('bessel')
|
18
|
+
assert_kind_of Proj4::Ellipsoid, ellipsoid
|
19
|
+
assert_equal 'bessel', ellipsoid.id
|
20
|
+
assert_equal 'a=6377397.155', ellipsoid.major
|
21
|
+
assert_equal 'rf=299.1528128', ellipsoid.ell
|
22
|
+
assert_equal 'Bessel 1841', ellipsoid.name
|
23
|
+
assert_equal 'bessel', ellipsoid.to_s
|
24
|
+
assert_equal '#<Proj4::Ellipsoid id="bessel", major="a=6377397.155", ell="rf=299.1528128", name="Bessel 1841">', ellipsoid.inspect
|
25
|
+
end
|
42
26
|
|
27
|
+
def test_compare
|
28
|
+
e1 = Proj4::Ellipsoid.get('bessel')
|
29
|
+
e2 = Proj4::Ellipsoid.get('bessel')
|
30
|
+
assert e1 == e2
|
43
31
|
end
|
32
|
+
|
33
|
+
def test_failed_get
|
34
|
+
ellipsoid = Proj4::Ellipsoid.get('foo')
|
35
|
+
assert_nil ellipsoid
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_new
|
39
|
+
assert_raise TypeError do
|
40
|
+
Proj4::Ellipsoid.new
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
44
45
|
end
|
45
46
|
|
data/test/test_errors.rb
CHANGED
@@ -1,70 +1,66 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
class ErrorsTest < Test::Unit::TestCase
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def test_list
|
9
|
+
assert_equal "Unknown", Proj4::Error.error(0)
|
10
|
+
assert_equal "NoOptionsInInitFile", Proj4::Error.error(2)
|
11
|
+
assert_equal "NoOptionsInInitFile", Proj4::Error.error(-2)
|
12
|
+
assert_equal "Unknown", Proj4::Error.error(-2000)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def test_parenting
|
16
|
+
assert_kind_of Proj4::Error, Proj4::UnknownError.new
|
17
|
+
assert_kind_of Proj4::Error, Proj4::ToleranceConditionError.new
|
18
|
+
assert_kind_of StandardError, Proj4::UnknownError.new
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def test_num
|
22
|
+
assert 0, Proj4::UnknownError.errnum
|
23
|
+
assert 1, Proj4::NoArgsInInitListError.errnum
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
assert_raise Proj4::NoOptionsInInitFileError do
|
30
|
-
Proj4::Error.raise_error(2)
|
31
|
-
end
|
32
|
-
assert_raise Proj4::ProjectionNotNamedError do
|
33
|
-
Proj4::Error.raise_error(-4)
|
34
|
-
end
|
35
|
-
assert_raise Proj4::UnknownError do
|
36
|
-
Proj4::Error.raise_error(2000)
|
37
|
-
end
|
26
|
+
def test_raise
|
27
|
+
assert_raise Proj4::UnknownError do
|
28
|
+
Proj4::Error.raise_error(0)
|
38
29
|
end
|
39
|
-
|
40
|
-
|
41
|
-
assert_equal 'no arguments in initialization list', Proj4::Error.message(-1)
|
42
|
-
assert_equal 'reciprocal flattening (1/f) = 0', Proj4::Error.message(-10)
|
43
|
-
assert_equal 'unknown error', Proj4::Error.message(0)
|
44
|
-
assert_match /^invalid projection system error/, Proj4::Error.message(-2000)
|
30
|
+
assert_raise Proj4::NoOptionsInInitFileError do
|
31
|
+
Proj4::Error.raise_error(2)
|
45
32
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
assert_equal Proj4::UnknownError, exception.class
|
52
|
-
assert_equal "unknown error", exception.message
|
53
|
-
assert_equal 0, exception.errnum
|
54
|
-
assert_match %r{test/test_errors.rb:[0-9]+:in .test_raise_err0.$} , exception.backtrace[0]
|
55
|
-
end
|
33
|
+
assert_raise Proj4::ProjectionNotNamedError do
|
34
|
+
Proj4::Error.raise_error(-4)
|
35
|
+
end
|
36
|
+
assert_raise Proj4::UnknownError do
|
37
|
+
Proj4::Error.raise_error(2000)
|
56
38
|
end
|
39
|
+
end
|
57
40
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
41
|
+
def test_strerrno
|
42
|
+
assert_equal 'no arguments in initialization list', Proj4::Error.message(-1)
|
43
|
+
assert_equal 'reciprocal flattening (1/f) = 0', Proj4::Error.message(-10)
|
44
|
+
assert_equal 'unknown error', Proj4::Error.message(0)
|
45
|
+
assert_match /^invalid projection system error/, Proj4::Error.message(-2000)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_raise_err0
|
49
|
+
exception = assert_raise(Proj4::UnknownError) do
|
50
|
+
Proj4::Error.raise_error(0)
|
67
51
|
end
|
52
|
+
assert_equal "unknown error", exception.message
|
53
|
+
assert_equal 0, exception.errnum
|
54
|
+
assert_match %r{test/test_errors.rb:[0-9]+:in .test_raise_err0.$} , exception.backtrace[0]
|
55
|
+
end
|
68
56
|
|
57
|
+
def test_raise_err1
|
58
|
+
exception = assert_raise(Proj4::NoArgsInInitListError) do
|
59
|
+
Proj4::Error.raise_error(1)
|
60
|
+
end
|
61
|
+
assert_equal 'no arguments in initialization list', exception.message
|
62
|
+
assert_equal 1, exception.errnum
|
63
|
+
assert_match %r{test/test_errors.rb:[0-9]+:in .test_raise_err1.$} , exception.backtrace[0]
|
64
|
+
end
|
69
65
|
end
|
70
66
|
|
@@ -1,108 +1,109 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
class InitProjectionTest < Test::Unit::TestCase
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@nad = ' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs'
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_arg_fail
|
17
|
-
assert_raise ArgumentError do
|
18
|
-
Proj4::Projection._parse_init_parameters()
|
19
|
-
end
|
20
|
-
assert_raise ArgumentError do
|
21
|
-
Proj4::Projection._parse_init_parameters(nil)
|
22
|
-
end
|
23
|
-
assert_raise ArgumentError do
|
24
|
-
Proj4::Projection._parse_init_parameters(1)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_arg_string
|
29
|
-
args = Proj4::Projection._parse_init_parameters('init=epsg:2029')
|
30
|
-
assert_equal @epsg2029i, args
|
31
|
-
args = Proj4::Projection._parse_init_parameters(' proj=utm zone=17 ellps=clrk66 units=m no_defs ')
|
32
|
-
assert_equal @epsg2029x, args.sort
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_arg_string_with_plus
|
36
|
-
args = Proj4::Projection._parse_init_parameters('+init=epsg:2029')
|
37
|
-
assert_equal @epsg2029i, args
|
38
|
-
args = Proj4::Projection._parse_init_parameters('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
|
39
|
-
assert_equal @epsg2029x, args.sort
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_arg_array
|
43
|
-
args = Proj4::Projection._parse_init_parameters(['init=epsg:2029'])
|
44
|
-
assert_equal @epsg2029i, args
|
45
|
-
args = Proj4::Projection._parse_init_parameters(['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'])
|
46
|
-
assert_equal @epsg2029x, args.sort
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_arg_array_with_plus
|
50
|
-
args = Proj4::Projection._parse_init_parameters(['+init=epsg:2029'])
|
51
|
-
assert_equal @epsg2029i, args
|
52
|
-
args = Proj4::Projection._parse_init_parameters(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
|
53
|
-
assert_equal @epsg2029x, args.sort
|
54
|
-
end
|
8
|
+
def setup
|
9
|
+
# NAD27(76) / UTM zone 17N
|
10
|
+
# <2029> +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs no_defs <>
|
11
|
+
@epsg2029i = ['init=epsg:2029']
|
12
|
+
@epsg2029x = ['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'].sort
|
55
13
|
|
56
|
-
|
57
|
-
|
58
|
-
assert_equal @epsg2029i, args
|
59
|
-
args = Proj4::Projection._parse_init_parameters( {'proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil} )
|
60
|
-
assert_equal @epsg2029x, args.sort
|
61
|
-
end
|
14
|
+
@nad = ' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs'
|
15
|
+
end
|
62
16
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
args = Proj4::Projection._parse_init_parameters( {:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil} )
|
67
|
-
assert_equal @epsg2029x, args.sort
|
17
|
+
def test_arg_fail
|
18
|
+
assert_raise ArgumentError do
|
19
|
+
Proj4::Projection._parse_init_parameters()
|
68
20
|
end
|
69
|
-
|
70
|
-
|
71
|
-
args = Proj4::Projection._parse_init_parameters( :init => 'epsg:2029' )
|
72
|
-
assert_equal @epsg2029i, args
|
73
|
-
args = Proj4::Projection._parse_init_parameters( :proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil )
|
74
|
-
assert_equal @epsg2029x, args.sort
|
21
|
+
assert_raise ArgumentError do
|
22
|
+
Proj4::Projection._parse_init_parameters(nil)
|
75
23
|
end
|
76
|
-
|
77
|
-
|
78
|
-
proj = Proj4::Projection.new(['init=epsg:2029'])
|
79
|
-
args = Proj4::Projection._parse_init_parameters(proj)
|
80
|
-
assert_equal [@epsg2029i, @epsg2029x].flatten.sort, args.sort
|
24
|
+
assert_raise ArgumentError do
|
25
|
+
Proj4::Projection._parse_init_parameters(1)
|
81
26
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_arg_string
|
30
|
+
args = Proj4::Projection._parse_init_parameters('init=epsg:2029')
|
31
|
+
assert_equal @epsg2029i, args
|
32
|
+
args = Proj4::Projection._parse_init_parameters(' proj=utm zone=17 ellps=clrk66 units=m no_defs ')
|
33
|
+
assert_equal @epsg2029x, args.sort
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_arg_string_with_plus
|
37
|
+
args = Proj4::Projection._parse_init_parameters('+init=epsg:2029')
|
38
|
+
assert_equal @epsg2029i, args
|
39
|
+
args = Proj4::Projection._parse_init_parameters('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
|
40
|
+
assert_equal @epsg2029x, args.sort
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_arg_array
|
44
|
+
args = Proj4::Projection._parse_init_parameters(['init=epsg:2029'])
|
45
|
+
assert_equal @epsg2029i, args
|
46
|
+
args = Proj4::Projection._parse_init_parameters(['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'])
|
47
|
+
assert_equal @epsg2029x, args.sort
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_arg_array_with_plus
|
51
|
+
args = Proj4::Projection._parse_init_parameters(['+init=epsg:2029'])
|
52
|
+
assert_equal @epsg2029i, args
|
53
|
+
args = Proj4::Projection._parse_init_parameters(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
|
54
|
+
assert_equal @epsg2029x, args.sort
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_arg_hash_with_string
|
58
|
+
args = Proj4::Projection._parse_init_parameters( {'init' => 'epsg:2029'} )
|
59
|
+
assert_equal @epsg2029i, args
|
60
|
+
args = Proj4::Projection._parse_init_parameters( {'proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil} )
|
61
|
+
assert_equal @epsg2029x, args.sort
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_arg_hash_with_symbol
|
65
|
+
args = Proj4::Projection._parse_init_parameters( {:init => 'epsg:2029'} )
|
66
|
+
assert_equal @epsg2029i, args
|
67
|
+
args = Proj4::Projection._parse_init_parameters( {:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil} )
|
68
|
+
assert_equal @epsg2029x, args.sort
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_arg_hash_with_symbol_simple
|
72
|
+
args = Proj4::Projection._parse_init_parameters( :init => 'epsg:2029' )
|
73
|
+
assert_equal @epsg2029i, args
|
74
|
+
args = Proj4::Projection._parse_init_parameters( :proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil )
|
75
|
+
assert_equal @epsg2029x, args.sort
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_arg_projection
|
79
|
+
proj = Proj4::Projection.new(['init=epsg:2029'])
|
80
|
+
args = Proj4::Projection._parse_init_parameters(proj)
|
81
|
+
assert_equal [@epsg2029i, @epsg2029x].flatten.sort, args.sort
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_init_arg_string
|
85
|
+
proj = Proj4::Projection.new('+init=epsg:2029')
|
86
|
+
assert_equal @nad, proj.getDef
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_init_arg_array
|
90
|
+
proj = Proj4::Projection.new(['init=epsg:2029'])
|
91
|
+
assert_equal @nad, proj.getDef
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_init_arg_hash
|
95
|
+
proj = Proj4::Projection.new( :proj => 'utm', 'zone' => '17', '+ellps' => 'clrk66', :units => 'm', :no_defs => nil )
|
96
|
+
assert_equal @epsg2029x, proj.getDef.strip.split(' ').collect{ |a| a.sub(/^\+/, '') }.sort
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_init_arg_fail
|
100
|
+
assert_raise Proj4::UnknownProjectionIdError do
|
101
|
+
Proj4::Projection.new( :proj => 'xxxx' )
|
86
102
|
end
|
87
|
-
|
88
|
-
|
89
|
-
proj = Proj4::Projection.new(['init=epsg:2029'])
|
90
|
-
assert_equal @nad, proj.getDef
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_init_arg_hash
|
94
|
-
proj = Proj4::Projection.new( :proj => 'utm', 'zone' => '17', '+ellps' => 'clrk66', :units => 'm', :no_defs => nil )
|
95
|
-
assert_equal @epsg2029x, proj.getDef.strip.split(' ').collect{ |a| a.sub(/^\+/, '') }.sort
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_init_arg_fail
|
99
|
-
assert_raise Proj4::UnknownProjectionIdError do
|
100
|
-
Proj4::Projection.new( :proj => 'xxxx' )
|
101
|
-
end
|
102
|
-
assert_raise Proj4::ProjectionNotNamedError do
|
103
|
-
Proj4::Projection.new( :foo => 'xxxx' )
|
104
|
-
end
|
103
|
+
assert_raise Proj4::ProjectionNotNamedError do
|
104
|
+
Proj4::Projection.new( :foo => 'xxxx' )
|
105
105
|
end
|
106
|
+
end
|
106
107
|
|
107
108
|
end
|
108
109
|
|