rgeo 1.1.2 → 2.0.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/ext/geos_c_impl/extconf.rb +5 -3
  3. data/ext/geos_c_impl/factory.c +4 -4
  4. data/ext/geos_c_impl/geometry.c +1 -1
  5. data/lib/rgeo.rb +2 -4
  6. data/lib/rgeo/cartesian.rb +6 -16
  7. data/lib/rgeo/cartesian/analysis.rb +22 -20
  8. data/lib/rgeo/cartesian/bounding_box.rb +83 -79
  9. data/lib/rgeo/cartesian/calculations.rb +40 -38
  10. data/lib/rgeo/cartesian/factory.rb +134 -169
  11. data/lib/rgeo/cartesian/feature_classes.rb +2 -18
  12. data/lib/rgeo/cartesian/feature_methods.rb +37 -39
  13. data/lib/rgeo/cartesian/interface.rb +11 -9
  14. data/lib/rgeo/coord_sys.rb +9 -8
  15. data/lib/rgeo/coord_sys/cs/entities.rb +345 -303
  16. data/lib/rgeo/coord_sys/cs/factories.rb +30 -28
  17. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +128 -126
  18. data/lib/rgeo/coord_sys/srs_database/{interface.rb → entry.rb} +26 -32
  19. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +19 -17
  20. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +21 -19
  21. data/lib/rgeo/error.rb +3 -1
  22. data/lib/rgeo/feature.rb +23 -34
  23. data/lib/rgeo/feature/curve.rb +2 -0
  24. data/lib/rgeo/feature/factory.rb +15 -13
  25. data/lib/rgeo/feature/factory_generator.rb +7 -5
  26. data/lib/rgeo/feature/geometry.rb +31 -29
  27. data/lib/rgeo/feature/geometry_collection.rb +6 -4
  28. data/lib/rgeo/feature/line.rb +2 -0
  29. data/lib/rgeo/feature/line_string.rb +3 -1
  30. data/lib/rgeo/feature/linear_ring.rb +2 -0
  31. data/lib/rgeo/feature/multi_curve.rb +2 -0
  32. data/lib/rgeo/feature/multi_line_string.rb +2 -0
  33. data/lib/rgeo/feature/multi_point.rb +2 -0
  34. data/lib/rgeo/feature/multi_polygon.rb +2 -0
  35. data/lib/rgeo/feature/multi_surface.rb +2 -0
  36. data/lib/rgeo/feature/point.rb +2 -0
  37. data/lib/rgeo/feature/polygon.rb +3 -1
  38. data/lib/rgeo/feature/surface.rb +2 -0
  39. data/lib/rgeo/feature/types.rb +107 -103
  40. data/lib/rgeo/geographic.rb +17 -27
  41. data/lib/rgeo/geographic/factory.rb +154 -199
  42. data/lib/rgeo/geographic/interface.rb +141 -137
  43. data/lib/rgeo/geographic/proj4_projector.rb +28 -23
  44. data/lib/rgeo/geographic/projected_feature_classes.rb +2 -18
  45. data/lib/rgeo/geographic/projected_feature_methods.rb +59 -49
  46. data/lib/rgeo/geographic/projected_window.rb +4 -2
  47. data/lib/rgeo/geographic/simple_mercator_projector.rb +41 -39
  48. data/lib/rgeo/geographic/spherical_feature_classes.rb +2 -18
  49. data/lib/rgeo/geographic/spherical_feature_methods.rb +67 -67
  50. data/lib/rgeo/geographic/spherical_math.rb +81 -87
  51. data/lib/rgeo/geos.rb +23 -34
  52. data/lib/rgeo/geos/capi_factory.rb +106 -135
  53. data/lib/rgeo/geos/capi_feature_classes.rb +19 -37
  54. data/lib/rgeo/geos/ffi_factory.rb +276 -297
  55. data/lib/rgeo/geos/ffi_feature_classes.rb +2 -20
  56. data/lib/rgeo/geos/ffi_feature_methods.rb +170 -166
  57. data/lib/rgeo/geos/interface.rb +25 -23
  58. data/lib/rgeo/geos/utils.rb +47 -39
  59. data/lib/rgeo/geos/zm_factory.rb +171 -185
  60. data/lib/rgeo/geos/zm_feature_classes.rb +2 -20
  61. data/lib/rgeo/geos/zm_feature_methods.rb +76 -72
  62. data/lib/rgeo/impl_helper.rb +1 -11
  63. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +72 -75
  64. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +21 -23
  65. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +57 -49
  66. data/lib/rgeo/impl_helper/basic_point_methods.rb +29 -25
  67. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +31 -27
  68. data/lib/rgeo/impl_helper/math.rb +2 -0
  69. data/lib/rgeo/impl_helper/utils.rb +9 -15
  70. data/lib/rgeo/version.rb +3 -1
  71. data/lib/rgeo/wkrep.rb +20 -30
  72. data/lib/rgeo/wkrep/wkb_generator.rb +87 -84
  73. data/lib/rgeo/wkrep/wkb_parser.rb +93 -93
  74. data/lib/rgeo/wkrep/wkt_generator.rb +67 -63
  75. data/lib/rgeo/wkrep/wkt_parser.rb +172 -168
  76. metadata +17 -32
  77. data/lib/rgeo/feature/mixins.rb +0 -143
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0760bb96d9e6654cf7cb09bd88b4a799f5ba249f573fd4c0484df2269ba50a0
4
- data.tar.gz: 73928442258c96603367a340aac3cd1f93bed12471854e17cf14a712d58bb711
3
+ metadata.gz: b8472a195fa15704c94ed5074f539d815477b9d05e1354e4a47dcf7110235f5e
4
+ data.tar.gz: 81914f85026703454776fd5816c25869a35ba00f77f6509dc815205d2f35b604
5
5
  SHA512:
