rgeo 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +29 -0
  3. data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
  4. data/ext/geos_c_impl/coordinates.c +65 -0
  5. data/ext/geos_c_impl/coordinates.h +2 -0
  6. data/ext/geos_c_impl/extconf.rb +19 -43
  7. data/ext/geos_c_impl/geometry.c +24 -0
  8. data/ext/geos_c_impl/geometry_collection.c +99 -1
  9. data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
  10. data/ext/geos_c_impl/line_string.c +38 -0
  11. data/ext/geos_c_impl/mkmf.log +123 -0
  12. data/ext/geos_c_impl/point.c +27 -0
  13. data/ext/geos_c_impl/polygon.c +26 -0
  14. data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
  15. data/ext/proj4_c_impl/extconf.rb +32 -32
  16. data/ext/proj4_c_impl/mkmf.log +47 -0
  17. data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
  18. data/lib/rgeo.rb +10 -11
  19. data/lib/rgeo/cartesian.rb +7 -12
  20. data/lib/rgeo/cartesian/analysis.rb +13 -26
  21. data/lib/rgeo/cartesian/bounding_box.rb +45 -114
  22. data/lib/rgeo/cartesian/calculations.rb +3 -21
  23. data/lib/rgeo/cartesian/factory.rb +101 -122
  24. data/lib/rgeo/cartesian/feature_classes.rb +9 -59
  25. data/lib/rgeo/cartesian/feature_methods.rb +15 -45
  26. data/lib/rgeo/cartesian/interface.rb +6 -17
  27. data/lib/rgeo/coord_sys.rb +9 -15
  28. data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
  29. data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
  30. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
  31. data/lib/rgeo/coord_sys/proj4.rb +28 -67
  32. data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
  33. data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
  34. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
  35. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
  36. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
  37. data/lib/rgeo/error.rb +0 -6
  38. data/lib/rgeo/feature.rb +18 -23
  39. data/lib/rgeo/feature/curve.rb +0 -14
  40. data/lib/rgeo/feature/factory.rb +13 -38
  41. data/lib/rgeo/feature/factory_generator.rb +4 -16
  42. data/lib/rgeo/feature/geometry.rb +18 -60
  43. data/lib/rgeo/feature/geometry_collection.rb +3 -17
  44. data/lib/rgeo/feature/line.rb +0 -10
  45. data/lib/rgeo/feature/line_string.rb +1 -13
  46. data/lib/rgeo/feature/linear_ring.rb +0 -9
  47. data/lib/rgeo/feature/mixins.rb +11 -36
  48. data/lib/rgeo/feature/multi_curve.rb +0 -11
  49. data/lib/rgeo/feature/multi_line_string.rb +0 -9
  50. data/lib/rgeo/feature/multi_point.rb +0 -9
  51. data/lib/rgeo/feature/multi_polygon.rb +0 -9
  52. data/lib/rgeo/feature/multi_surface.rb +0 -12
  53. data/lib/rgeo/feature/point.rb +0 -13
  54. data/lib/rgeo/feature/polygon.rb +1 -14
  55. data/lib/rgeo/feature/surface.rb +0 -12
  56. data/lib/rgeo/feature/types.rb +19 -61
  57. data/lib/rgeo/geographic.rb +10 -15
  58. data/lib/rgeo/geographic/factory.rb +126 -147
  59. data/lib/rgeo/geographic/interface.rb +67 -81
  60. data/lib/rgeo/geographic/proj4_projector.rb +13 -37
  61. data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
  62. data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
  63. data/lib/rgeo/geographic/projected_window.rb +15 -67
  64. data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
  65. data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
  66. data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
  67. data/lib/rgeo/geographic/spherical_math.rb +26 -51
  68. data/lib/rgeo/geos.rb +23 -20
  69. data/lib/rgeo/geos/capi_factory.rb +125 -131
  70. data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
  71. data/lib/rgeo/geos/ffi_factory.rb +90 -143
  72. data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
  73. data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
  74. data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
  75. data/lib/rgeo/geos/interface.rb +4 -23
  76. data/lib/rgeo/geos/utils.rb +4 -19
  77. data/lib/rgeo/geos/zm_factory.rb +82 -131
  78. data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
  79. data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
  80. data/lib/rgeo/impl_helper.rb +8 -13
  81. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
  82. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
  83. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
  84. data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
  85. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
  86. data/lib/rgeo/impl_helper/math.rb +4 -10
  87. data/lib/rgeo/impl_helper/utils.rb +2 -10
  88. data/lib/rgeo/version.rb +1 -1
  89. data/lib/rgeo/wkrep.rb +4 -9
  90. data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
  91. data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
  92. data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
  93. data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
  94. data/lib/rgeo/yaml.rb +1 -7
  95. data/test/common/factory_tests.rb +4 -19
  96. data/test/common/geometry_collection_tests.rb +6 -39
  97. data/test/common/line_string_tests.rb +10 -39
  98. data/test/common/multi_line_string_tests.rb +10 -30
  99. data/test/common/multi_point_tests.rb +15 -34
  100. data/test/common/multi_polygon_tests.rb +26 -28
  101. data/test/common/point_tests.rb +37 -59
  102. data/test/common/polygon_tests.rb +16 -25
  103. data/test/coord_sys/tc_ogc_cs.rb +151 -186
  104. data/test/coord_sys/tc_proj4.rb +35 -60
  105. data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
  106. data/test/coord_sys/tc_sr_org.rb +11 -19
  107. data/test/coord_sys/tc_url_reader.rb +13 -23
  108. data/test/geos_capi/tc_factory.rb +7 -16
  109. data/test/geos_capi/tc_geometry_collection.rb +6 -14
  110. data/test/geos_capi/tc_line_string.rb +7 -15
  111. data/test/geos_capi/tc_misc.rb +26 -41
  112. data/test/geos_capi/tc_multi_line_string.rb +6 -14
  113. data/test/geos_capi/tc_multi_point.rb +7 -15
  114. data/test/geos_capi/tc_multi_polygon.rb +8 -18
  115. data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
  116. data/test/geos_capi/tc_point.rb +12 -26
  117. data/test/geos_capi/tc_polygon.rb +52 -17
  118. data/test/geos_capi/tc_zmfactory.rb +7 -18
  119. data/test/geos_ffi/tc_factory.rb +7 -16
  120. data/test/geos_ffi/tc_geometry_collection.rb +7 -15
  121. data/test/geos_ffi/tc_line_string.rb +7 -15
  122. data/test/geos_ffi/tc_misc.rb +8 -18
  123. data/test/geos_ffi/tc_multi_line_string.rb +7 -15
  124. data/test/geos_ffi/tc_multi_point.rb +8 -16
  125. data/test/geos_ffi/tc_multi_polygon.rb +9 -18
  126. data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
  127. data/test/geos_ffi/tc_point.rb +13 -28
  128. data/test/geos_ffi/tc_polygon.rb +7 -17
  129. data/test/geos_ffi/tc_zmfactory.rb +8 -19
  130. data/test/projected_geographic/tc_factory.rb +7 -15
  131. data/test/projected_geographic/tc_geometry_collection.rb +7 -15
  132. data/test/projected_geographic/tc_line_string.rb +7 -15
  133. data/test/projected_geographic/tc_multi_line_string.rb +7 -16
  134. data/test/projected_geographic/tc_multi_point.rb +8 -17
  135. data/test/projected_geographic/tc_multi_polygon.rb +8 -16
  136. data/test/projected_geographic/tc_point.rb +11 -23
  137. data/test/projected_geographic/tc_polygon.rb +7 -15
  138. data/test/simple_cartesian/tc_calculations.rb +6 -22
  139. data/test/simple_cartesian/tc_factory.rb +7 -16
  140. data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
  141. data/test/simple_cartesian/tc_line_string.rb +6 -15
  142. data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
  143. data/test/simple_cartesian/tc_multi_point.rb +7 -16
  144. data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
  145. data/test/simple_cartesian/tc_point.rb +10 -21
  146. data/test/simple_cartesian/tc_polygon.rb +6 -15
  147. data/test/simple_mercator/tc_factory.rb +6 -14
  148. data/test/simple_mercator/tc_geometry_collection.rb +6 -14
  149. data/test/simple_mercator/tc_line_string.rb +6 -14
  150. data/test/simple_mercator/tc_multi_line_string.rb +6 -15
  151. data/test/simple_mercator/tc_multi_point.rb +7 -16
  152. data/test/simple_mercator/tc_multi_polygon.rb +7 -15
  153. data/test/simple_mercator/tc_point.rb +11 -24
  154. data/test/simple_mercator/tc_polygon.rb +6 -14
  155. data/test/simple_mercator/tc_window.rb +10 -34
  156. data/test/spherical_geographic/tc_calculations.rb +5 -32
  157. data/test/spherical_geographic/tc_factory.rb +6 -15
  158. data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
  159. data/test/spherical_geographic/tc_line_string.rb +6 -15
  160. data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
  161. data/test/spherical_geographic/tc_multi_point.rb +7 -16
  162. data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
  163. data/test/spherical_geographic/tc_point.rb +10 -22
  164. data/test/spherical_geographic/tc_polygon.rb +6 -15
  165. data/test/tc_cartesian_analysis.rb +4 -16
  166. data/test/tc_cartesian_bbox.rb +7 -21
  167. data/test/tc_mixins.rb +8 -25
  168. data/test/tc_oneoff.rb +5 -13
  169. data/test/tc_types.rb +7 -16
  170. data/test/wkrep/tc_wkb_generator.rb +63 -97
  171. data/test/wkrep/tc_wkb_parser.rb +63 -100
  172. data/test/wkrep/tc_wkt_generator.rb +54 -92
  173. data/test/wkrep/tc_wkt_parser.rb +84 -133
  174. metadata +39 -9
  175. data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
  176. data/test/coord_sys/tc_active_record_table.rb +0 -79
