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,16 +4,12 @@
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- require 'rgeo'
8
-
7
+ require "rgeo"
9
8
 
10
9
  module RGeo
11
- module Tests # :nodoc:
12
- module Common # :nodoc:
13
-
14
- module MultiLineStringTests # :nodoc:
15
-
16
-
10
+ module Tests # :nodoc:
11
+ module Common # :nodoc:
12
+ module MultiLineStringTests # :nodoc:
17
13
  def setup
18
14
  @factory = create_factory
19
15
  point1_ = @factory.point(0, 0)
@@ -27,7 +23,6 @@ module RGeo
27
23
  @line1 = @factory.line(point1_, point2_)
28
24
  end
29
25
 
30
-
31
26
  def test_creation_simple
32
27
  geom_ = @factory.multi_line_string([@linestring1, @linestring2])
33
28
  assert_not_nil(geom_)
@@ -38,7 +33,6 @@ module RGeo
38
33
  assert(@linestring2.eql?(geom_[1]))
39
34
  end
40
35
 
41
-
42
36
  def test_creation_empty
43
37
  geom_ = @factory.multi_line_string([])
44
38
  assert_not_nil(geom_)
@@ -48,7 +42,6 @@ module RGeo
48
42
  assert_equal([], geom_.to_a)
49
43
  end
50
44
 
51
-
52
45
  def test_creation_save_types
53
46
  geom_ = @factory.multi_line_string([@linestring1, @linearring1, @line1])
54
47
  assert_not_nil(geom_)
@@ -59,7 +52,6 @@ module RGeo
59
52
  assert(geom_[2].eql?(@line1))
60
53
  end
61
54
 
62
-
63
55
  def test_creation_casting
64
56
  mls1_ = @factory.collection([@line1])
65
57
  mls2_ = @factory.multi_line_string([@linearring1])
@@ -73,7 +65,6 @@ module RGeo
73
65
  assert(@linearring1.eql?(geom_[3]))
74
66
  end
75
67
 
76
-
77
68
  def test_required_equivalences
78
69
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
79
70
  geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
@@ -81,7 +72,6 @@ module RGeo
81
72
  assert(geom1_ == geom2_)
82
73
  end
83
74
 
84
-
85
75
  def test_fully_equal
86
76
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
87
77
  geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
@@ -89,7 +79,6 @@ module RGeo
89
79
  assert(geom1_.equals?(geom2_))
90
80
  end
91
81
 
92
-
93
82
  def test_geometrically_equal
94
83
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2, @linearring1])
95
84
  geom2_ = @factory.multi_line_string([@line1, @linearring1])
@@ -97,7 +86,6 @@ module RGeo
97
86
  assert(geom1_.equals?(geom2_))
98
87
  end
99
88
 
100
-
101
89
  def test_not_equal
102
90
  geom1_ = @factory.multi_line_string([@linestring2])
103
91
  geom2_ = @factory.multi_line_string([@linearring1])
@@ -105,29 +93,25 @@ module RGeo
105
93
  assert(!geom1_.equals?(geom2_))
106
94
  end
107
95
 
108
-
109
96
  def test_hashes_equal_for_representationally_equivalent_objects
110
97
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
111
98
  geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
112
99
  assert_equal(geom1_.hash, geom2_.hash)
113
100
  end
114
101
 
115
-
116
102
  def test_wkt_creation_simple
117
- parsed_geom_ = @factory.parse_wkt('MULTILINESTRING((0 0, 1 0), (-4 2, -7 6, 5 11))')
103
+ parsed_geom_ = @factory.parse_wkt("MULTILINESTRING((0 0, 1 0), (-4 2, -7 6, 5 11))")
118
104
  built_geom_ = @factory.multi_line_string([@linestring1, @linestring2])
119
105
  assert(built_geom_.eql?(parsed_geom_))
120
106
  end
121
107
 
122
-
123
108
  def test_wkt_creation_empty
124
- parsed_geom_ = @factory.parse_wkt('MULTILINESTRING EMPTY')
109
+ parsed_geom_ = @factory.parse_wkt("MULTILINESTRING EMPTY")
125
110
  assert_equal(::RGeo::Feature::MultiLineString, parsed_geom_.geometry_type)
126
111
  assert_equal(0, parsed_geom_.num_geometries)
127
112
  assert_equal([], parsed_geom_.to_a)
128
113
  end
129
114
 
130
-
131
115
  def test_clone
132
116
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
133
117
  geom2_ = geom1_.clone
@@ -138,7 +122,6 @@ module RGeo
138
122
  assert(@linestring2.eql?(geom2_[1]))