6
- metadata.gz: 961f639e7a8985cbcdff0b166cdf2923a6a8a4c4143e55b66a2769d5897abdacb42a6abceaa2b92c870f648e867154df996e55d5ab9a50bbbe70a6c4eef5c7bd
7
- data.tar.gz: ff8f393c6c5ef195c790836a4ba844867d54c7cf4e8a7266d86c4bd0f44025a58a90debad8a77521288ef1ffe8db0906575e52de9a5dc49d5507fb03aee43765
6
+ metadata.gz: 6a6e0a821118e84e0052585431df5af8956a9f89882ce3314eeca72ff386617859bbe52a857b7761b8f8d8bc644a60734b5197fe209b20dd0d9fc294121735af
7
+ data.tar.gz: 2f68c55105f188e1f8c1b9c4bc1a5ae32e20b4dd630a3ade0038169a9d62fb3409cc85bad3c08bfb60bf0c73331f7c33192fb5c94622073974021e5b6447e9ae
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # Makefile builder for GEOS wrapper
4
6
  #
5
7
  # -----------------------------------------------------------------------------
6
8
  def create_dummy_makefile
7
- ::File.open("Makefile", "w") { |f_| f_.write(".PHONY: install\ninstall:\n") }
9
+ File.open("Makefile", "w") { |f_| f_.write(".PHONY: install\ninstall:\n") }
8
10
  end
9
11
 
10
- if ::RUBY_DESCRIPTION =~ /^jruby\s/
12
+ if RUBY_DESCRIPTION =~ /^jruby\s/
11
13
  create_dummy_makefile
12
14
  else
13
15
  require "mkmf"
@@ -15,7 +17,7 @@ else
15
17
  geosconfig = with_config("geos-config") || find_executable("geos-config")
16
18
 
17
19
  if geosconfig
18
- puts "Using GEOS compile configuration from %s" [geosconfig]
20
+ puts "Using GEOS compile configuration from #{geosconfig}"
19
21
  $INCFLAGS << " " << `#{geosconfig} --cflags`.strip
20
22
  geos_libs = `#{geosconfig} --clibs`.tr("\n", " ")
21
23
  geos_libs.split(/\s+/).each do |flag|
@@ -623,10 +623,10 @@ RGeo_Globals* rgeo_init_geos_factory()
623
623
  rb_define_method(geos_factory_class, "_wkb_generator", method_get_wkb_generator, 0);