@@ -4,259 +4,230 @@
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- require 'test/unit'
8
- require 'rgeo'
9
-
7
+ require "test/unit"
8
+ require "rgeo"
10
9
 
11
10
  module RGeo
12
- module Tests # :nodoc:
13
- module WKRep # :nodoc:
14
-
15
- class TestWKTParser < ::Test::Unit::TestCase # :nodoc:
16
-
17
-
11
+ module Tests # :nodoc:
12
+ module WKRep # :nodoc:
13
+ class TestWKTParser < ::Test::Unit::TestCase # :nodoc:
18
14
  def test_point_2d
19
15
  parser_ = ::RGeo::WKRep::WKTParser.new
20
- obj_ = parser_.parse('POINT(1 2)')
16
+ obj_ = parser_.parse("POINT(1 2)")
21
17
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
22
18
  assert_equal(1, obj_.x)
23
19
  assert_equal(2, obj_.y)
24
20
  end
25
21
 
26
-
27
22
  def test_values_fractional
28
23
  parser_ = ::RGeo::WKRep::WKTParser.new
29
- obj_ = parser_.parse('POINT(1.000 2.5)')
24
+ obj_ = parser_.parse("POINT(1.000 2.5)")
30
25
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
31
26
  assert_equal(1.0, obj_.x)