139
123
  end
140
124
 
141
-
142
125
  def test_type_check
143
126
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
144
127
  assert(::RGeo::Feature::Geometry.check_type(geom1_))
@@ -154,7 +137,6 @@ module RGeo
154
137
  assert(::RGeo::Feature::MultiLineString.check_type(geom2_))
155
138
  end
156
139
 
157
-
158
140
  def test_as_text_wkt_round_trip
159
141
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
160
142
  text_ = geom1_.as_text
@@ -162,7 +144,6 @@ module RGeo
162
144
  assert(geom1_.eql?(geom2_))
163
145
  end
164
146
 
165
-
166
147
  def test_as_binary_wkb_round_trip
167
148
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
168
149
  binary_ = geom1_.as_binary
@@ -170,7 +151,6 @@ module RGeo
170
151
  assert(geom1_.eql?(geom2_))
171
152
  end
172
153
 
173
-
174
154
  def test_dimension
175
155
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
176
156
  assert_equal(1, geom1_.dimension)
@@ -178,7 +158,6 @@ module RGeo
178
158
  assert_equal(-1, geom2_.dimension)
179
159
  end
180
160
 
181
-
182
161
  def test_is_empty
183
162
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
184
163
  assert(!geom1_.is_empty?)
@@ -186,7 +165,6 @@ module RGeo
186
165
  assert(geom2_.is_empty?)
187
166
  end
188
167
 
189
-
190
168
  def test_length
191
169
  geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
192
170
  assert_equal(19, geom1_.length)
@@ -194,9 +172,11 @@ module RGeo
194
172
  assert_equal(0, geom2_.length)
195
173
  end
196
174
 
197
-
175
+ def test_coordinates
176
+ ml = @factory.multi_line_string([@linestring1, @linestring2])
177
+ assert_equal(ml.coordinates, [@linestring1, @linestring2].map(&:coordinates))
178
+ end
198
179
  end
199
-
200
180
  end
201
181
  end
202
182
  end
@@ -4,16 +4,12 @@
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- require 'rgeo'
8
-
7
+ require "rgeo"
9
8
 
10
9
  module RGeo
11
- module Tests # :nodoc:
12
- module Common # :nodoc:
13
-
14
- module MultiPointTests # :nodoc:
15
-
16
-
10
+ module Tests # :nodoc:
11
+ module Common # :nodoc:
12
+ module MultiPointTests # :nodoc:
17
13
  def setup
18
14
  @factory = create_factory
19
15
  @point1 = @factory.point(0, 0)
@@ -23,7 +19,6 @@ module RGeo
23
19
  @point5 = @factory.point(-5, 3)
24
20
  end
25
21
 
26
-
27
22
  def test_creation_simple
28
23
  geom_ = @factory.multi_point([@point1, @point2])
29
24
  assert_not_nil(geom_)
@@ -34,7 +29,6 @@ module RGeo
34
29
  assert(@point2.eql?(geom_[1]))
35
30
  end
36
31
 
37
-
38
32
  def test_creation_empty
39
33
  geom_ = @factory.multi_point([])
40
34
  assert_not_nil(geom_)
@@ -44,7 +38,6 @@ module RGeo
44
38
  assert_equal([], geom_.to_a)
45
39
  end
46
40
 
47
-
48
41
  def test_creation_casting
49
42
  mp1_ = @factory.collection([@point3])
50
43
  mp2_ = @factory.multi_point([@point4])
@@ -58,14 +51,12 @@ module RGeo
58
51
  assert(@point4.eql?(geom_[3]))
59
52
  end
60
53
 
61
-
62
54
  def test_creation_wrong_type
63
55
  line_ = @factory.line_string([@point1, @point2])
64
56
  geom_ = @factory.multi_point([@point3, line_])
65
57
  assert_nil(geom_)
66
58
  end
67
59
 
68
-
69
60
  def test_required_equivalences
70
61
  geom1_ = @factory.multi_point([@point1, @point2])
71
62
  geom2_ = @factory.multi_point([@point1, @point2])
@@ -73,7 +64,6 @@ module RGeo
73
64
  assert(geom1_ == geom2_)
74
65
  end
75
66
 
76
-
77
67
  def test_fully_equal
78
68
  geom1_ = @factory.multi_point([@point1, @point2])
79
69
  geom2_ = @factory.multi_point([@point1, @point2])
@@ -81,7 +71,6 @@ module RGeo
81
71
  assert(geom1_.equals?(geom2_))
82
72
  end
83
73
 
84
-
85
74
  def test_geometrically_equal
