rgeo 0.5.3 → 0.6.0

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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/ext/geos_c_impl/extconf.rb +1 -0
  3. data/ext/geos_c_impl/factory.c +10 -1
  4. data/ext/geos_c_impl/geometry.c +25 -3
  5. data/ext/geos_c_impl/line_string.c +1 -12
  6. data/ext/geos_c_impl/polygon.c +0 -3
  7. data/ext/geos_c_impl/preface.h +3 -0
  8. data/lib/rgeo.rb +0 -1
  9. data/lib/rgeo/feature/geometry.rb +17 -0
  10. data/lib/rgeo/feature/types.rb +4 -4
  11. data/lib/rgeo/geographic/projected_feature_methods.rb +1 -22
  12. data/lib/rgeo/geos/ffi_feature_methods.rb +5 -0
  13. data/lib/rgeo/geos/utils.rb +2 -0
  14. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -0
  15. data/lib/rgeo/version.rb +1 -1
  16. metadata +11 -171
  17. data/lib/rgeo/yaml.rb +0 -23
  18. data/test/cartesian_analysis_test.rb +0 -65
  19. data/test/cartesian_bbox_test.rb +0 -123
  20. data/test/common/factory_tests.rb +0 -78
  21. data/test/common/geometry_collection_tests.rb +0 -237
  22. data/test/common/line_string_tests.rb +0 -330
  23. data/test/common/multi_line_string_tests.rb +0 -182
  24. data/test/common/multi_point_tests.rb +0 -200
  25. data/test/common/multi_polygon_tests.rb +0 -191
  26. data/test/common/point_tests.rb +0 -370
  27. data/test/common/polygon_tests.rb +0 -228
  28. data/test/coord_sys/ogc_cs_test.rb +0 -342
  29. data/test/coord_sys/proj4_srs_data_test.rb +0 -41
  30. data/test/coord_sys/proj4_test.rb +0 -150
  31. data/test/coord_sys/sr_org_test.rb +0 -32
  32. data/test/coord_sys/url_reader_test.rb +0 -42
  33. data/test/geos_capi/factory_test.rb +0 -31
  34. data/test/geos_capi/geometry_collection_test.rb +0 -24
  35. data/test/geos_capi/line_string_test.rb +0 -24
  36. data/test/geos_capi/misc_test.rb +0 -116
  37. data/test/geos_capi/multi_line_string_test.rb +0 -24
  38. data/test/geos_capi/multi_point_test.rb +0 -24
  39. data/test/geos_capi/multi_polygon_test.rb +0 -39
  40. data/test/geos_capi/parsing_unparsing_test.rb +0 -40
  41. data/test/geos_capi/point_test.rb +0 -72
  42. data/test/geos_capi/polygon_test.rb +0 -154
  43. data/test/geos_capi/zmfactory_test.rb +0 -57
  44. data/test/geos_ffi/factory_test.rb +0 -31
  45. data/test/geos_ffi/geometry_collection_test.rb +0 -24
  46. data/test/geos_ffi/line_string_test.rb +0 -24
  47. data/test/geos_ffi/misc_test.rb +0 -63
  48. data/test/geos_ffi/multi_line_string_test.rb +0 -24
  49. data/test/geos_ffi/multi_point_test.rb +0 -24
  50. data/test/geos_ffi/multi_polygon_test.rb +0 -33
  51. data/test/geos_ffi/parsing_unparsing_test.rb +0 -41
  52. data/test/geos_ffi/point_test.rb +0 -77
  53. data/test/geos_ffi/polygon_test.rb +0 -46
  54. data/test/geos_ffi/zmfactory_test.rb +0 -58
  55. data/test/mixins_test.rb +0 -141
  56. data/test/oneoff_test.rb +0 -26
  57. data/test/projected_geographic/factory_test.rb +0 -25
  58. data/test/projected_geographic/geometry_collection_test.rb +0 -24
  59. data/test/projected_geographic/line_string_test.rb +0 -24
  60. data/test/projected_geographic/multi_line_string_test.rb +0 -26
  61. data/test/projected_geographic/multi_point_test.rb +0 -30
  62. data/test/projected_geographic/multi_polygon_test.rb +0 -25
  63. data/test/projected_geographic/point_test.rb +0 -51
  64. data/test/projected_geographic/polygon_test.rb +0 -24
  65. data/test/simple_cartesian/calculations_test.rb +0 -99
  66. data/test/simple_cartesian/factory_test.rb +0 -27
  67. data/test/simple_cartesian/geometry_collection_test.rb +0 -30
  68. data/test/simple_cartesian/line_string_test.rb +0 -31
  69. data/test/simple_cartesian/multi_line_string_test.rb +0 -28
  70. data/test/simple_cartesian/multi_point_test.rb +0 -31
  71. data/test/simple_cartesian/multi_polygon_test.rb +0 -31
  72. data/test/simple_cartesian/point_test.rb +0 -50
  73. data/test/simple_cartesian/polygon_test.rb +0 -28
  74. data/test/simple_mercator/factory_test.rb +0 -25
  75. data/test/simple_mercator/geometry_collection_test.rb +0 -24
  76. data/test/simple_mercator/line_string_test.rb +0 -24
  77. data/test/simple_mercator/multi_line_string_test.rb +0 -26
  78. data/test/simple_mercator/multi_point_test.rb +0 -29
  79. data/test/simple_mercator/multi_polygon_test.rb +0 -25
  80. data/test/simple_mercator/point_test.rb +0 -55
  81. data/test/simple_mercator/polygon_test.rb +0 -24
  82. data/test/simple_mercator/window_test.rb +0 -173
  83. data/test/spherical_geographic/calculations_test.rb +0 -167
  84. data/test/spherical_geographic/factory_test.rb +0 -27
  85. data/test/spherical_geographic/geometry_collection_test.rb +0 -31
  86. data/test/spherical_geographic/line_string_test.rb +0 -31
  87. data/test/spherical_geographic/multi_line_string_test.rb +0 -29
  88. data/test/spherical_geographic/multi_point_test.rb +0 -31
  89. data/test/spherical_geographic/multi_polygon_test.rb +0 -31
  90. data/test/spherical_geographic/point_test.rb +0 -78
  91. data/test/spherical_geographic/polygon_test.rb +0 -28
  92. data/test/types_test.rb +0 -42
  93. data/test/wkrep/wkb_generator_test.rb +0 -185
  94. data/test/wkrep/wkb_parser_test.rb +0 -293
  95. data/test/wkrep/wkt_generator_test.rb +0 -294
  96. data/test/wkrep/wkt_parser_test.rb +0 -412