624
624
  rb_define_method(geos_factory_class, "_wkt_parser", method_get_wkt_parser, 0);
625
625
  rb_define_method(geos_factory_class, "_wkb_parser", method_get_wkb_parser, 0);
626
- rb_define_method(geos_factory_class, "_read_for_marshal", method_factory_read_for_marshal, 1);
627
- rb_define_method(geos_factory_class, "_write_for_marshal", method_factory_write_for_marshal, 1);
628
- rb_define_method(geos_factory_class, "_read_for_psych", method_factory_read_for_psych, 1);
629
- rb_define_method(geos_factory_class, "_write_for_psych", method_factory_write_for_psych, 1);
626
+ rb_define_method(geos_factory_class, "read_for_marshal", method_factory_read_for_marshal, 1);
627
+ rb_define_method(geos_factory_class, "write_for_marshal", method_factory_write_for_marshal, 1);
628
+ rb_define_method(geos_factory_class, "read_for_psych", method_factory_read_for_psych, 1);
629
+ rb_define_method(geos_factory_class, "write_for_psych", method_factory_write_for_psych, 1);
630
630
  rb_define_module_function(geos_factory_class, "_create", cmethod_factory_create, 7);
631
631
  rb_define_module_function(geos_factory_class, "_geos_version", cmethod_factory_geos_version, 0);
632
632
  rb_define_module_function(geos_factory_class, "_supports_unary_union?", cmethod_factory_supports_unary_union, 0);
@@ -1063,7 +1063,7 @@ void rgeo_init_geos_geometry(RGeo_Globals* globals)
1063
1063
 
1064
1064
  geos_geometry_methods = rb_define_module_under(globals->geos_module, "CAPIGeometryMethods");
1065
1065
 
1066
- rb_define_method(geos_geometry_methods, "_set_factory", method_geometry_set_factory, 1);
1066
+ rb_define_method(geos_geometry_methods, "factory=", method_geometry_set_factory, 1);
1067
1067
  rb_define_method(geos_geometry_methods, "initialize_copy", method_geometry_initialize_copy, 1);
1068
1068
  rb_define_method(geos_geometry_methods, "_steal", method_geometry_steal, 1);
1069
1069
  rb_define_method(geos_geometry_methods, "initialized?", method_geometry_initialized_p, 0);
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # RGeo is a spatial data library for Ruby. It focuses on the storage and
2
4
  # manipulation of spatial data types such as points, lines, and polygons.
3
5
  #
@@ -73,10 +75,6 @@
73
75
  # database, and based on the postgresql adapter. Available as the
74
76
  # activerecord-postgis-adapter gem.
75
77
 
76
- module RGeo
77
- end
78
-
79
- # Core modules
80
78
  require "rgeo/version"
81
79
  require "rgeo/error"
82
80
  require "rgeo/feature"
@@ -1,21 +1,11 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Cartesian features for RGeo
4
- #
5
- # -----------------------------------------------------------------------------
1
+ # frozen_string_literal: true
6
2
 
7
- module RGeo
8
- # The Cartesian module is a gateway to implementations that use the
9
- # Cartesian (i.e. flat) coordinate system. It provides convenient
10
- # access to Cartesian factories such as the Geos implementation and
11
- # the simple Cartesian implementation. It also provides a namespace
12
- # for Cartesian-specific analysis tools.
3
+ # The Cartesian module is a gateway to implementations that use the
4
+ # Cartesian (i.e. flat) coordinate system. It provides convenient
5
+ # access to Cartesian factories such as the Geos implementation and
6
+ # the simple Cartesian implementation. It also provides a namespace
7
+ # for Cartesian-specific analysis tools.
13
8
 
14
- module Cartesian
15
- end
16
- end
17
-
18
- # Implementation files.
19
9
  require "rgeo/cartesian/calculations"
20
10
  require "rgeo/cartesian/feature_methods"
21
11
  require "rgeo/cartesian/feature_classes"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # Cartesian geometric analysis utilities