32
27
  assert_equal(2.5, obj_.y)
33
28
  end
34
29
 
35
-
36
30
  def test_values_fractional2
37
31
  parser_ = ::RGeo::WKRep::WKTParser.new
38
- obj_ = parser_.parse('POINT(1. .5)')
32
+ obj_ = parser_.parse("POINT(1. .5)")
39
33
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
40
34
  assert_equal(1.0, obj_.x)
41
35
  assert_equal(0.5, obj_.y)
42
36
  end
43
37
 
44
-
45
38
  def test_values_negative
46
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
39
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
47
40
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
48
- obj_ = parser_.parse('POINT(-1. -.5 -5.5)')
41
+ obj_ = parser_.parse("POINT(-1. -.5 -5.5)")
49
42
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
50
43
  assert_equal(-1.0, obj_.x)
51
44
  assert_equal(-0.5, obj_.y)
52
45
  assert_equal(-5.5, obj_.z)
53
46
  end
54
47
 
55
-
56
48
  def test_point_square_brackets
57
49
  parser_ = ::RGeo::WKRep::WKTParser.new
58
- obj_ = parser_.parse('POINT[1 2]')
50
+ obj_ = parser_.parse("POINT[1 2]")
59
51
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
60
52
  assert_equal(1, obj_.x)
61
53
  assert_equal(2, obj_.y)
62
54
  end
63
55
 
64
-
65
56
  def test_point_empty
66
57
  parser_ = ::RGeo::WKRep::WKTParser.new
67
- obj_ = parser_.parse('POINT EMPTY')
58
+ obj_ = parser_.parse("POINT EMPTY")
68
59
  assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
69
60
  assert_equal(0, obj_.num_geometries)
70
61
  end
71
62
 
72
-
73
63
  def test_point_with_z