86
75
  geom1_ = @factory.multi_point([@point1, @point4])
87
76
  geom2_ = @factory.multi_point([@point1, @point4, @point5])
@@ -89,7 +78,6 @@ module RGeo
89
78
  assert(geom1_.equals?(geom2_))
90
79
  end
91
80
 
92
-
93
81
  def test_not_equal
94
82
  geom1_ = @factory.multi_point([@point1, @point2])
95
83
  geom2_ = @factory.multi_point([@point1])
@@ -97,29 +85,25 @@ module RGeo
97
85
  assert(!geom1_.equals?(geom2_))
98
86
  end
99
87
 
100
-
101
88
  def test_hashes_equal_for_representationally_equivalent_objects
102
89
  geom1_ = @factory.multi_point([@point1, @point2])
103
90
  geom2_ = @factory.multi_point([@point1, @point2])
104
91
  assert_equal(geom1_.hash, geom2_.hash)
105
92
  end
106
93
 
107
-
108
94
  def test_wkt_creation_simple
109
- parsed_geom_ = @factory.parse_wkt('MULTIPOINT((0 0), (-4 2), (-5 3))')
95
+ parsed_geom_ = @factory.parse_wkt("MULTIPOINT((0 0), (-4 2), (-5 3))")
110
96
  built_geom_ = @factory.multi_point([@point1, @point3, @point4])
111
97
  assert(built_geom_.eql?(parsed_geom_))
112
98
  end
113
99
 
114
-
115
100
  def test_wkt_creation_empty
116
- parsed_geom_ = @factory.parse_wkt('MULTIPOINT EMPTY')
101
+ parsed_geom_ = @factory.parse_wkt("MULTIPOINT EMPTY")
117
102
  assert(::RGeo::Feature::MultiPoint === parsed_geom_)
118
103
  assert_equal(0, parsed_geom_.num_geometries)
119
104
  assert_equal([], parsed_geom_.to_a)
120
105
  end
121
106
 
122
-
123
107
  def test_clone
124
108
  geom1_ = @factory.multi_point([@point1, @point2])
125
109
  geom2_ = geom1_.clone
@@ -130,7 +114,6 @@ module RGeo
130
114
  assert(@point2.eql?(geom2_[1]))
131
115
  end
132
116
 
133
-
134
117
  def test_type_check
135
118
  geom1_ = @factory.multi_point([@point1, @point2])
136
119
  assert(::RGeo::Feature::Geometry.check_type(geom1_))
@@ -146,7 +129,6 @@ module RGeo
146
129
  assert(!::RGeo::Feature::MultiLineString.check_type(geom2_))
147
130
  end
148
131
 
149
-
150
132
  def test_as_text_wkt_round_trip
151
133
  geom1_ = @factory.multi_point([@point1, @point2])
152
134
  text_ = geom1_.as_text
@@ -154,7 +136,6 @@ module RGeo
154
136
  assert(geom1_.eql?(geom2_))
155
137
  end
156
138
 
157
-
158
139
  def test_as_binary_wkb_round_trip
159
140
  geom1_ = @factory.multi_point([@point1, @point2])
160
141
  binary_ = geom1_.as_binary
@@ -162,7 +143,6 @@ module RGeo
162
143
  assert(geom1_.eql?(geom2_))
163
144
  end
164
145
 
165
-
166
146
  def test_dimension
167
147
  geom1_ = @factory.multi_point([@point1, @point2])
168
148
  assert_equal(0, geom1_.dimension)
@@ -170,7 +150,6 @@ module RGeo
170
150
  assert_equal(-1, geom2_.dimension)
171
151
  end
172
152
 
173
-
174
153
  def test_is_empty
175
154
  geom1_ = @factory.multi_point([@point1, @point2])
176
155
  assert(!geom1_.is_empty?)
@@ -178,7 +157,6 @@ module RGeo
178
157
  assert(geom2_.is_empty?)
179
158
  end
180
159
 
181
-
182
160
  def test_union
183
161
  geom1_ = @factory.multi_point([@point1, @point2])
184
162
  geom2_ = @factory.multi_point([@point1, @point3])
@@ -187,7 +165,6 @@ module RGeo
187
165
  assert_equal(geom3_, geom1_ + geom2_)
188
166
  end
189
167
 
190
-
191
168
  def test_difference
192
169
  geom1_ = @factory.multi_point([@point1, @point2])
193
170
  geom2_ = @factory.multi_point([@point1, @point3])
@@ -195,7 +172,6 @@ module RGeo
195
172
  assert_equal(@point2, geom1_ - geom2_)