@@ -19,33 +21,33 @@ module RGeo
19
21
  # The return value is undefined if the object is not a ring, or
20
22
  # is not in a Cartesian coordinate system.
21
23
 
22
- def ring_direction(ring_)
23
- size_ = ring_.num_points - 1
24
- return 0 if size_ == 0
24
+ def ring_direction(ring)
25
+ size = ring.num_points - 1
26
+ return 0 if size == 0
25
27
 
26
28
  # Extract unit-length segments from the ring.
27
- segs_ = []
28
- size_.times do |i_|
29
- p0_ = ring_.point_n(i_)
30
- p1_ = ring_.point_n(i_ + 1)
31
- x_ = p1_.x - p0_.x
32
- y_ = p1_.y - p0_.y
33
- r_ = ::Math.sqrt(x_ * x_ + y_ * y_)
34
- if r_ > 0.0
35
- segs_ << x_ / r_ << y_ / r_
29
+ segs = []
30
+ size.times do |i|
31
+ p0 = ring.point_n(i)
32
+ p1 = ring.point_n(i + 1)
33
+ x = p1.x - p0.x
34
+ y = p1.y - p0.y
35
+ r = Math.sqrt(x * x + y * y)
36
+ if r > 0.0
37
+ segs << x / r << y / r
36
38
  else
37
- size_ -= 1
39
+ size -= 1
38
40
  end
39
41
  end
40
- segs_ << segs_[0] << segs_[1]
42
+ segs << segs[0] << segs[1]
41
43
 
42
44
  # Extract angles from the segments by subtracting the segments.
43
45
  # Note angles are represented as cos/sin pairs so we don't
44
46
  # have to calculate any trig functions.
45
- angs_ = []
46
- size_.times do |i_|
47
- x0_, y0_, x1_, y1_ = segs_[i_ * 2, 4]
48
- angs_ << x0_ * x1_ + y0_ * y1_ << x0_ * y1_ - x1_ * y0_
47
+ angs = []
48
+ size.times do |i|
49
+ x0, y0, x1, y1 = segs[i * 2, 4]
50
+ angs << x0 * x1 + y0 * y1 << x0 * y1 - x1 * y0
49
51
  end
50
52
 
51
53
  # Now add the angles and count revolutions.
@@ -54,12 +56,12 @@ module RGeo
54
56
  direction = nil
55
57
  sin = 0.0
56
58
  cos = 1.0
57
- angs_.each_slice(2) do |(x, y)|
59
+ angs.each_slice(2) do |(x, y)|
58
60
  ready = y > 0.0 && (sin > 0.0 || sin == 0.0 && direction == -1) || y < 0.0 && (sin < 0.0 || sin == 0.0 && direction == 1)
59
61
  if y != 0.0
60
62
  s = sin * x + cos * y
61
63
  c = cos * x - sin * y
62
- r = ::Math.sqrt(s * s + c * c)
64
+ r = Math.sqrt(s * s + c * c)
63
65
  sin = s / r
64
66
  cos = c / r
65
67
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # Cartesian bounding box
@@ -24,9 +26,9 @@ module RGeo
24
26
  # You may also provide the same options available to
25
27
  # BoundingBox.new.
26
28
 
27
- def self.create_from_points(point1_, point2_, opts_ = {})
28
- factory_ = point1_.factory
29
- new(factory_, opts_)._add_geometry(point1_).add(point2_)
29
+ def self.create_from_points(point1, point2, opts = {})
30
+ factory = point1.factory
31
+ new(factory, opts).add_geometry(point1).add(point2)
30
32
  end
31
33
 
32
34
  # Create a bounding box given a geometry to surround.
@@ -34,9 +36,9 @@ module RGeo
34
36
  # You may also provide the same options available to
35
37
  # BoundingBox.new.
36
38
 
37
- def self.create_from_geometry(geom_, opts_ = {})
38
- factory_ = geom_.factory
39
- new(factory_, opts_)._add_geometry(geom_)
39
+ def self.create_from_geometry(geom, opts = {})
40
+ factory = geom.factory
41
+ new(factory, opts).add_geometry(geom)
40
42
  end
