rgeo 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +6 -0
- data/README.rdoc +1 -1
- data/Version +1 -1
- data/ext/geos_c_impl/extconf.rb +13 -13
- data/ext/geos_c_impl/factory.c +30 -18
- data/ext/geos_c_impl/factory.h +18 -12
- data/ext/geos_c_impl/geometry.c +11 -11
- data/ext/geos_c_impl/geometry.h +7 -7
- data/ext/geos_c_impl/geometry_collection.c +15 -15
- data/ext/geos_c_impl/geometry_collection.h +8 -8
- data/ext/geos_c_impl/line_string.c +14 -14
- data/ext/geos_c_impl/line_string.h +7 -7
- data/ext/geos_c_impl/main.c +7 -7
- data/ext/geos_c_impl/point.c +9 -9
- data/ext/geos_c_impl/point.h +7 -7
- data/ext/geos_c_impl/polygon.c +9 -9
- data/ext/geos_c_impl/polygon.h +7 -7
- data/ext/geos_c_impl/preface.h +7 -7
- data/ext/proj4_c_impl/extconf.rb +13 -13
- data/ext/proj4_c_impl/main.c +12 -12
- data/lib/rgeo.rb +26 -26
- data/lib/rgeo/cartesian.rb +12 -12
- data/lib/rgeo/cartesian/analysis.rb +26 -26
- data/lib/rgeo/cartesian/bounding_box.rb +83 -83
- data/lib/rgeo/cartesian/calculations.rb +36 -36
- data/lib/rgeo/cartesian/factory.rb +78 -78
- data/lib/rgeo/cartesian/feature_classes.rb +74 -74
- data/lib/rgeo/cartesian/feature_methods.rb +34 -34
- data/lib/rgeo/cartesian/interface.rb +33 -33
- data/lib/rgeo/coord_sys.rb +15 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
- data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
- data/lib/rgeo/coord_sys/proj4.rb +85 -85
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
- data/lib/rgeo/error.rb +17 -17
- data/lib/rgeo/feature.rb +15 -15
- data/lib/rgeo/feature/curve.rb +58 -58
- data/lib/rgeo/feature/factory.rb +84 -84
- data/lib/rgeo/feature/factory_generator.rb +32 -32
- data/lib/rgeo/feature/geometry.rb +215 -215
- data/lib/rgeo/feature/geometry_collection.rb +46 -46
- data/lib/rgeo/feature/line.rb +21 -21
- data/lib/rgeo/feature/line_string.rb +35 -35
- data/lib/rgeo/feature/linear_ring.rb +20 -20
- data/lib/rgeo/feature/mixins.rb +61 -61
- data/lib/rgeo/feature/multi_curve.rb +37 -37
- data/lib/rgeo/feature/multi_line_string.rb +20 -20
- data/lib/rgeo/feature/multi_point.rb +22 -22
- data/lib/rgeo/feature/multi_polygon.rb +28 -28
- data/lib/rgeo/feature/multi_surface.rb +39 -39
- data/lib/rgeo/feature/point.rb +42 -42
- data/lib/rgeo/feature/polygon.rb +50 -50
- data/lib/rgeo/feature/surface.rb +42 -42
- data/lib/rgeo/feature/types.rb +58 -58
- data/lib/rgeo/geographic.rb +14 -14
- data/lib/rgeo/geographic/factory.rb +87 -87
- data/lib/rgeo/geographic/interface.rb +55 -55
- data/lib/rgeo/geographic/proj4_projector.rb +35 -35
- data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
- data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
- data/lib/rgeo/geographic/projected_window.rb +103 -103
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
- data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
- data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
- data/lib/rgeo/geographic/spherical_math.rb +58 -58
- data/lib/rgeo/geos.rb +22 -17
- data/lib/rgeo/geos/factory.rb +93 -93
- data/lib/rgeo/geos/ffi_classes.rb +306 -231
- data/lib/rgeo/geos/ffi_factory.rb +100 -96
- data/lib/rgeo/geos/impl_additions.rb +22 -22
- data/lib/rgeo/geos/interface.rb +45 -45
- data/lib/rgeo/geos/zm_factory.rb +90 -90
- data/lib/rgeo/geos/zm_impl.rb +167 -167
- data/lib/rgeo/impl_helper.rb +11 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
- data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
- data/lib/rgeo/impl_helper/math.rb +13 -13
- data/lib/rgeo/version.rb +10 -10
- data/lib/rgeo/wkrep.rb +16 -16
- data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
- data/lib/rgeo/yaml.rb +14 -14
- data/test/common/geometry_collection_tests.rb +53 -53
- data/test/common/line_string_tests.rb +57 -57
- data/test/common/multi_line_string_tests.rb +43 -43
- data/test/common/multi_point_tests.rb +43 -43
- data/test/common/multi_polygon_tests.rb +43 -43
- data/test/common/point_tests.rb +75 -75
- data/test/common/polygon_tests.rb +37 -37
- data/test/coord_sys/tc_active_record_table.rb +25 -25
- data/test/coord_sys/tc_ogc_cs.rb +72 -72
- data/test/coord_sys/tc_proj4.rb +51 -51
- data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
- data/test/coord_sys/tc_sr_org.rb +15 -15
- data/test/coord_sys/tc_url_reader.rb +19 -19
- data/test/geos_capi/tc_factory.rb +21 -21
- data/test/geos_capi/tc_geometry_collection.rb +15 -15
- data/test/geos_capi/tc_line_string.rb +15 -15
- data/test/geos_capi/tc_misc.rb +33 -22
- data/test/geos_capi/tc_multi_line_string.rb +15 -15
- data/test/geos_capi/tc_multi_point.rb +15 -15
- data/test/geos_capi/tc_multi_polygon.rb +15 -15
- data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_capi/tc_point.rb +21 -21
- data/test/geos_capi/tc_polygon.rb +19 -19
- data/test/geos_capi/tc_zmfactory.rb +17 -17
- data/test/geos_ffi/tc_factory.rb +21 -21
- data/test/geos_ffi/tc_geometry_collection.rb +15 -15
- data/test/geos_ffi/tc_line_string.rb +15 -15
- data/test/geos_ffi/tc_misc.rb +49 -15
- data/test/geos_ffi/tc_multi_line_string.rb +15 -15
- data/test/geos_ffi/tc_multi_point.rb +15 -15
- data/test/geos_ffi/tc_multi_polygon.rb +15 -15
- data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_ffi/tc_point.rb +21 -21
- data/test/geos_ffi/tc_polygon.rb +19 -19
- data/test/geos_ffi/tc_zmfactory.rb +17 -17
- data/test/projected_geographic/tc_geometry_collection.rb +15 -15
- data/test/projected_geographic/tc_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_point.rb +15 -15
- data/test/projected_geographic/tc_multi_polygon.rb +15 -15
- data/test/projected_geographic/tc_point.rb +23 -23
- data/test/projected_geographic/tc_polygon.rb +15 -15
- data/test/simple_cartesian/tc_calculations.rb +31 -31
- data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
- data/test/simple_cartesian/tc_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_point.rb +17 -17
- data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
- data/test/simple_cartesian/tc_point.rb +21 -21
- data/test/simple_cartesian/tc_polygon.rb +17 -17
- data/test/simple_mercator/tc_geometry_collection.rb +15 -15
- data/test/simple_mercator/tc_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_point.rb +15 -15
- data/test/simple_mercator/tc_multi_polygon.rb +15 -15
- data/test/simple_mercator/tc_point.rb +23 -23
- data/test/simple_mercator/tc_polygon.rb +15 -15
- data/test/simple_mercator/tc_window.rb +50 -50
- data/test/spherical_geographic/tc_calculations.rb +47 -47
- data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
- data/test/spherical_geographic/tc_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_point.rb +17 -17
- data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
- data/test/spherical_geographic/tc_point.rb +23 -23
- data/test/spherical_geographic/tc_polygon.rb +17 -17
- data/test/tc_cartesian_analysis.rb +23 -23
- data/test/tc_mixins.rb +39 -39
- data/test/tc_oneoff.rb +15 -15
- data/test/tc_types.rb +17 -17
- data/test/wkrep/tc_wkb_generator.rb +67 -67
- data/test/wkrep/tc_wkb_parser.rb +73 -73
- data/test/wkrep/tc_wkt_generator.rb +75 -75
- data/test/wkrep/tc_wkt_parser.rb +97 -97
- metadata +3 -3
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for OGC CS classes
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -43,7 +43,7 @@ module RGeo
|
|
43
43
|
module Tests # :nodoc:
|
44
44
|
module CoordSys # :nodoc:
|
45
45
|
module ActiveRecordTableTests # :nodoc:
|
46
|
-
|
46
|
+
|
47
47
|
database_configs_ = ::YAML.load_file(::File.dirname(__FILE__)+'/database.yml') rescue nil
|
48
48
|
if database_configs_
|
49
49
|
begin
|
@@ -52,50 +52,50 @@ module RGeo
|
|
52
52
|
database_configs_ = nil
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
if database_configs_
|
57
|
-
|
57
|
+
|
58
58
|
PostGIS_CONFIG = database_configs_['postgis'] rescue nil
|
59
|
-
|
60
|
-
|
59
|
+
|
60
|
+
|
61
61
|
if PostGIS_CONFIG
|
62
|
-
|
62
|
+
|
63
63
|
class TestPostGIS < ::Test::Unit::TestCase # :nodoc:
|
64
|
-
|
64
|
+
|
65
65
|
class ARBase < ::ActiveRecord::Base
|
66
66
|
establish_connection(PostGIS_CONFIG)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
@@db = ::RGeo::CoordSys::SRSDatabase::ActiveRecordTable.new(:ar_base_class => ARBase, :auth_name_column => 'auth_name', :auth_srid_column => 'auth_srid', :srtext_column => 'srtext', :proj4text_column => 'proj4text')
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
|
72
72
|
def test_4326
|
73
73
|
entry_ = @@db.get(4326)
|
74
74
|
assert_equal('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', entry_.proj4.original_str)
|
75
75
|
assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
|
76
76
|
assert_equal('WGS 84', entry_.name)
|
77
77
|
end
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
def test_3785
|
81
81
|
entry_ = @@db.get(3785)
|
82
82
|
assert_equal('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +units=m +k=1.0 +nadgrids=@null +no_defs', entry_.proj4.original_str)
|
83
83
|
assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
|
84
84
|
assert_equal('Popular Visualisation CRS / Mercator (deprecated)', entry_.name)
|
85
85
|
end
|
86
|
-
|
87
|
-
|
86
|
+
|
87
|
+
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
else
|
91
91
|
puts "WARNING: No postgis section in database.yml; skipping PostGIS tests."
|
92
92
|
end
|
93
|
-
|
94
|
-
|
93
|
+
|
94
|
+
|
95
95
|
else
|
96
96
|
puts "WARNING: Couldn't find database.yml or ActiveRecord gem is not present; skipping ActiveRecord tests."
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
data/test/coord_sys/tc_ogc_cs.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for OGC CS classes
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,12 +41,12 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
43
|
module CoordSys # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestOgcCs < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
# Handle differences in floating-point output.
|
49
|
-
|
49
|
+
|
50
50
|
def _lenient_regex_for(str_)
|
51
51
|
::Regexp.new(str_.gsub(/(\d)\.(\d{10,})/) do |m_|
|
52
52
|
before_ = $1
|
@@ -54,16 +54,16 @@ module RGeo
|
|
54
54
|
"#{before_}.#{after_}\\d*"
|
55
55
|
end.gsub(/(\.|\[|\]|\(|\)|\$|\^|\||\+)/){ |m_| "\\#{$1}"})
|
56
56
|
end
|
57
|
-
|
58
|
-
|
57
|
+
|
58
|
+
|
59
59
|
def test_axis_info_by_value
|
60
60
|
obj_ = ::RGeo::CoordSys::CS::AxisInfo.create('N', ::RGeo::CoordSys::CS::AO_NORTH)
|
61
61
|
assert_equal('N', obj_.name)
|
62
62
|
assert_equal(::RGeo::CoordSys::CS::AO_NORTH, obj_.orientation)
|
63
63
|
assert_equal('AXIS["N",NORTH]', obj_.to_wkt)
|
64
64
|
end
|
65
|
-
|
66
|
-
|
65
|
+
|
66
|
+
|
67
67
|
def test_axis_info_by_name
|
68
68
|
obj_ = ::RGeo::CoordSys::CS::AxisInfo.create('S', 'SOUTH')
|
69
69
|
assert_equal('S', obj_.name)
|
@@ -72,16 +72,16 @@ module RGeo
|
|
72
72
|
obj2_ = ::RGeo::CoordSys::CS::AxisInfo.create('S', ::RGeo::CoordSys::CS::AO_SOUTH)
|
73
73
|
assert_equal(obj_, obj2_)
|
74
74
|
end
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
|
77
77
|
def test_parameter
|
78
78
|
obj_ = ::RGeo::CoordSys::CS::ProjectionParameter.create('false_easting', 400000)
|
79
79
|
assert_equal('false_easting', obj_.name)
|
80
80
|
assert_equal(400000, obj_.value)
|
81
81
|
assert_equal('PARAMETER["false_easting",400000.0]', obj_.to_wkt)
|
82
82
|
end
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
|
85
85
|
def test_towgs84
|
86
86
|
obj_ = ::RGeo::CoordSys::CS::WGS84ConversionInfo.create(1, 2, 3, 4, 5, 6, 7)
|
87
87
|
assert_equal(1, obj_.dx)
|
@@ -93,8 +93,8 @@ module RGeo
|
|
93
93
|
assert_equal(7, obj_.ppm)
|
94
94
|
assert_equal('TOWGS84[1.0,2.0,3.0,4.0,5.0,6.0,7.0]', obj_.to_wkt)
|
95
95
|
end
|
96
|
-
|
97
|
-
|
96
|
+
|
97
|
+
|
98
98
|
def test_unit
|
99
99
|
obj_ = ::RGeo::CoordSys::CS::Unit.create('metre', 1)
|
100
100
|
assert_equal('metre', obj_.name)
|
@@ -102,8 +102,8 @@ module RGeo
|
|
102
102
|
assert_nil(obj_.authority)
|
103
103
|
assert_equal('UNIT["metre",1.0]', obj_.to_wkt)
|
104
104
|
end
|
105
|
-
|
106
|
-
|
105
|
+
|
106
|
+
|
107
107
|
def test_unit_with_authority
|
108
108
|
obj_ = ::RGeo::CoordSys::CS::Unit.create('metre', 1, 'EPSG', 9001)
|
109
109
|
assert_equal('metre', obj_.name)
|
@@ -112,22 +112,22 @@ module RGeo
|
|
112
112
|
assert_equal('9001', obj_.authority_code)
|
113
113
|
assert_equal('UNIT["metre",1.0,AUTHORITY["EPSG","9001"]]', obj_.to_wkt)
|
114
114
|
end
|
115
|
-
|
116
|
-
|
115
|
+
|
116
|
+
|
117
117
|
def test_linear_unit
|
118
118
|
obj_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1)
|
119
119
|
assert_equal(1, obj_.meters_per_unit)
|
120
120
|
assert_equal('UNIT["metre",1.0]', obj_.to_wkt)
|
121
121
|
end
|
122
|
-
|
123
|
-
|
122
|
+
|
123
|
+
|
124
124
|
def test_angular_unit
|
125
125
|
obj_ = ::RGeo::CoordSys::CS::AngularUnit.create('radian', 1)
|
126
126
|
assert_equal(1, obj_.radians_per_unit)
|
127
127
|
assert_equal('UNIT["radian",1.0]', obj_.to_wkt)
|
128
128
|
end
|
129
|
-
|
130
|
-
|
129
|
+
|
130
|
+
|
131
131
|
def test_prime_meridian
|
132
132
|
obj1_ = ::RGeo::CoordSys::CS::AngularUnit.create('radian', 1)
|
133
133
|
obj_ = ::RGeo::CoordSys::CS::PrimeMeridian.create('Greenwich', obj1_, 0, 'EPSG', '8901')
|
@@ -135,8 +135,8 @@ module RGeo
|
|
135
135
|
assert_equal(0, obj_.longitude)
|
136
136
|
assert_equal('PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]]', obj_.to_wkt)
|
137
137
|
end
|
138
|
-
|
139
|
-
|
138
|
+
|
139
|
+
|
140
140
|
def test_create_flattened_sphere
|
141
141
|
obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1)
|
142
142
|
obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere('WGS 84', 6378137, 298.257223563, obj1_, 'EPSG', '7030')
|
@@ -148,8 +148,8 @@ module RGeo
|
|
148
148
|
assert_equal('7030', obj_.authority_code)
|
149
149
|
assert_equal('SPHEROID["WGS 84",6378137.0,298.257223563,AUTHORITY["EPSG","7030"]]', obj_.to_wkt)
|
150
150
|
end
|
151
|
-
|
152
|
-
|
151
|
+
|
152
|
+
|
153
153
|
def test_create_unflattened_sphere
|
154
154
|
obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1)
|
155
155
|
obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere('Popular Visualisation Sphere', 6378137, 0, obj1_, 'EPSG', '7059')
|
@@ -161,30 +161,30 @@ module RGeo
|
|
161
161
|
assert_equal('7059', obj_.authority_code)
|
162
162
|
assert_equal('SPHEROID["Popular Visualisation Sphere",6378137.0,0.0,AUTHORITY["EPSG","7059"]]', obj_.to_wkt)
|
163
163
|
end
|
164
|
-
|
165
|
-
|
164
|
+
|
165
|
+
|
166
166
|
def test_create_ellipsoid
|
167
167
|
obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1)
|
168
168
|
obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_ellipsoid('WGS 84', 6378137, 6356752.314245, obj1_, 'EPSG', '7030')
|
169
169
|
assert_in_delta(298.257223563, obj_.inverse_flattening, 0.1)
|
170
170
|
end
|
171
|
-
|
172
|
-
|
171
|
+
|
172
|
+
|
173
173
|
def test_create_spherical_ellipsoid
|
174
174
|
obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1)
|
175
175
|
obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_ellipsoid('Popular Visualisation Sphere', 6378137, 6378137, obj1_, 'EPSG', '7059')
|
176
176
|
assert_equal(0, obj_.inverse_flattening)
|
177
177
|
end
|
178
|
-
|
179
|
-
|
178
|
+
|
179
|
+
|
180
180
|
def test_local_datum
|
181
181
|
obj_ = ::RGeo::CoordSys::CS::LocalDatum.create('Random Local Datum', ::RGeo::CoordSys::CS::LD_MIN)
|
182
182
|
assert_equal('Random Local Datum', obj_.name)
|
183
183
|
assert_equal(::RGeo::CoordSys::CS::LD_MIN, obj_.datum_type)
|
184
184
|
assert_equal('LOCAL_DATUM["Random Local Datum",10000]', obj_.to_wkt)
|
185
185
|
end
|
186
|
-
|
187
|
-
|
186
|
+
|
187
|
+
|
188
188
|
def test_vertical_datum
|
189
189
|
obj_ = ::RGeo::CoordSys::CS::VerticalDatum.create('Ordnance Datum Newlyn', ::RGeo::CoordSys::CS::VD_GEOID_MODE_DERIVED, 'EPSG', '5101')
|
190
190
|
assert_equal('Ordnance Datum Newlyn', obj_.name)
|
@@ -193,8 +193,8 @@ module RGeo
|
|
193
193
|
assert_equal('5101', obj_.authority_code)
|
194
194
|
assert_equal('VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]]', obj_.to_wkt)
|
195
195
|
end
|
196
|
-
|
197
|
-
|
196
|
+
|
197
|
+
|
198
198
|
def test_horizontal_datum
|
199
199
|
obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1)
|
200
200
|
obj2_ = ::RGeo::CoordSys::CS::Ellipsoid.create_ellipsoid('Popular Visualisation Sphere', 6378137, 6378137, obj1_, 'EPSG', '7059')
|
@@ -206,8 +206,8 @@ module RGeo
|
|
206
206
|
assert_equal('6055', obj_.authority_code)
|
207
207
|
assert_equal('DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137.0,0.0,AUTHORITY["EPSG","7059"]],TOWGS84[0.0,0.0,0.0,0.0,0.0,0.0,0.0],AUTHORITY["EPSG","6055"]]', obj_.to_wkt)
|
208
208
|
end
|
209
|
-
|
210
|
-
|
209
|
+
|
210
|
+
|
211
211
|
def test_projection
|
212
212
|
obj_ = ::RGeo::CoordSys::CS::Projection.create('Transverse_Mercator', 'Transverse_Mercator', [])
|
213
213
|
assert_equal('Transverse_Mercator', obj_.name)
|
@@ -215,8 +215,8 @@ module RGeo
|
|
215
215
|
assert_equal(0, obj_.num_parameters)
|
216
216
|
assert_equal('PROJECTION["Transverse_Mercator"]', obj_.to_wkt)
|
217
217
|
end
|
218
|
-
|
219
|
-
|
218
|
+
|
219
|
+
|
220
220
|
def test_local_coordinate_system
|
221
221
|
obj1_ = ::RGeo::CoordSys::CS::LocalDatum.create('Random Local Datum', ::RGeo::CoordSys::CS::LD_MIN)
|
222
222
|
obj2_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1, 'EPSG', 9001)
|
@@ -232,8 +232,8 @@ module RGeo
|
|
232
232
|
assert_equal('metre', obj_.get_units(1).name)
|
233
233
|
assert_equal('LOCAL_CS["My CS",LOCAL_DATUM["Random Local Datum",10000],UNIT["metre",1.0,AUTHORITY["EPSG","9001"]],AXIS["N",NORTH],AXIS["E",EAST]]', obj_.to_wkt)
|
234
234
|
end
|
235
|
-
|
236
|
-
|
235
|
+
|
236
|
+
|
237
237
|
def test_geocentric_coordinate_system
|
238
238
|
obj1_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere('WGS 84', 6378137, 298.257223563, nil, 'EPSG', '7030')
|
239
239
|
obj2_ = ::RGeo::CoordSys::CS::HorizontalDatum.create('World Geodetic System 1984', ::RGeo::CoordSys::CS::HD_GEOCENTRIC, obj1_, nil, 'EPSG', '6326')
|
@@ -256,8 +256,8 @@ module RGeo
|
|
256
256
|
assert_equal('m', obj_.get_units(2).name)
|
257
257
|
assert_equal('GEOCCS["WGS 84 (geocentric)",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137.0,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["m",1.0],AXIS["Geocentric X",OTHER],AXIS["Geocentric Y",EAST],AXIS["Geocentric Z",NORTH],AUTHORITY["EPSG","4328"]]', obj_.to_wkt)
|
258
258
|
end
|
259
|
-
|
260
|
-
|
259
|
+
|
260
|
+
|
261
261
|
def test_vertical_coordinate_system
|
262
262
|
obj1_ = ::RGeo::CoordSys::CS::VerticalDatum.create('Ordnance Datum Newlyn', ::RGeo::CoordSys::CS::VD_GEOID_MODE_DERIVED, 'EPSG', 5101)
|
263
263
|
obj2_ = ::RGeo::CoordSys::CS::LinearUnit.create('metre', 1, 'EPSG', 9001)
|
@@ -271,8 +271,8 @@ module RGeo
|
|
271
271
|
assert_equal('metre', obj_.get_units(0).name)
|
272
272
|
assert_equal('VERT_CS["Newlyn",VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]],UNIT["metre",1.0,AUTHORITY["EPSG","9001"]],AXIS["Up",UP],AUTHORITY["EPSG","5701"]]', obj_.to_wkt)
|
273
273
|
end
|
274
|
-
|
275
|
-
|
274
|
+
|
275
|
+
|
276
276
|
def test_geographic_coordinate_system
|
277
277
|
obj1_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere('WGS 84', 6378137, 298.257223563, nil, 'EPSG', '7030')
|
278
278
|
obj2_ = ::RGeo::CoordSys::CS::AngularUnit.create('degree', 0.01745329251994328, 'EPSG', 9122)
|
@@ -290,8 +290,8 @@ module RGeo
|
|
290
290
|
assert_equal('degree', obj_.get_units(1).name)
|
291
291
|
assert_match(_lenient_regex_for('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137.0,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'), obj_.to_wkt)
|
292
292
|
end
|
293
|
-
|
294
|
-
|
293
|
+
|
294
|
+
|
295
295
|
def test_projected_coordinate_system
|
296
296
|
obj1_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere('Airy 1830', 6377563.396, 299.3249646, nil, 'EPSG', '7001')
|
297
297
|
obj2_ = ::RGeo::CoordSys::CS::WGS84ConversionInfo.create(375, -111, 431, 0, 0, 0, 0)
|
@@ -328,8 +328,8 @@ module RGeo
|
|
328
328
|
assert_equal('metre', obj_.get_units(1).name)
|
329
329
|
assert_equal('PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB_1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[375.0,-111.0,431.0,0.0,0.0,0.0,0.0],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["DMSH",0.0174532925199433,AUTHORITY["EPSG","9108"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49.0],PARAMETER["central_meridian",-2.0],PARAMETER["scale_factor",0.999601272],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],UNIT["metre",1.0,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","27700"]]', obj_.to_wkt)
|
330
330
|
end
|
331
|
-
|
332
|
-
|
331
|
+
|
332
|
+
|
333
333
|
def test_parse_epsg_6055
|
334
334
|
input_ = 'DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137.0,0.0,AUTHORITY["EPSG","7059"]],TOWGS84[0.0,0.0,0.0,0.0,0.0,0.0,0.0],AUTHORITY["EPSG","6055"]]'
|
335
335
|
obj_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
|
@@ -347,8 +347,8 @@ module RGeo
|
|
347
347
|
assert_equal(0, obj_.wgs84_parameters.dx)
|
348
348
|
assert_equal(input_, obj_.to_wkt)
|
349
349
|
end
|
350
|
-
|
351
|
-
|
350
|
+
|
351
|
+
|
352
352
|
def test_parse_epsg_7405
|
353
353
|
input_ = 'COMPD_CS["OSGB36 / British National Grid + ODN",PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.842,-4.2261596151967575],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943295],AXIS["Geodetic latitude",NORTH],AXIS["Geodetic longitude",EAST],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["central_meridian",-2.0],PARAMETER["latitude_of_origin",49.0],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],UNIT["m",1.0],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","27700"]],VERT_CS["Newlyn",VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]],UNIT["m",1.0],AXIS["Gravity-related height",UP],AUTHORITY["EPSG","5701"]],AUTHORITY["EPSG","7405"]]'
|
354
354
|
obj_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
|
@@ -358,8 +358,8 @@ module RGeo
|
|
358
358
|
assert_equal(3, obj_.dimension)
|
359
359
|
assert_match(_lenient_regex_for(input_), obj_.to_wkt)
|
360
360
|
end
|
361
|
-
|
362
|
-
|
361
|
+
|
362
|
+
|
363
363
|
def test_marshal_roundtrip
|
364
364
|
input_ = 'COMPD_CS["OSGB36 / British National Grid + ODN",PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.842,-4.2261596151967575],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943295],AXIS["Geodetic latitude",NORTH],AXIS["Geodetic longitude",EAST],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["central_meridian",-2.0],PARAMETER["latitude_of_origin",49.0],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],UNIT["m",1.0],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","27700"]],VERT_CS["Newlyn",VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]],UNIT["m",1.0],AXIS["Gravity-related height",UP],AUTHORITY["EPSG","5701"]],AUTHORITY["EPSG","7405"]]'
|
365
365
|
obj1_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
|
@@ -367,11 +367,11 @@ module RGeo
|
|
367
367
|
obj2_ = ::Marshal.load(dump_)
|
368
368
|
assert_equal(obj1_, obj2_)
|
369
369
|
end
|
370
|
-
|
371
|
-
|
370
|
+
|
371
|
+
|
372
372
|
if ::RGeo.yaml_supported?
|
373
|
-
|
374
|
-
|
373
|
+
|
374
|
+
|
375
375
|
def test_yaml_roundtrip
|
376
376
|
input_ = 'COMPD_CS["OSGB36 / British National Grid + ODN",PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.842,-4.2261596151967575],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943295],AXIS["Geodetic latitude",NORTH],AXIS["Geodetic longitude",EAST],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["central_meridian",-2.0],PARAMETER["latitude_of_origin",49.0],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],UNIT["m",1.0],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","27700"]],VERT_CS["Newlyn",VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]],UNIT["m",1.0],AXIS["Gravity-related height",UP],AUTHORITY["EPSG","5701"]],AUTHORITY["EPSG","7405"]]'
|
377
377
|
obj1_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
|
@@ -379,17 +379,17 @@ module RGeo
|
|
379
379
|
obj2_ = ::Psych.load(dump_)
|
380
380
|
assert_equal(obj1_, obj2_)
|
381
381
|
end
|
382
|
-
|
383
|
-
|
382
|
+
|
383
|
+
|
384
384
|
else
|
385
|
-
|
385
|
+
|
386
386
|
puts "WARNING: Psych not installed. Skipping YAML tests."
|
387
|
-
|
387
|
+
|
388
388
|
end
|
389
|
-
|
390
|
-
|
389
|
+
|
390
|
+
|
391
391
|
end
|
392
|
-
|
392
|
+
|
393
393
|
end
|
394
394
|
end
|
395
395
|
end
|
data/test/coord_sys/tc_proj4.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for proj4 wrapper
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,18 +41,18 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
43
|
module CoordSys # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestProj4 < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def test_create_wgs84
|
49
49
|
proj_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
50
50
|
assert_equal(true, proj_.geographic?)
|
51
51
|
assert_equal('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', proj_.original_str)
|
52
52
|
assert_equal(' +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0', proj_.canonical_str)
|
53
53
|
end
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
|
56
56
|
def test_get_wgs84_geographic
|
57
57
|
proj_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
58
58
|
proj2_ = proj_.get_geographic
|
@@ -61,36 +61,36 @@ module RGeo
|
|
61
61
|
coords_ = ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj2_, 1, 2, 0)
|
62
62
|
assert_equal([1, 2, 0], coords_)
|
63
63
|
end
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
|
66
66
|
def test_identity_transform
|
67
67
|
proj_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
68
68
|
assert_equal([1, 2, 0], ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, 0))
|
69
69
|
assert_equal([1, 2], ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, nil))
|
70
70
|
end
|
71
|
-
|
72
|
-
|
71
|
+
|
72
|
+
|
73
73
|
def _project_merc(x_, y_)
|
74
74
|
[x_ * 6378137.0, ::Math.log(::Math.tan(::Math::PI / 4.0 + y_ / 2.0)) * 6378137.0]
|
75
75
|
end
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
|
78
78
|
def _unproject_merc(x_, y_)
|
79
79
|
[x_ / 6378137.0, (2.0 * ::Math.atan(::Math.exp(y_ / 6378137.0)) - ::Math::PI / 2.0)]
|
80
80
|
end
|
81
|
-
|
82
|
-
|
81
|
+
|
82
|
+
|
83
83
|
def _assert_close_enough(a_, b_)
|
84
84
|
assert_in_delta(a_, b_, ::Math.sqrt(a_*a_+b_*b_)*0.00000001)
|
85
85
|
end
|
86
|
-
|
87
|
-
|
86
|
+
|
87
|
+
|
88
88
|
def _assert_xy_close(xy1_, xy2_)
|
89
89
|
_assert_close_enough(xy1_[0], xy2_[0])
|
90
90
|
_assert_close_enough(xy1_[1], xy2_[1])
|
91
91
|
end
|
92
|
-
|
93
|
-
|
92
|
+
|
93
|
+
|
94
94
|
def test_simple_mercator_transform
|
95
95
|
geography_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', :radians => true)
|
96
96
|
projection_ = ::RGeo::CoordSys::Proj4.create('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs')
|
@@ -102,15 +102,15 @@ module RGeo
|
|
102
102
|
_assert_xy_close(_unproject_merc(10000, 10000), ::RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, 10000, 10000, nil))
|
103
103
|
_assert_xy_close(_unproject_merc(-20000000, -20000000), ::RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, -20000000, -20000000, nil))
|
104
104
|
end
|
105
|
-
|
106
|
-
|
105
|
+
|
106
|
+
|
107
107
|
def test_equivalence
|
108
108
|
proj1_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
109
109
|
proj2_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
110
110
|
assert_equal(proj1_, proj2_)
|
111
111
|
end
|
112
|
-
|
113
|
-
|
112
|
+
|
113
|
+
|
114
114
|
def test_point_projection_cast
|
115
115
|
geography_ = ::RGeo::Geos.factory(:proj4 => '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', :srid =>4326)
|
116
116
|
projection_ = ::RGeo::Geos.factory(:proj4 => '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs', :srid => 27700)
|
@@ -119,8 +119,8 @@ module RGeo
|
|
119
119
|
_assert_close_enough(-0.9393598527244420, geo_point_.x)
|
120
120
|
_assert_close_enough(51.5740106527552697, geo_point_.y)
|
121
121
|
end
|
122
|
-
|
123
|
-
|
122
|
+
|
123
|
+
|
124
124
|
def test_point_transform_lowlevel
|
125
125
|
geography_ = ::RGeo::Geos.factory(:proj4 => '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', :srid =>4326)
|
126
126
|
projection_ = ::RGeo::Geos.factory(:proj4 => '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs', :srid => 27700)
|
@@ -129,65 +129,65 @@ module RGeo
|
|
129
129
|
_assert_close_enough(-0.9393598527244420, geo_point_.x)
|
130
130
|
_assert_close_enough(51.5740106527552697, geo_point_.y)
|
131
131
|
end
|
132
|
-
|
133
|
-
|
132
|
+
|
133
|
+
|
134
134
|
def test_geocentric
|
135
135
|
obj1_ = ::RGeo::CoordSys::Proj4.create('+proj=geocent +ellps=WGS84')
|
136
136
|
assert_equal(true, obj1_.geocentric?)
|
137
137
|
end
|
138
|
-
|
139
|
-
|
138
|
+
|
139
|
+
|
140
140
|
def test_get_geographic
|
141
141
|
projection_ = ::RGeo::CoordSys::Proj4.create('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs')
|
142
142
|
geographic_ = projection_.get_geographic
|
143
143
|
expected_ = ::RGeo::CoordSys::Proj4.create('+proj=latlong +a=6378137 +b=6378137 +nadgrids=@null')
|
144
144
|
assert_equal(expected_, geographic_)
|
145
145
|
end
|
146
|
-
|
147
|
-
|
146
|
+
|
147
|
+
|
148
148
|
def test_marshal_roundtrip
|
149
149
|
obj1_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
150
150
|
dump_ = ::Marshal.dump(obj1_)
|
151
151
|
obj2_ = ::Marshal.load(dump_)
|
152
152
|
assert_equal(obj1_, obj2_)
|
153
153
|
end
|
154
|
-
|
155
|
-
|
154
|
+
|
155
|
+
|
156
156
|
def test_dup
|
157
157
|
obj1_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
158
158
|
obj2_ = obj1_.dup
|
159
159
|
assert_equal(obj1_, obj2_)
|
160
160
|
end
|
161
|
-
|
162
|
-
|
161
|
+
|
162
|
+
|
163
163
|
def test_dup_of_get_geographic
|
164
164
|
obj1_ = ::RGeo::CoordSys::Proj4.create('+proj=latlong +datum=WGS84 +ellps=WGS84')
|
165
165
|
obj2_ = obj1_.get_geographic
|
166
166
|
obj3_ = obj2_.dup
|
167
167
|
assert_equal(obj1_, obj3_)
|
168
168
|
end
|
169
|
-
|
170
|
-
|
169
|
+
|
170
|
+
|
171
171
|
if ::RGeo.yaml_supported?
|
172
|
-
|
173
|
-
|
172
|
+
|
173
|
+
|
174
174
|
def test_yaml_roundtrip
|
175
175
|
obj1_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
176
176
|
dump_ = ::Psych.dump(obj1_)
|
177
177
|
obj2_ = ::Psych.load(dump_)
|
178
178
|
assert_equal(obj1_, obj2_)
|
179
179
|
end
|
180
|
-
|
181
|
-
|
180
|
+
|
181
|
+
|
182
182
|
else
|
183
|
-
|
183
|
+
|
184
184
|
puts "WARNING: Psych not installed. Skipping YAML tests."
|
185
|
-
|
185
|
+
|
186
186
|
end
|
187
|
-
|
188
|
-
|
187
|
+
|
188
|
+
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end if ::RGeo::CoordSys::Proj4.supported?
|