74
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
64
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
75
65
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
76
- obj_ = parser_.parse('POINT(1 2 3)')
66
+ obj_ = parser_.parse("POINT(1 2 3)")
77
67
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
78
68
  assert_equal(3, obj_.z)
79
69
  assert_nil(obj_.m)
80
70
  end
81
71
 
82
-
83
72
  def test_point_with_m
84
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
73
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
85
74
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
86
- obj_ = parser_.parse('POINT(1 2 3)')
75
+ obj_ = parser_.parse("POINT(1 2 3)")
87
76
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
88
77
  assert_equal(3, obj_.m)
89
78
  assert_nil(obj_.z)
90
79
  end
91
80
 
92
-
93
81
  def test_point_with_too_many_coords
94
82
  factory_ = ::RGeo::Cartesian.preferred_factory
95
83
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
96
84
  assert_raise(::RGeo::Error::ParseError) do
97
- parser_.parse('POINT(1 2 3)')
85
+ parser_.parse("POINT(1 2 3)")
98
86
  end
99
87
  end
100
88
 
101
-
102
89
  def test_point_wkt12_z
103
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
104
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
105
- obj_ = parser_.parse('POINT Z(1 2 3)')
90
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
91
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
92
+ obj_ = parser_.parse("POINT Z(1 2 3)")
106
93
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
107
94
  assert_equal(3, obj_.z)
108
95
  assert_nil(obj_.m)
109
96
  end
110
97
 
111
-
112
98
  def test_point_wkt12_z_unsupported_factory
113
99
  factory_ = ::RGeo::Cartesian.preferred_factory
114
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
100
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
115
101
  assert_raise(::RGeo::Error::ParseError) do
116
- parser_.parse('POINT Z(1 2 3)')
102
+ parser_.parse("POINT Z(1 2 3)")
117
103
  end
118
104
  end
119
105
 
120
-
121
106
  def test_point_wkt12_m
122
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
123
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
124
- obj_ = parser_.parse('POINT M(1 2 3)')
107
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
108
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
109
+ obj_ = parser_.parse("POINT M(1 2 3)")
125
110
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
126
111
  assert_equal(3, obj_.m)
127
112
  assert_nil(obj_.z)
128
113
  end
129
114
 
130
-
131
115
  def test_point_wkt12_m_with_factory_zm
132
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
133
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
134
- obj_ = parser_.parse('POINT M(1 2 3)')
116
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
117
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
118
+ obj_ = parser_.parse("POINT M(1 2 3)")
135
119
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
136
120
  assert_equal(3, obj_.m)
137
121
  assert_equal(0, obj_.z)
138
122
  end
139
123
 
140
-
141
124
  def test_point_wkt12_m_too_many_coords
142
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
143
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
125
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
126
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
144
127
  assert_raise(::RGeo::Error::ParseError) do
145
- parser_.parse('POINT M(1 2 3 4)')
128
+ parser_.parse("POINT M(1 2 3 4)")
146
129
  end
147
130
  end
148
131
 
149
-
150
132
  def test_point_wkt12_zm
151
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
152
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
153
- obj_ = parser_.parse('POINT ZM(1 2 3 4)')
133
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
134
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
135
+ obj_ = parser_.parse("POINT ZM(1 2 3 4)")
154
136
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
155
137
  assert_equal(3, obj_.z)
156
138
  assert_equal(4, obj_.m)
157
139
  end
158
140
 
159
-
160
141
  def test_point_wkt12_zm_not_enough_coords
161
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
162
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
142
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
143
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
163
144
  assert_raise(::RGeo::Error::ParseError) do
164
- parser_.parse('POINT ZM(1 2 3)')
145
+ parser_.parse("POINT ZM(1 2 3)")
165
146
  end
166
147
  end
167
148
 
168
-
169
149
  def test_point_ewkt_z
170
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
171
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
172
- obj_ = parser_.parse('POINT(1 2 3)')
150
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
151
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true)
152
+ obj_ = parser_.parse("POINT(1 2 3)")
173
153
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
174
154
  assert_equal(3, obj_.z)
175
155
  assert_nil(obj_.m)
176
156
  end
177
157
 
178
-
179
158
  def test_point_ewkt_m
180
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
181
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
182
- obj_ = parser_.parse('POINTM(1 2 3)')
159
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
160
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true)
161
+ obj_ = parser_.parse("POINTM(1 2 3)")
183
162
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
184
163
  assert_equal(3, obj_.m)
185
164
  assert_nil(obj_.z)