41
43
 
42
44
  # Create a new empty bounding box with the given factory.
@@ -56,23 +58,23 @@ module RGeo
56
58
  # If true, ignore m coordinates even if the factory supports them.
57
59
  # Default is false.
58
60
 
59
- def initialize(factory_, opts_ = {})
60
- @factory = factory_
61
- if (values_ = opts_[:raw])
62
- @has_z, @has_m, @min_x, @max_x, @min_y, @max_y, @min_z, @max_z, @min_m, @max_m = values_
61
+ def initialize(factory, opts = {})
62
+ @factory = factory
63
+ if (values = opts[:raw])
64
+ @has_z, @has_m, @min_x, @max_x, @min_y, @max_y, @min_z, @max_z, @min_m, @max_m = values
63
65
  else
64
- @has_z = !opts_[:ignore_z] && factory_.property(:has_z_coordinate) ? true : false
65
- @has_m = !opts_[:ignore_m] && factory_.property(:has_m_coordinate) ? true : false
66
+ @has_z = !opts[:ignore_z] && factory.property(:has_z_coordinate) ? true : false
67
+ @has_m = !opts[:ignore_m] && factory.property(:has_m_coordinate) ? true : false
66
68
  @min_x = @max_x = @min_y = @max_y = @min_z = @max_z = @min_m = @max_m = nil
67
69
  end
68
70
  end
69
71
 
70
- def eql?(rhs_) # :nodoc:
71
- rhs_.is_a?(BoundingBox) && @factory == rhs_.factory &&
72
- @min_x == rhs_.min_x && @max_x == rhs_.max_x &&
73
- @min_y == rhs_.min_y && @max_y == rhs_.max_y &&
74
- @min_z == rhs_.min_z && @max_z == rhs_.max_z &&
75
- @min_m == rhs_.min_m && @max_m == rhs_.max_m
72
+ def eql?(rhs) # :nodoc:
73
+ rhs.is_a?(BoundingBox) && @factory == rhs.factory &&
74
+ @min_x == rhs.min_x && @max_x == rhs.max_x &&
75
+ @min_y == rhs.min_y && @max_y == rhs.max_y &&
76
+ @min_z == rhs.min_z && @max_z == rhs.max_z &&
77
+ @min_m == rhs.min_m && @max_m == rhs.max_m
76
78
  end
77
79
  alias == eql?
78
80
 
@@ -196,10 +198,10 @@ module RGeo
196
198
 
197
199
  def min_point
198
200
  if @min_x
199
- extras_ = []
200
- extras_ << @min_z if @has_z
201
- extras_ << @min_m if @has_m
202
- @factory.point(@min_x, @min_y, *extras_)
201
+ extras = []
202
+ extras << @min_z if @has_z
203
+ extras << @min_m if @has_m
204
+ @factory.point(@min_x, @min_y, *extras)
203
205
  end
204
206
  end
205
207
 
@@ -208,10 +210,10 @@ module RGeo
208
210
 
209
211
  def max_point
210
212
  if @min_x
211
- extras_ = []
212
- extras_ << @max_z if @has_z
213
- extras_ << @max_m if @has_m
214
- @factory.point(@max_x, @max_y, *extras_)
213
+ extras = []
214
+ extras << @max_z if @has_z
215
+ extras << @max_m if @has_m
216
+ @factory.point(@max_x, @max_y, *extras)
215
217
  end
216
218
  end
217
219
 
@@ -219,16 +221,16 @@ module RGeo
219
221
  # object, which may be a geometry or another bounding box.
220
222
  # Returns self.
221
223
 
222
- def add(geometry_)
223
- case geometry_
224
+ def add(geometry)
225
+ case geometry
224
226
  when BoundingBox
225
- add(geometry_.min_point)
226
- add(geometry_.max_point)
227
+ add(geometry.min_point)
228
+ add(geometry.max_point)
227
229
  when Feature::Geometry
228
- if geometry_.factory == @factory
229
- _add_geometry(geometry_)
230
+ if geometry.factory == @factory
231
+ add_geometry(geometry)
230
232
  else