196
173
  end
197
174
 
198
-
199
175
  def test_intersection
200
176
  geom1_ = @factory.multi_point([@point1, @point2])
201
177
  geom2_ = @factory.multi_point([@point1, @point3])
@@ -203,17 +179,22 @@ module RGeo
203
179
  assert_equal(@point1, geom1_ * geom2_)
204
180
  end
205
181
 
206
-
207
182
  def test_zm
208
- factory_ = create_factory(:has_z_coordinate => true, :has_m_coordinate => true)
183
+ factory_ = create_factory(has_z_coordinate: true, has_m_coordinate: true)
209
184
  p1_ = factory_.point(1, 2, 3, 4)
210
185
  mp_ = factory_.multi_point([p1_])
211
186
  assert_equal(p1_, mp_[0])
212
187
  end
213
188
 
214
-
189
+ def test_coordinate
190
+ p0 = @factory.point(0, 0)
191
+ p1 = @factory.point(1, 1)
192
+ p2 = @factory.point(2, 2)
193
+ points = [p0, p1, p2]
194
+ mp = @factory.multi_point(points)
195
+ assert_equal(mp.coordinates, points.map(&:coordinates))
196
+ end
215
197
  end
216
-
217
198
  end
218
199
  end
219
200
  end
@@ -4,16 +4,12 @@
4
4
  #
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- require 'rgeo'
8
-
7
+ require "rgeo"
9
8
 
10
9
  module RGeo
11
- module Tests # :nodoc:
12
- module Common # :nodoc:
13
-
14
- module MultiPolygonTests # :nodoc:
15
-
16
-
10
+ module Tests # :nodoc:
11
+ module Common # :nodoc:
12
+ module MultiPolygonTests # :nodoc:
17
13
  def setup
18
14
  create_factories
19
15
  point1_ = @factory.point(0, 0)
@@ -37,7 +33,6 @@ module RGeo
37
33
  @line1 = interior1_
38
34
  end
39
35
 
40
-
41
36
  def test_creation_simple
42
37
  geom_ = @factory.multi_polygon([@poly1, @poly2])
43
38
  assert_not_nil(geom_)
@@ -48,7 +43,6 @@ module RGeo
48
43
  assert(@poly2.eql?(geom_[1]))
49
44
  end
50
45
 
51
-
52
46
  def test_creation_empty
53
47
  geom_ = @factory.multi_polygon([])
54
48
  assert_not_nil(geom_)
@@ -58,13 +52,11 @@ module RGeo
58
52
  assert_equal([], geom_.to_a)
59
53
  end
60
54
 
61
-
62
55
  def test_creation_wrong_type
63
56
  geom_ = @factory.multi_polygon([@poly1, @line1])
64
57
  assert_nil(geom_)
65
58
  end
66
59
 
67
-
68
60
  def test_creation_overlapping
69
61
  geom_ = @factory.multi_polygon([@poly1, @poly1])
70
62
  assert_nil(geom_)
@@ -72,7 +64,6 @@ module RGeo
72
64
  assert_not_nil(geom2_)
73
65
  end
74
66
 
75
-
76
67
  def test_creation_connected
77
68
  geom_ = @factory.multi_polygon([@poly3, @poly4])
78
69
  assert_nil(geom_)
@@ -80,7 +71,6 @@ module RGeo
80
71
  assert_not_nil(geom2_)
81
72
  end
82
73
 
83
-
84
74
  def test_required_equivalences
85
75
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
86
76
  geom2_ = @factory.multi_polygon([@poly1, @poly2])
@@ -88,7 +78,6 @@ module RGeo
88
78
  assert(geom1_ == geom2_)
89
79
  end
90
80
 
91
-
92
81
  def test_equal
93
82
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
94
83
  geom2_ = @factory.multi_polygon([@poly1, @poly2])
@@ -96,7 +85,6 @@ module RGeo
96
85
  assert(geom1_.equals?(geom2_))
97
86
  end
98
87
 
99
-
100
88
  def test_not_equal
101
89
  geom1_ = @factory.multi_polygon([@poly1])
102
90
  geom2_ = @factory.multi_polygon([@poly2])
@@ -104,29 +92,25 @@ module RGeo
104
92
  assert(!geom1_.equals?(geom2_))
105
93
  end
106
94
 
107
-
108
95
  def test_hashes_equal_for_representationally_equivalent_objects
109
96
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
110
97
  geom2_ = @factory.multi_polygon([@poly1, @poly2])
111
98
  assert_equal(geom1_.hash, geom2_.hash)