186
165
  end
187
166
 
188
-
189
167
  def test_point_ewkt_with_srid
190
- parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), :support_ewkt => true)
191
- obj_ = parser_.parse('SRID=1000;POINTM(1 2 3)')
168
+ parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), support_ewkt: true)
169
+ obj_ = parser_.parse("SRID=1000;POINTM(1 2 3)")
192
170
  assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
193
171
  assert_equal(3, obj_.m)
194
172
  assert_nil(obj_.z)
195
173
  assert_equal(1000, obj_.srid)
196
174
  end
197
175
 
198
-
199
176
  def test_point_ewkt_m_too_many_coords
200
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
201
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
177
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
178
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true)
202
179
  assert_raise(::RGeo::Error::ParseError) do
203
- parser_.parse('POINTM(1 2 3 4)')
180
+ parser_.parse("POINTM(1 2 3 4)")
204
181
  end
205
182
  end
206
183
 
207
-
208
184
  def test_point_strict_wkt11_with_z
209
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
210
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :strict_wkt11 => true)
185
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
186
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, strict_wkt11: true)
211
187
  assert_raise(::RGeo::Error::ParseError) do
212
- parser_.parse('POINT(1 2 3)')
188
+ parser_.parse("POINT(1 2 3)")
213
189
  end
214
190
  end
215
191
 
216
-
217
192
  def test_point_non_ewkt_with_srid
218
193
  parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory))
219
194
  assert_raise(::RGeo::Error::ParseError) do
220
- parser_.parse('SRID=1000;POINT(1 2)')
195
+ parser_.parse("SRID=1000;POINT(1 2)")
221
196
  end
222
197
  end
223
198
 
224
-
225
199
  def test_linestring_basic
226
200
  factory_ = ::RGeo::Cartesian.preferred_factory
227
201
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
228
- obj_ = parser_.parse('LINESTRING(1 2, 3 4, 5 6)')
202
+ obj_ = parser_.parse("LINESTRING(1 2, 3 4, 5 6)")
229
203
  assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
230
204
  assert_equal(3, obj_.num_points)
231
205
  assert_equal(1, obj_.point_n(0).x)
232
206
  assert_equal(6, obj_.point_n(2).y)
233
207
  end
234
208
 
235
-
236
209
  def test_linestring_with_z
237
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
210
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
238
211
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
239
- obj_ = parser_.parse('LINESTRING(1 2 3, 4 5 6,7 8 9)')
212
+ obj_ = parser_.parse("LINESTRING(1 2 3, 4 5 6,7 8 9)")
240
213
  assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
241
214
  assert_equal(3, obj_.num_points)
242
215
  assert_equal(1, obj_.point_n(0).x)
243
216
  assert_equal(9, obj_.point_n(2).z)
244
217
  end
245
218
 
246
-
247
219
  def test_linestring_with_inconsistent_coords
248
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
220
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
249
221
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
250
222
  assert_raise(::RGeo::Error::ParseError) do
251
- parser_.parse('LINESTRING(1 2 3, 4 5,7 8 9)')
223
+ parser_.parse("LINESTRING(1 2 3, 4 5,7 8 9)")
252
224
  end
253
225
  end
254
226
 
255
-
256
227
  def test_linestring_wkt12_m
257
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
258
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
259
- obj_ = parser_.parse('LINESTRING M(1 2 3,5 6 7)')
228
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
229
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
230
+ obj_ = parser_.parse("LINESTRING M(1 2 3,5 6 7)")
260
231
  assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
261
232
  assert_equal(2, obj_.num_points)
262
233
  assert_equal(0, obj_.point_n(0).z)
@@ -265,41 +236,37 @@ module RGeo
265
236
  assert_equal(7, obj_.point_n(1).m)
266
237
  end
267
238
 
268
-
269
239
  def test_linestring_ewkt_with_srid
270
- parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), :support_ewkt => true)
271
- obj_ = parser_.parse('SRID=1000;LINESTRINGM(1 2 3, 4 5 6)')
240
+ parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), support_ewkt: true)
241
+ obj_ = parser_.parse("SRID=1000;LINESTRINGM(1 2 3, 4 5 6)")
272
242
  assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
273
243
  assert_equal(3, obj_.point_n(0).m)
274
244
  assert_nil(obj_.point_n(0).z)
275
245
  assert_equal(1000, obj_.srid)
276
246
  end
277
247
 