231
- _add_geometry(Feature.cast(geometry_, @factory))
233
+ add_geometry(Feature.cast(geometry, @factory))
232
234
  end
233
235
  end
234
236
  self
@@ -241,23 +243,23 @@ module RGeo
241
243
 
242
244
  def to_geometry
243
245
  if @min_x
244
- extras_ = []
245
- extras_ << @min_z if @has_z
246
- extras_ << @min_m if @has_m
247
- point_min_ = @factory.point(@min_x, @min_y, *extras_)
246
+ extras = []
247
+ extras << @min_z if @has_z
248
+ extras << @min_m if @has_m
249
+ point_min = @factory.point(@min_x, @min_y, *extras)
248
250
  if infinitesimal?
249
- point_min_
251
+ point_min
250
252
  else
251
- extras_ = []
252
- extras_ << @max_z if @has_z
253
- extras_ << @max_m if @has_m
254
- point_max_ = @factory.point(@max_x, @max_y, *extras_)
253
+ extras = []
254
+ extras << @max_z if @has_z
255
+ extras << @max_m if @has_m
256
+ point_max = @factory.point(@max_x, @max_y, *extras)
255
257
  if degenerate?
256
- @factory.line(point_min_, point_max_)
258
+ @factory.line(point_min, point_max)
257
259
  else
258
- @factory.polygon(@factory.linear_ring([point_min_,
259
- @factory.point(@max_x, @min_y, *extras_), point_max_,
260
- @factory.point(@min_x, @max_y, *extras_), point_min_]))
260
+ @factory.polygon(@factory.linear_ring([point_min,
261
+ @factory.point(@max_x, @min_y, *extras), point_max,
262
+ @factory.point(@min_x, @max_y, *extras), point_min]))
261
263
  end
262
264
  end
263
265
  else
@@ -277,18 +279,18 @@ module RGeo
277
279
  # Ignore the M coordinate when testing, even if both objects
278
280
  # have M. Default is false.
279
281
 
280
- def contains?(rhs_, opts_ = {})
281
- if Feature::Geometry === rhs_
282
- contains?(BoundingBox.new(@factory).add(rhs_))
283
- elsif rhs_.empty?
282
+ def contains?(rhs, opts = {})
283
+ if Feature::Geometry === rhs
284
+ contains?(BoundingBox.new(@factory).add(rhs))
285
+ elsif rhs.empty?
284
286
  true
285
287
  elsif empty?
286
288
  false
287
- elsif @min_x > rhs_.min_x || @max_x < rhs_.max_x || @min_y > rhs_.min_y || @max_y < rhs_.max_y
289
+ elsif @min_x > rhs.min_x || @max_x < rhs.max_x || @min_y > rhs.min_y || @max_y < rhs.max_y
288
290
  false
289
- elsif @has_m && rhs_.has_m && !opts_[:ignore_m] && (@min_m > rhs_.min_m || @max_m < rhs_.max_m)
291
+ elsif @has_m && rhs.has_m && !opts[:ignore_m] && (@min_m > rhs.min_m || @max_m < rhs.max_m)
290
292
  false
291
- elsif @has_z && rhs_.has_z && !opts_[:ignore_z] && (@min_z > rhs_.min_z || @max_z < rhs_.max_z)
293
+ elsif @has_z && rhs.has_z && !opts[:ignore_z] && (@min_z > rhs.min_z || @max_z < rhs.max_z)
292
294
  false
293
295
  else
294
296
  true
@@ -309,7 +311,7 @@ module RGeo
309
311
  # greater than this factor, the bounding box is divided only in
310
312
  # half instead of fourths.
311
313
 
312
- def subdivide(opts_ = {})
314
+ def subdivide(opts = {})
313
315
  return [] if empty?
314
316
  if infinitesimal?
315
317
  return [
@@ -317,17 +319,17 @@ module RGeo
317
319
  @min_x, @max_x, @min_y, @max_y, @min_z, @max_z, @min_m, @max_m])
318
320
  ]
319
321
  end