@@ -1,228 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Common tests for polygon implementations
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "rgeo"
8
-
9
- module RGeo
10
- module Tests # :nodoc:
11
- module Common # :nodoc:
12
- module PolygonTests # :nodoc:
13
- def test_creation_simple
14
- point1_ = @factory.point(0, 0)
15
- point2_ = @factory.point(0, 1)
16
- point3_ = @factory.point(1, 0)
17
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
18
- polygon_ = @factory.polygon(exterior_)
19
- assert_not_nil(polygon_)
20
- assert(::RGeo::Feature::Polygon === polygon_)
21
- assert_equal(::RGeo::Feature::Polygon, polygon_.geometry_type)
22
- assert(exterior_.eql?(polygon_.exterior_ring))
23
- assert_equal(0, polygon_.num_interior_rings)
24
- assert_nil(polygon_.interior_ring_n(0))
25
- assert_nil(polygon_.interior_ring_n(-1))
26
- end
27
-
28
- def test_creation_one_hole
29
- point1_ = @factory.point(0, 0)
30
- point2_ = @factory.point(0, 10)
31
- point3_ = @factory.point(10, 10)
32
- point4_ = @factory.point(10, 0)
33
- point5_ = @factory.point(4, 4)
34
- point6_ = @factory.point(5, 6)
35
- point7_ = @factory.point(6, 4)
36
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point4_, point1_])
37
- interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
38
- polygon_ = @factory.polygon(exterior_, [interior_])
39
- assert_not_nil(polygon_)
40
- assert(::RGeo::Feature::Polygon === polygon_)
41
- assert_equal(::RGeo::Feature::Polygon, polygon_.geometry_type)
42
- assert(exterior_.eql?(polygon_.exterior_ring))
43
- assert_equal(1, polygon_.num_interior_rings)
44
- assert(interior_.eql?(polygon_.interior_ring_n(0)))
45
- assert_nil(polygon_.interior_ring_n(1))
46
- assert_nil(polygon_.interior_ring_n(-1))
47
- end
48
-
49
- def test_required_equivalences
50
- point1_ = @factory.point(0, 0)
51
- point2_ = @factory.point(0, 1)
52
- point3_ = @factory.point(1, 0)
53
- exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
54
- poly1_ = @factory.polygon(exterior1_)
55
- point4_ = @factory.point(0, 0)
56
- point5_ = @factory.point(0, 1)
57
- point6_ = @factory.point(1, 0)
58
- exterior2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
59
- poly2_ = @factory.polygon(exterior2_)
60
- assert(poly1_.eql?(poly2_))
61
- assert(poly1_ == poly2_)
62
- end
63
-
64
- def test_fully_equal
65
- point1_ = @factory.point(0, 0)
66
- point2_ = @factory.point(0, 1)
67
- point3_ = @factory.point(1, 0)
68
- exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
69
- poly1_ = @factory.polygon(exterior1_)
70
- point4_ = @factory.point(0, 0)
71
- point5_ = @factory.point(0, 1)
72
- point6_ = @factory.point(1, 0)
73
- exterior2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
74
- poly2_ = @factory.polygon(exterior2_)
75
- assert(poly1_.rep_equals?(poly2_))
76
- assert(poly1_.equals?(poly2_))
77
- end
78
-
79
- def test_geometrically_equal_but_ordered_different
80
- point1_ = @factory.point(0, 0)
81
- point2_ = @factory.point(0, 1)
82
- point3_ = @factory.point(1, 0)
83
- exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
84
- poly1_ = @factory.polygon(exterior1_)
85
- exterior2_ = @factory.linear_ring([point2_, point3_, point1_, point2_])
86
- poly2_ = @factory.polygon(exterior2_)
87
- assert(!poly1_.rep_equals?(poly2_))
88
- assert(poly1_.equals?(poly2_))
89
- end
90
-
91
- def test_geometrically_equal_but_different_directions
92
- point1_ = @factory.point(0, 0)
93
- point2_ = @factory.point(0, 1)
94
- point3_ = @factory.point(1, 0)
95
- exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
96
- poly1_ = @factory.polygon(exterior1_)
97
- exterior2_ = @factory.linear_ring([point1_, point3_, point2_, point1_])
98
- poly2_ = @factory.polygon(exterior2_)
99
- assert(!poly1_.rep_equals?(poly2_))
100
- assert(poly1_.equals?(poly2_))
101
- end
102
-
103
- def test_hashes_equal_for_representationally_equivalent_objects
104
- point1_ = @factory.point(0, 0)
105
- point2_ = @factory.point(0, 1)
106
- point3_ = @factory.point(1, 0)
107
- exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
108
- poly1_ = @factory.polygon(exterior1_)
109
- point4_ = @factory.point(0, 0)
110
- point5_ = @factory.point(0, 1)
111
- point6_ = @factory.point(1, 0)
112
- exterior2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
113
- poly2_ = @factory.polygon(exterior2_)
114
- assert_equal(poly1_.hash, poly2_.hash)
115
- end
116
-
117
- def test_wkt_creation_simple
118
- parsed_poly_ = @factory.parse_wkt("POLYGON((0 0, 0 1, 1 0, 0 0))")
119
- point1_ = @factory.point(0, 0)
120
- point2_ = @factory.point(0, 1)
121
- point3_ = @factory.point(1, 0)
122
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
123
- built_poly_ = @factory.polygon(exterior_)
124
- assert(built_poly_.eql?(parsed_poly_))
125
- end
126
-
127
- def test_wkt_creation_one_hole
128
- parsed_poly_ = @factory.parse_wkt("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0), (4 4, 5 6, 6 4, 4 4))")
129
- point1_ = @factory.point(0, 0)
130
- point2_ = @factory.point(0, 10)
131
- point3_ = @factory.point(10, 10)
132
- point4_ = @factory.point(10, 0)
133
- point5_ = @factory.point(4, 4)
134
- point6_ = @factory.point(5, 6)
135
- point7_ = @factory.point(6, 4)
136
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point4_, point1_])
137
- interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
138
- built_poly_ = @factory.polygon(exterior_, [interior_])
139
- assert(built_poly_.eql?(parsed_poly_))
140
- end
141
-
142
- def test_clone
143
- point1_ = @factory.point(0, 0)
144
- point2_ = @factory.point(0, 1)
145
- point3_ = @factory.point(1, 0)
146
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
147
- poly1_ = @factory.polygon(exterior_)
148
- poly2_ = poly1_.clone
149
- assert(poly1_.eql?(poly2_))
150
- assert(exterior_.eql?(poly2_.exterior_ring))
151
- assert_equal(0, poly2_.num_interior_rings)
152
- end
153
-
154
- def test_type_check
155
- point1_ = @factory.point(0, 0)
156
- point2_ = @factory.point(0, 1)
157
- point3_ = @factory.point(1, 0)
158
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
159
- poly_ = @factory.polygon(exterior_)
160
- assert(::RGeo::Feature::Geometry.check_type(poly_))
161
- assert(!::RGeo::Feature::Point.check_type(poly_))
162
- assert(!::RGeo::Feature::GeometryCollection.check_type(poly_))
163
- assert(::RGeo::Feature::Surface.check_type(poly_))
164
- assert(::RGeo::Feature::Polygon.check_type(poly_))
165
- end
166
-
167
- def test_as_text_wkt_round_trip
168
- point1_ = @factory.point(0, 0)
169
- point2_ = @factory.point(0, 1)
170
- point3_ = @factory.point(1, 0)
171
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
172
- poly1_ = @factory.polygon(exterior_)
173
- text_ = poly1_.as_text
174
- poly2_ = @factory.parse_wkt(text_)
175
- assert(poly1_.eql?(poly2_))
176
- end
177
-
178
- def test_as_binary_wkb_round_trip
179
- point1_ = @factory.point(0, 0)
180
- point2_ = @factory.point(0, 1)
181
- point3_ = @factory.point(1, 0)
182
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
183
- poly1_ = @factory.polygon(exterior_)
184
- binary_ = poly1_.as_binary
185
- poly2_ = @factory.parse_wkb(binary_)
186
- assert(poly1_.eql?(poly2_))
187
- end
188
-
189
- def test_dimension
190
- point1_ = @factory.point(0, 0)
191
- point2_ = @factory.point(0, 10)
192
- point3_ = @factory.point(10, 10)
193
- point4_ = @factory.point(10, 0)
194
- point5_ = @factory.point(4, 4)
195
- point6_ = @factory.point(5, 6)
196
- point7_ = @factory.point(6, 4)
197
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point4_, point1_])
198
- interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
199
- poly_ = @factory.polygon(exterior_, [interior_])
200
- assert_equal(2, poly_.dimension)
201
- end
202
-
203
- def test_is_empty
204
- point1_ = @factory.point(0, 0)
205
- point2_ = @factory.point(0, 1)
206
- point3_ = @factory.point(1, 0)
207
- exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
208
- poly1_ = @factory.polygon(exterior_)
209
- assert(!poly1_.is_empty?)
210
- poly2_ = @factory.polygon(@factory.linear_ring([]))
211
- assert(poly2_.is_empty?)
212
- end
213
-
214
- def test_polygon_coordinates
215
- coordinates = [
216
- [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]],
217
- [[0.25, 0.25], [0.75, 0.25], [0.75, 0.75], [0.25, 0.75], [0.25, 0.25]]
218
- ]
219
-
220
- ring = @factory.line_string(coordinates.first.map { |(x, y)| @factory.point x, y })
221
- inner_ring = @factory.line_string(coordinates.last.map { |(x, y)| @factory.point x, y })
222
- polygon = @factory.polygon ring, [inner_ring]
223
- assert_equal(polygon.coordinates, coordinates)
224
- end
225
- end
226
- end
227
- end
228
- end
@@ -1,342 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Tests for OGC CS classes
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "test/unit"
8
- require "rgeo"
9
-
10
- module RGeo
11
- module Tests # :nodoc:
12
- module CoordSys # :nodoc:
13
- class TestOgcCs < ::Test::Unit::TestCase # :nodoc:
14
- # Handle differences in floating-point output.
15
-
16
- def _lenient_regex_for(str_)
17
- ::Regexp.new(str_.gsub(/(\d)\.(\d{10,})/) do |_m_|
18
- before_ = Regexp.last_match(1)
19
- after_ = Regexp.last_match(2)[0, 10]
20
- "#{before_}.#{after_}\\d*"
21
- end.gsub(/(\.|\[|\]|\(|\)|\$|\^|\||\+)/) { |_m_| "\\#{Regexp.last_match(1)}" })
22
- end
23
-
24
- def test_axis_info_by_value
25
- obj_ = ::RGeo::CoordSys::CS::AxisInfo.create("N", ::RGeo::CoordSys::CS::AO_NORTH)
26
- assert_equal("N", obj_.name)
27
- assert_equal(::RGeo::CoordSys::CS::AO_NORTH, obj_.orientation)
28
- assert_equal('AXIS["N",NORTH]', obj_.to_wkt)
29
- end
30
-
31
- def test_axis_info_by_name
32
- obj_ = ::RGeo::CoordSys::CS::AxisInfo.create("S", "SOUTH")
33
- assert_equal("S", obj_.name)
34
- assert_equal(::RGeo::CoordSys::CS::AO_SOUTH, obj_.orientation)
35
- assert_equal('AXIS["S",SOUTH]', obj_.to_wkt)
36
- obj2_ = ::RGeo::CoordSys::CS::AxisInfo.create("S", ::RGeo::CoordSys::CS::AO_SOUTH)
37
- assert_equal(obj_, obj2_)
38
- end
39
-
40
- def test_parameter
41
- obj_ = ::RGeo::CoordSys::CS::ProjectionParameter.create("false_easting", 400_000)
42
- assert_equal("false_easting", obj_.name)
43
- assert_equal(400_000, obj_.value)
44
- assert_equal('PARAMETER["false_easting",400000.0]', obj_.to_wkt)
45
- end
46
-
47
- def test_towgs84
48
- obj_ = ::RGeo::CoordSys::CS::WGS84ConversionInfo.create(1, 2, 3, 4, 5, 6, 7)
49
- assert_equal(1, obj_.dx)
50
- assert_equal(2, obj_.dy)
51
- assert_equal(3, obj_.dz)
52
- assert_equal(4, obj_.ex)
53
- assert_equal(5, obj_.ey)
54
- assert_equal(6, obj_.ez)
55
- assert_equal(7, obj_.ppm)
56
- assert_equal("TOWGS84[1.0,2.0,3.0,4.0,5.0,6.0,7.0]", obj_.to_wkt)
57
- end
58
-
59
- def test_unit
60
- obj_ = ::RGeo::CoordSys::CS::Unit.create("metre", 1)
61
- assert_equal("metre", obj_.name)
62
- assert_equal(1, obj_.conversion_factor)
63
- assert_nil(obj_.authority)
64
- assert_equal('UNIT["metre",1.0]', obj_.to_wkt)
65
- end
66
-
67
- def test_unit_with_authority
68
- obj_ = ::RGeo::CoordSys::CS::Unit.create("metre", 1, "EPSG", 9001)
69
- assert_equal("metre", obj_.name)
70
- assert_equal(1, obj_.conversion_factor)
71
- assert_equal("EPSG", obj_.authority)
72
- assert_equal("9001", obj_.authority_code)
73
- assert_equal('UNIT["metre",1.0,AUTHORITY["EPSG","9001"]]', obj_.to_wkt)
74
- end
75
-
76
- def test_linear_unit
77
- obj_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1)
78
- assert_equal(1, obj_.meters_per_unit)
79
- assert_equal('UNIT["metre",1.0]', obj_.to_wkt)
80
- end
81
-
82
- def test_angular_unit
83
- obj_ = ::RGeo::CoordSys::CS::AngularUnit.create("radian", 1)
84
- assert_equal(1, obj_.radians_per_unit)
85
- assert_equal('UNIT["radian",1.0]', obj_.to_wkt)
86
- end
87
-
88
- def test_prime_meridian
89
- obj1_ = ::RGeo::CoordSys::CS::AngularUnit.create("radian", 1)
90
- obj_ = ::RGeo::CoordSys::CS::PrimeMeridian.create("Greenwich", obj1_, 0, "EPSG", "8901")
91
- assert_equal("Greenwich", obj_.name)
92
- assert_equal(0, obj_.longitude)
93
- assert_equal('PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]]', obj_.to_wkt)
94
- end
95
-
96
- def test_create_flattened_sphere
97
- obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1)
98
- obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere("WGS 84", 6_378_137, 298.257223563, obj1_, "EPSG", "7030")
99
- assert_equal("WGS 84", obj_.name)
100
- assert_equal(6_378_137, obj_.semi_major_axis)
101
- assert_in_delta(298.257223563, obj_.inverse_flattening, 0.1)
102
- assert_in_delta(6_356_752.314245, obj_.semi_minor_axis, 0.1)
103
- assert_equal("EPSG", obj_.authority)
104
- assert_equal("7030", obj_.authority_code)
105
- assert_equal('SPHEROID["WGS 84",6378137.0,298.257223563,AUTHORITY["EPSG","7030"]]', obj_.to_wkt)
106
- end
107
-
108
- def test_create_unflattened_sphere
109
- obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1)
110
- obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere("Popular Visualisation Sphere", 6_378_137, 0, obj1_, "EPSG", "7059")
111
- assert_equal("Popular Visualisation Sphere", obj_.name)
112
- assert_equal(6_378_137, obj_.semi_major_axis)
113
- assert_equal(0, obj_.inverse_flattening)
114
- assert_equal(6_378_137, obj_.semi_minor_axis)
115
- assert_equal("EPSG", obj_.authority)
116
- assert_equal("7059", obj_.authority_code)
117
- assert_equal('SPHEROID["Popular Visualisation Sphere",6378137.0,0.0,AUTHORITY["EPSG","7059"]]', obj_.to_wkt)
118
- end
119
-
120
- def test_create_ellipsoid
121
- obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1)
122
- obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_ellipsoid("WGS 84", 6_378_137, 6_356_752.314245, obj1_, "EPSG", "7030")
123
- assert_in_delta(298.257223563, obj_.inverse_flattening, 0.1)
124
- end
125
-
126
- def test_create_spherical_ellipsoid
127
- obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1)
128
- obj_ = ::RGeo::CoordSys::CS::Ellipsoid.create_ellipsoid("Popular Visualisation Sphere", 6_378_137, 6_378_137, obj1_, "EPSG", "7059")
129
- assert_equal(0, obj_.inverse_flattening)
130
- end
131
-
132
- def test_local_datum
133
- obj_ = ::RGeo::CoordSys::CS::LocalDatum.create("Random Local Datum", ::RGeo::CoordSys::CS::LD_MIN)
134
- assert_equal("Random Local Datum", obj_.name)
135
- assert_equal(::RGeo::CoordSys::CS::LD_MIN, obj_.datum_type)
136
- assert_equal('LOCAL_DATUM["Random Local Datum",10000]', obj_.to_wkt)
137
- end
138
-
139
- def test_local_datum_with_extension
140
- obj_ = ::RGeo::CoordSys::CS::LocalDatum.create("Random Local Datum", ::RGeo::CoordSys::CS::LD_MIN, nil, nil, nil, nil, nil, foo: :bar)
141
- assert_equal("bar", obj_.extension(:foo))
142
- assert_nil(obj_.extension(:bar))
143
- assert_equal('LOCAL_DATUM["Random Local Datum",10000,EXTENSION["foo","bar"]]', obj_.to_wkt)
144
- end
145
-
146
- def test_vertical_datum
147
- obj_ = ::RGeo::CoordSys::CS::VerticalDatum.create("Ordnance Datum Newlyn", ::RGeo::CoordSys::CS::VD_GEOID_MODE_DERIVED, "EPSG", "5101")
148
- assert_equal("Ordnance Datum Newlyn", obj_.name)
149
- assert_equal(::RGeo::CoordSys::CS::VD_GEOID_MODE_DERIVED, obj_.datum_type)
150
- assert_equal("EPSG", obj_.authority)
151
- assert_equal("5101", obj_.authority_code)
152
- assert_equal('VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]]', obj_.to_wkt)
153
- end
154
-
155
- def test_horizontal_datum
156
- obj1_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1)
157
- obj2_ = ::RGeo::CoordSys::CS::Ellipsoid.create_ellipsoid("Popular Visualisation Sphere", 6_378_137, 6_378_137, obj1_, "EPSG", "7059")
158
- obj3_ = ::RGeo::CoordSys::CS::WGS84ConversionInfo.create(0, 0, 0, 0, 0, 0, 0)
159
- obj_ = ::RGeo::CoordSys::CS::HorizontalDatum.create("Popular_Visualisation_Datum", ::RGeo::CoordSys::CS::HD_GEOCENTRIC, obj2_, obj3_, "EPSG", "6055")
160
- assert_equal("Popular_Visualisation_Datum", obj_.name)
161
- assert_equal(::RGeo::CoordSys::CS::HD_GEOCENTRIC, obj_.datum_type)
162
- assert_equal("EPSG", obj_.authority)
163
- assert_equal("6055", obj_.authority_code)
164
- 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)
165
- end
166
-
167
- def test_projection
168
- obj_ = ::RGeo::CoordSys::CS::Projection.create("Transverse_Mercator", "Transverse_Mercator", [])
169
- assert_equal("Transverse_Mercator", obj_.name)
170
- assert_equal("Transverse_Mercator", obj_.class_name)
171
- assert_equal(0, obj_.num_parameters)
172
- assert_equal('PROJECTION["Transverse_Mercator"]', obj_.to_wkt)
173
- end
174
-
175
- def test_local_coordinate_system
176
- obj1_ = ::RGeo::CoordSys::CS::LocalDatum.create("Random Local Datum", ::RGeo::CoordSys::CS::LD_MIN)
177
- obj2_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1, "EPSG", 9001)
178
- obj3_ = ::RGeo::CoordSys::CS::AxisInfo.create("N", ::RGeo::CoordSys::CS::AO_NORTH)
179
- obj4_ = ::RGeo::CoordSys::CS::AxisInfo.create("E", ::RGeo::CoordSys::CS::AO_EAST)
180
- obj_ = ::RGeo::CoordSys::CS::LocalCoordinateSystem.create("My CS", obj1_, obj2_, [obj3_, obj4_])
181
- assert_equal("My CS", obj_.name)
182
- assert_equal(2, obj_.dimension)
183
- assert_equal("Random Local Datum", obj_.local_datum.name)
184
- assert_equal("N", obj_.get_axis(0).name)
185
- assert_equal("E", obj_.get_axis(1).name)
186
- assert_equal("metre", obj_.get_units(0).name)
187
- assert_equal("metre", obj_.get_units(1).name)
188
- 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)
189
- end
190
-
191
- def test_geocentric_coordinate_system
192
- obj1_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere("WGS 84", 6_378_137, 298.257223563, nil, "EPSG", "7030")
193
- obj2_ = ::RGeo::CoordSys::CS::HorizontalDatum.create("World Geodetic System 1984", ::RGeo::CoordSys::CS::HD_GEOCENTRIC, obj1_, nil, "EPSG", "6326")
194
- obj3_ = ::RGeo::CoordSys::CS::PrimeMeridian.create("Greenwich", nil, 0.0, "EPSG", "8901")
195
- obj4_ = ::RGeo::CoordSys::CS::LinearUnit.create("m", 1.0)
196
- obj5_ = ::RGeo::CoordSys::CS::AxisInfo.create("Geocentric X", ::RGeo::CoordSys::CS::AO_OTHER)
197
- obj6_ = ::RGeo::CoordSys::CS::AxisInfo.create("Geocentric Y", ::RGeo::CoordSys::CS::AO_EAST)
198
- obj7_ = ::RGeo::CoordSys::CS::AxisInfo.create("Geocentric Z", ::RGeo::CoordSys::CS::AO_NORTH)
199
- obj_ = ::RGeo::CoordSys::CS::GeocentricCoordinateSystem.create("WGS 84 (geocentric)", obj2_, obj3_, obj4_, obj5_, obj6_, obj7_, "EPSG", 4328)
200
- assert_equal("WGS 84 (geocentric)", obj_.name)
201
- assert_equal(3, obj_.dimension)
202
- assert_equal("World Geodetic System 1984", obj_.horizontal_datum.name)
203
- assert_equal("Greenwich", obj_.prime_meridian.name)
204
- assert_equal("m", obj_.linear_unit.name)
205
- assert_equal("Geocentric X", obj_.get_axis(0).name)
206
- assert_equal("Geocentric Y", obj_.get_axis(1).name)
207
- assert_equal("Geocentric Z", obj_.get_axis(2).name)
208
- assert_equal("m", obj_.get_units(0).name)
209
- assert_equal("m", obj_.get_units(1).name)
210
- assert_equal("m", obj_.get_units(2).name)
211
- 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)
212
- end
213
-
214
- def test_vertical_coordinate_system
215
- obj1_ = ::RGeo::CoordSys::CS::VerticalDatum.create("Ordnance Datum Newlyn", ::RGeo::CoordSys::CS::VD_GEOID_MODE_DERIVED, "EPSG", 5101)
216
- obj2_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1, "EPSG", 9001)
217
- obj3_ = ::RGeo::CoordSys::CS::AxisInfo.create("Up", ::RGeo::CoordSys::CS::AO_UP)
218
- obj_ = ::RGeo::CoordSys::CS::VerticalCoordinateSystem.create("Newlyn", obj1_, obj2_, obj3_, "EPSG", 5701)
219
- assert_equal("Newlyn", obj_.name)
220
- assert_equal(1, obj_.dimension)
221
- assert_equal("Ordnance Datum Newlyn", obj_.vertical_datum.name)
222
- assert_equal("metre", obj_.vertical_unit.name)
223
- assert_equal("Up", obj_.get_axis(0).name)
224
- assert_equal("metre", obj_.get_units(0).name)
225
- 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)
226
- end
227
-
228
- def test_geographic_coordinate_system
229
- obj1_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere("WGS 84", 6_378_137, 298.257223563, nil, "EPSG", "7030")
230
- obj2_ = ::RGeo::CoordSys::CS::AngularUnit.create("degree", 0.01745329251994328, "EPSG", 9122)
231
- obj3_ = ::RGeo::CoordSys::CS::HorizontalDatum.create("WGS_1984", ::RGeo::CoordSys::CS::HD_GEOCENTRIC, obj1_, nil, "EPSG", "6326")
232
- obj4_ = ::RGeo::CoordSys::CS::PrimeMeridian.create("Greenwich", nil, 0, "EPSG", "8901")
233
- obj_ = ::RGeo::CoordSys::CS::GeographicCoordinateSystem.create("WGS 84", obj2_, obj3_, obj4_, nil, nil, "EPSG", 4326)
234
- assert_equal("WGS 84", obj_.name)
235
- assert_equal(2, obj_.dimension)
236
- assert_equal("WGS_1984", obj_.horizontal_datum.name)
237
- assert_equal("Greenwich", obj_.prime_meridian.name)
238
- assert_equal("degree", obj_.angular_unit.name)
239
- assert_nil(obj_.get_axis(0))
240
- assert_nil(obj_.get_axis(1))
241
- assert_equal("degree", obj_.get_units(0).name)
242
- assert_equal("degree", obj_.get_units(1).name)
243
- 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)
244
- end
245
-
246
- def test_projected_coordinate_system
247
- obj1_ = ::RGeo::CoordSys::CS::Ellipsoid.create_flattened_sphere("Airy 1830", 6_377_563.396, 299.3249646, nil, "EPSG", "7001")
248
- obj2_ = ::RGeo::CoordSys::CS::WGS84ConversionInfo.create(375, -111, 431, 0, 0, 0, 0)
249
- obj3_ = ::RGeo::CoordSys::CS::AngularUnit.create("DMSH", 0.0174532925199433, "EPSG", 9108)
250
- obj4_ = ::RGeo::CoordSys::CS::HorizontalDatum.create("OSGB_1936", ::RGeo::CoordSys::CS::HD_CLASSIC, obj1_, obj2_, "EPSG", "6277")
251
- obj5_ = ::RGeo::CoordSys::CS::PrimeMeridian.create("Greenwich", nil, 0, "EPSG", "8901")
252
- obj6_ = ::RGeo::CoordSys::CS::AxisInfo.create("Lat", ::RGeo::CoordSys::CS::AO_NORTH)
253
- obj7_ = ::RGeo::CoordSys::CS::AxisInfo.create("Long", ::RGeo::CoordSys::CS::AO_EAST)
254
- obj8_ = ::RGeo::CoordSys::CS::GeographicCoordinateSystem.create("OSGB 1936", obj3_, obj4_, obj5_, obj6_, obj7_, "EPSG", 4277)
255
- obj9_ = ::RGeo::CoordSys::CS::ProjectionParameter.create("latitude_of_origin", 49)
256
- obj10_ = ::RGeo::CoordSys::CS::ProjectionParameter.create("central_meridian", -2)
257
- obj11_ = ::RGeo::CoordSys::CS::ProjectionParameter.create("scale_factor", 0.999601272)
258
- obj12_ = ::RGeo::CoordSys::CS::ProjectionParameter.create("false_easting", 400_000)
259
- obj13_ = ::RGeo::CoordSys::CS::ProjectionParameter.create("false_northing", -100_000)
260
- obj14_ = ::RGeo::CoordSys::CS::Projection.create("Transverse_Mercator", "Transverse_Mercator", [obj9_, obj10_, obj11_, obj12_, obj13_])
261
- obj15_ = ::RGeo::CoordSys::CS::LinearUnit.create("metre", 1, "EPSG", 9001)
262
- obj16_ = ::RGeo::CoordSys::CS::AxisInfo.create("E", ::RGeo::CoordSys::CS::AO_EAST)
263
- obj17_ = ::RGeo::CoordSys::CS::AxisInfo.create("N", ::RGeo::CoordSys::CS::AO_NORTH)
264
- obj_ = ::RGeo::CoordSys::CS::ProjectedCoordinateSystem.create("OSGB 1936 / British National Grid", obj8_, obj14_, obj15_, obj16_, obj17_, "EPSG", 27_700)
265
- assert_equal("OSGB 1936 / British National Grid", obj_.name)
266
- assert_equal(2, obj_.dimension)
267
- assert_equal("OSGB_1936", obj_.horizontal_datum.name)
268
- assert_equal("OSGB 1936", obj_.geographic_coordinate_system.name)
269
- assert_equal("Transverse_Mercator", obj_.projection.name)
270
- assert_equal(5, obj_.projection.num_parameters)
271
- assert_equal("latitude_of_origin", obj_.projection.get_parameter(0).name)
272
- assert_equal(49, obj_.projection.get_parameter(0).value)
273
- assert_equal("false_northing", obj_.projection.get_parameter(4).name)
274
- assert_equal(-100_000, obj_.projection.get_parameter(4).value)
275
- assert_equal("metre", obj_.linear_unit.name)
276
- assert_equal("E", obj_.get_axis(0).name)
277
- assert_equal("N", obj_.get_axis(1).name)
278
- assert_equal("metre", obj_.get_units(0).name)
279
- assert_equal("metre", obj_.get_units(1).name)
280
- 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)
281
- end
282
-
283
- def test_parse_epsg_6055
284
- 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"]]'
285
- obj_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
286
- assert_kind_of(::RGeo::CoordSys::CS::HorizontalDatum, obj_)
287
- assert_equal("Popular_Visualisation_Datum", obj_.name)
288
- assert_equal(::RGeo::CoordSys::CS::HD_GEOCENTRIC, obj_.datum_type)
289
- assert_equal("EPSG", obj_.authority)
290
- assert_equal("6055", obj_.authority_code)
291
- assert_equal("Popular Visualisation Sphere", obj_.ellipsoid.name)
292
- assert_equal(6_378_137, obj_.ellipsoid.semi_major_axis)
293
- assert_equal(0, obj_.ellipsoid.inverse_flattening)
294
- assert_equal(6_378_137, obj_.ellipsoid.semi_minor_axis)
295
- assert_equal("EPSG", obj_.ellipsoid.authority)
296
- assert_equal("7059", obj_.ellipsoid.authority_code)
297
- assert_equal(0, obj_.wgs84_parameters.dx)
298
- assert_equal(input_, obj_.to_wkt)
299
- end
300
-
301
- def test_parse_epsg_7405
302
- 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"]]'
303
- obj_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
304
- assert_kind_of(::RGeo::CoordSys::CS::CompoundCoordinateSystem, obj_)
305
- assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, obj_.head)
306
- assert_kind_of(::RGeo::CoordSys::CS::VerticalCoordinateSystem, obj_.tail)
307
- assert_equal(3, obj_.dimension)
308
- assert_match(_lenient_regex_for(input_), obj_.to_wkt)
309
- end
310
-
311
- def test_parse_local_datum_with_extension
312
- input_ = 'LOCAL_DATUM["Random Local Datum",10000,EXTENSION["foo","bar"]]'
313
- obj_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
314
- assert_kind_of(::RGeo::CoordSys::CS::LocalDatum, obj_)
315
- assert_equal("bar", obj_.extension(:foo))
316
- assert_nil(obj_.extension(:bar))
317
- assert_equal(input_, obj_.to_wkt)
318
- end
319
-
320
- def test_marshal_roundtrip
321
- 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"]]'
322
- obj1_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
323
- dump_ = ::Marshal.dump(obj1_)
324
- obj2_ = ::Marshal.load(dump_)
325
- assert_equal(obj1_, obj2_)
326
- end
327
-
328
- if ::RGeo.yaml_supported?
329
-
330
- def test_yaml_roundtrip
331
- 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"]]'
332
- obj1_ = ::RGeo::CoordSys::CS.create_from_wkt(input_)
333
- dump_ = ::Psych.dump(obj1_)
334
- obj2_ = ::Psych.load(dump_)
335
- assert_equal(obj1_, obj2_)
336
- end
337
-
338
- end
339
- end
340
- end
341
- end
342
- end