278
-
279
248
  def test_linestring_empty
280
249
  factory_ = ::RGeo::Cartesian.preferred_factory
281
250
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
282
- obj_ = parser_.parse('LINESTRING EMPTY')
251
+ obj_ = parser_.parse("LINESTRING EMPTY")
283
252
  assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
284
253
  assert_equal(0, obj_.num_points)
285
254
  end
286
255
 
287
-
288
256
  def test_polygon_basic
289
257
  factory_ = ::RGeo::Cartesian.preferred_factory
290
258
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
291
- obj_ = parser_.parse('POLYGON((1 2, 3 4, 5 7, 1 2))')
259
+ obj_ = parser_.parse("POLYGON((1 2, 3 4, 5 7, 1 2))")
292
260
  assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
293
261
  assert_equal(4, obj_.exterior_ring.num_points)
294
262
  assert_equal(1, obj_.exterior_ring.point_n(0).x)
295
263
  assert_equal(7, obj_.exterior_ring.point_n(2).y)
296
264
  end
297
265
 
298
-
299
266
  def test_polygon_with_holes_and_z
300
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
267
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
301
268
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
302
- obj_ = parser_.parse('POLYGON((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9))')
269
+ obj_ = parser_.parse("POLYGON((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9))")
303
270
  assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
304
271
  assert_equal(5, obj_.exterior_ring.num_points)
305
272
  assert_equal(0, obj_.exterior_ring.point_n(0).x)
@@ -309,73 +276,66 @@ module RGeo
309
276
  assert_equal(-7, obj_.interior_ring_n(0).point_n(1).z)
310
277
  end
311
278
 
312
-
313
279
  def test_polygon_empty
314
280
  factory_ = ::RGeo::Cartesian.preferred_factory
315
281
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
316
- obj_ = parser_.parse('POLYGON EMPTY')
282
+ obj_ = parser_.parse("POLYGON EMPTY")
317
283
  assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
318
284
  assert_equal(0, obj_.exterior_ring.num_points)
319
285
  end
320
286
 
321
-
322
287
  def test_multipoint_basic
323
288
  factory_ = ::RGeo::Cartesian.preferred_factory
324
289
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
325
- obj_ = parser_.parse('MULTIPOINT((1 2),(0 3))')
290
+ obj_ = parser_.parse("MULTIPOINT((1 2),(0 3))")
326
291
  assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
327
292
  assert_equal(2, obj_.num_geometries)
328
293
  assert_equal(1, obj_[0].x)
329
294
  assert_equal(3, obj_[1].y)
330
295
  end
331
296
 
332
-
333
297
  def test_multipoint_without_parens
334
298
  # This syntax isn't strictly allowed by the spec, but apparently
335
299
  # it does get used occasionally, so we do support parsing it.
336
300
  factory_ = ::RGeo::Cartesian.preferred_factory
337
301
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
338
- obj_ = parser_.parse('MULTIPOINT(1 2, 0 3)')
302
+ obj_ = parser_.parse("MULTIPOINT(1 2, 0 3)")
339
303
  assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
340
304
  assert_equal(2, obj_.num_geometries)
341
305
  assert_equal(1, obj_[0].x)
342
306
  assert_equal(3, obj_[1].y)
343
307
  end
344
308
 
345
-
346
309
  def test_multipoint_empty
347
310
  factory_ = ::RGeo::Cartesian.preferred_factory
348
311
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
349
- obj_ = parser_.parse('MULTIPOINT EMPTY')
312
+ obj_ = parser_.parse("MULTIPOINT EMPTY")
350
313
  assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
351
314
  assert_equal(0, obj_.num_geometries)
352
315
  end
353
316
 
354
-
355
317
  def test_multilinestring_basic
356
318
  factory_ = ::RGeo::Cartesian.preferred_factory
357
319
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
358
- obj_ = parser_.parse('MULTILINESTRING((1 2, 3 4, 5 6),(0 -3, 0 -4, 1 -5))')
320
+ obj_ = parser_.parse("MULTILINESTRING((1 2, 3 4, 5 6),(0 -3, 0 -4, 1 -5))")
359
321
  assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
360
322
  assert_equal(2, obj_.num_geometries)
361
323
  assert_equal(1, obj_[0].point_n(0).x)
362
324
  assert_equal(-5, obj_[1].point_n(2).y)
363
325
  end
364
326
 