320
- factor_ = opts_[:bisect_factor]
321
- factor_ ||= 1 if degenerate?
322
- if factor_
323
- if x_span > y_span * factor_
322
+ factor = opts[:bisect_factor]
323
+ factor ||= 1 if degenerate?
324
+ if factor
325
+ if x_span > y_span * factor
324
326
  return [
325
327
  BoundingBox.new(@factory, raw: [@has_z, @has_m,
326
328
  @min_x, center_x, @min_y, @max_y, @min_z, @max_z, @min_m, @max_m]),
327
329
  BoundingBox.new(@factory, raw: [@has_z, @has_m,
328
330
  center_x, @max_x, @min_y, @max_y, @min_z, @max_z, @min_m, @max_m])
329
331
  ]
330
- elsif y_span > x_span * factor_
332
+ elsif y_span > x_span * factor
331
333
  return [
332
334
  BoundingBox.new(@factory, raw: [@has_z, @has_m,
333
335
  @min_x, @max_x, @min_y, center_y, @min_z, @max_z, @min_m, @max_m]),
@@ -348,49 +350,51 @@ module RGeo
348
350
  ]
349
351
  end
350
352
 
351
- def _add_geometry(geometry_) # :nodoc:
352
- case geometry_
353
+ def add_geometry(geometry)
354
+ case geometry
353
355
  when Feature::Point
354
- _add_point(geometry_)
356
+ add_point(geometry)
355
357
  when Feature::LineString
356
- geometry_.points.each { |p_| _add_point(p_) }
358
+ geometry.points.each { |p| add_point(p) }
357
359
  when Feature::Polygon
358
- geometry_.exterior_ring.points.each { |p_| _add_point(p_) }
360
+ geometry.exterior_ring.points.each { |p| add_point(p) }
359
361
  when Feature::MultiPoint
360
- geometry_.each { |p_| _add_point(p_) }
362
+ geometry.each { |p| add_point(p) }
361
363
  when Feature::MultiLineString
362
- geometry_.each { |line_| line_.points.each { |p_| _add_point(p_) } }
364
+ geometry.each { |line| line.points.each { |p| add_point(p) } }
363
365
  when Feature::MultiPolygon
364
- geometry_.each { |poly_| poly_.exterior_ring.points.each { |p_| _add_point(p_) } }
366
+ geometry.each { |poly| poly.exterior_ring.points.each { |p| add_point(p) } }
365
367
  when Feature::GeometryCollection
366
- geometry_.each { |g_| _add_geometry(g_) }
368
+ geometry.each { |g| add_geometry(g) }
367
369
  end
368
370
  self
369
371
  end
370
372
 
371
- def _add_point(point_) # :nodoc:
373
+ private
374
+
375
+ def add_point(point)
372
376
  if @min_x
373
- x_ = point_.x
374
- @min_x = x_ if x_ < @min_x
375
- @max_x = x_ if x_ > @max_x
376
- y_ = point_.y
377
+ x = point.x
378
+ @min_x = x if x < @min_x
379
+ @max_x = x if x > @max_x
380
+ y_ = point.y
377
381
  @min_y = y_ if y_ < @min_y
378
382
  @max_y = y_ if y_ > @max_y
379
383
  if @has_z
380
- z_ = point_.z
384
+ z_ = point.z
381
385
  @min_z = z_ if z_ < @min_z
382
386
  @max_z = z_ if z_ > @max_z
383
387
  end
384
388
  if @has_m
385
- m_ = point_.m
389
+ m_ = point.m
386
390
  @min_m = m_ if m_ < @min_m
387
391
  @max_m = m_ if m_ > @max_m
388
392
  end
389
393
  else
390
- @min_x = @max_x = point_.x
391
- @min_y = @max_y = point_.y
392
- @min_z = @max_z = point_.z if @has_z
393
- @min_m = @max_m = point_.m if @has_m
394
+ @min_x = @max_x = point.x
395
+ @min_y = @max_y = point.y
396
+ @min_z = @max_z = point.z if @has_z
397
+ @min_m = @max_m = point.m if @has_m
394
398
  end
395
399
  end
396
400
  end