112
99
  end
113
100
 
114
-
115
101
  def test_wkt_creation_simple
116
- parsed_geom_ = @factory.parse_wkt('MULTIPOLYGON(((0 0, 0 -10, -10 0, 0 0)), ((0 0, 0 10, 10 10, 10 0, 0 0), (4 4, 5 6, 6 4, 4 4)))')
102
+ parsed_geom_ = @factory.parse_wkt("MULTIPOLYGON(((0 0, 0 -10, -10 0, 0 0)), ((0 0, 0 10, 10 10, 10 0, 0 0), (4 4, 5 6, 6 4, 4 4)))")
117
103
  built_geom_ = @factory.multi_polygon([@poly1, @poly2])
118
104
  assert(built_geom_.eql?(parsed_geom_))
119
105
  end
120
106
 
121
-
122
107
  def test_wkt_creation_empty
123
- parsed_geom_ = @factory.parse_wkt('MULTIPOLYGON EMPTY')
108
+ parsed_geom_ = @factory.parse_wkt("MULTIPOLYGON EMPTY")
124
109
  assert_equal(::RGeo::Feature::MultiPolygon, parsed_geom_.geometry_type)
125
110
  assert_equal(0, parsed_geom_.num_geometries)
126
111
  assert_equal([], parsed_geom_.to_a)
127
112
  end
128
113
 
129
-
130
114
  def test_clone
131
115
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
132
116
  geom2_ = geom1_.clone
@@ -137,7 +121,6 @@ module RGeo
137
121
  assert(@poly2.eql?(geom2_[1]))
138
122
  end
139
123
 
140
-
141
124
  def test_type_check
142
125
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
143
126
  assert(::RGeo::Feature::Geometry.check_type(geom1_))
@@ -153,7 +136,6 @@ module RGeo
153
136
  assert(::RGeo::Feature::MultiPolygon.check_type(geom2_))
154
137
  end
155
138
 
156
-
157
139
  def test_as_text_wkt_round_trip
158
140
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
159
141
  text_ = geom1_.as_text
@@ -161,7 +143,6 @@ module RGeo
161
143
  assert(geom1_.eql?(geom2_))
162
144
  end
163
145
 
164
-
165
146
  def test_as_binary_wkb_round_trip
166
147
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
167
148
  binary_ = geom1_.as_binary
@@ -169,7 +150,6 @@ module RGeo
169
150
  assert(geom1_.eql?(geom2_))
170
151
  end
171
152
 
172
-
173
153
  def test_dimension
174
154
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
175
155
  assert_equal(2, geom1_.dimension)
@@ -177,7 +157,6 @@ module RGeo
177
157
  assert_equal(-1, geom2_.dimension)
178
158
  end
179
159
 
180
-
181
160
  def test_is_empty
182
161
  geom1_ = @factory.multi_polygon([@poly1, @poly2])
183
162
  assert(!geom1_.is_empty?)
@@ -185,9 +164,28 @@ module RGeo
185
164
  assert(geom2_.is_empty?)
186
165
  end
187
166
 
167
+ def test_multi_polygon_coordinates
168
+ poly1_coordinates = [
169
+ [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]],
170
+ [[0.25, 0.25], [0.75, 0.25], [0.75, 0.75], [0.25, 0.75], [0.25, 0.25]]
171
+ ]
172
+ poly2_coordinates = [
173
+ [[2.0, 2.0], [3.0, 2.0], [3.0, 3.0], [2.0, 3.0], [2.0, 2.0]],
174
+ [[2.25, 2.25], [2.75, 2.25], [2.75, 2.75], [2.25, 2.75], [2.25, 2.25]]
175
+ ]
188
176
 
189
- end
177
+ ring = @factory.line_string(poly1_coordinates.first.map { |(x, y)| @factory.point x, y })
178
+ inner_ring = @factory.line_string(poly1_coordinates.last.map { |(x, y)| @factory.point x, y })
179
+ poly1 = @factory.polygon ring, [inner_ring]
190
180
 
181
+ ring = @factory.line_string(poly2_coordinates.first.map { |(x, y)| @factory.point x, y })
182
+ inner_ring = @factory.line_string(poly2_coordinates.last.map { |(x, y)| @factory.point x, y })
183
+ poly2 = @factory.polygon ring, [inner_ring]
184
+
185
+ multi_polygon = @factory.multi_polygon [poly1, poly2]
186
+ assert_equal(multi_polygon.coordinates, [poly1_coordinates, poly2_coordinates])
187
+ end
188
+ end
191
189
  end
192
190
  end
193
191
  end