365
-
366
327
  def test_multilinestring_empty
367
328
  factory_ = ::RGeo::Cartesian.preferred_factory
368
329
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
369
- obj_ = parser_.parse('MULTILINESTRING EMPTY')
330
+ obj_ = parser_.parse("MULTILINESTRING EMPTY")
370
331
  assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
371
332
  assert_equal(0, obj_.num_geometries)
372
333
  end
373
334
 
374
-
375
335
  def test_multipolygon_basic
376
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
336
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
377
337
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
378
- obj_ = parser_.parse('MULTIPOLYGON(((-1 -2 0, -3 -4 0, -5 -7 0, -1 -2 0)),((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9)))')
338
+ obj_ = parser_.parse("MULTIPOLYGON(((-1 -2 0, -3 -4 0, -5 -7 0, -1 -2 0)),((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9)))")
379
339
  assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
380
340
  assert_equal(2, obj_.num_geometries)
381
341
  assert_equal(4, obj_[0].exterior_ring.num_points)
@@ -389,20 +349,18 @@ module RGeo
389
349
  assert_equal(-7, obj_[1].interior_ring_n(0).point_n(1).z)
390
350
  end
391
351
 
392
-
393
352
  def test_multipolygon_empty
394
353
  factory_ = ::RGeo::Cartesian.preferred_factory
395
354
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
396
- obj_ = parser_.parse('MULTIPOLYGON EMPTY')
355
+ obj_ = parser_.parse("MULTIPOLYGON EMPTY")
397
356
  assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
398
357
  assert_equal(0, obj_.num_geometries)
399
358
  end
400
359
 
401
-
402
360
  def test_collection_basic
403
361
  factory_ = ::RGeo::Cartesian.preferred_factory
404
362
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
405
- obj_ = parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2, 3 4, 5 6))')
363
+ obj_ = parser_.parse("GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2, 3 4, 5 6))")
406
364
  assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
407
365
  assert_equal(2, obj_.num_geometries)
408
366
  assert_equal(::RGeo::Feature::Point, obj_[0].geometry_type)
@@ -412,11 +370,10 @@ module RGeo
412
370
  assert_equal(6, obj_[1].point_n(2).y)
413
371
  end
414
372
 
415
-
416
373
  def test_collection_z
417
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
374
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
418
375
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
419
- obj_ = parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2 0),LINESTRING(1 2 0, 3 4 0, 5 6 0))')
376
+ obj_ = parser_.parse("GEOMETRYCOLLECTION(POINT(-1 -2 0),LINESTRING(1 2 0, 3 4 0, 5 6 0))")
420
377
  assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
421
378
  assert_equal(2, obj_.num_geometries)
422
379
  assert_equal(::RGeo::Feature::Point, obj_[0].geometry_type)
@@ -426,36 +383,30 @@ module RGeo
426
383
  assert_equal(6, obj_[1].point_n(2).y)
427
384
  end
428
385
 
429
-
430
386
  def test_collection_dimension_mismatch
431
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
387
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
432
388
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
433
389
  assert_raise(::RGeo::Error::ParseError) do
434
- parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2 0, 3 4 0, 5 6 0))')
390
+ parser_.parse("GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2 0, 3 4 0, 5 6 0))")
435
391
  end
436
392
  end
437
393
 
438
-
439
394
  def test_collection_wkt12_type_mismatch
440
- factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
441
- parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
395
+ factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
396
+ parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
442
397
  assert_raise(::RGeo::Error::ParseError) do
443
- parser_.parse('GEOMETRYCOLLECTION Z(POINT Z(-1 -2 0),LINESTRING M(1 2 0, 3 4 0, 5 6 0))')
398
+ parser_.parse("GEOMETRYCOLLECTION Z(POINT Z(-1 -2 0),LINESTRING M(1 2 0, 3 4 0, 5 6 0))")
444
399
  end
445
400
  end
446
401
 
447
-
448
402
  def test_collection_empty
449
403
  factory_ = ::RGeo::Cartesian.preferred_factory
450
404
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
451
- obj_ = parser_.parse('GEOMETRYCOLLECTION EMPTY')
405
+ obj_ = parser_.parse("GEOMETRYCOLLECTION EMPTY")
452
406
  assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
453
407
  assert_equal(0, obj_.num_geometries)
454
408
  end
455
-
456
-
457
409
  end
458
-
459
410
  end
460
411
  end
461
412
  end