rgeo 2.3.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/README.md +23 -14
  4. data/ext/geos_c_impl/analysis.c +30 -25
  5. data/ext/geos_c_impl/analysis.h +8 -7
  6. data/ext/geos_c_impl/coordinates.c +27 -21
  7. data/ext/geos_c_impl/coordinates.h +5 -2
  8. data/ext/geos_c_impl/errors.c +19 -10
  9. data/ext/geos_c_impl/errors.h +11 -4
  10. data/ext/geos_c_impl/extconf.rb +42 -28
  11. data/ext/geos_c_impl/factory.c +540 -451
  12. data/ext/geos_c_impl/factory.h +105 -95
  13. data/ext/geos_c_impl/geometry.c +593 -387
  14. data/ext/geos_c_impl/geometry.h +10 -5
  15. data/ext/geos_c_impl/geometry_collection.c +306 -339
  16. data/ext/geos_c_impl/geometry_collection.h +6 -20
  17. data/ext/geos_c_impl/globals.c +169 -0
  18. data/ext/geos_c_impl/globals.h +46 -0
  19. data/ext/geos_c_impl/line_string.c +271 -231
  20. data/ext/geos_c_impl/line_string.h +5 -8
  21. data/ext/geos_c_impl/main.c +16 -16
  22. data/ext/geos_c_impl/point.c +65 -67
  23. data/ext/geos_c_impl/point.h +4 -7
  24. data/ext/geos_c_impl/polygon.c +137 -135
  25. data/ext/geos_c_impl/polygon.h +11 -11
  26. data/ext/geos_c_impl/preface.h +16 -10
  27. data/ext/geos_c_impl/ruby_more.c +67 -0
  28. data/ext/geos_c_impl/ruby_more.h +25 -0
  29. data/lib/rgeo/cartesian/analysis.rb +5 -3
  30. data/lib/rgeo/cartesian/bounding_box.rb +74 -79
  31. data/lib/rgeo/cartesian/calculations.rb +64 -33
  32. data/lib/rgeo/cartesian/factory.rb +57 -102
  33. data/lib/rgeo/cartesian/feature_classes.rb +68 -46
  34. data/lib/rgeo/cartesian/feature_methods.rb +67 -25
  35. data/lib/rgeo/cartesian/interface.rb +6 -41
  36. data/lib/rgeo/cartesian/planar_graph.rb +373 -0
  37. data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
  38. data/lib/rgeo/cartesian/valid_op.rb +69 -0
  39. data/lib/rgeo/cartesian.rb +3 -0
  40. data/lib/rgeo/coord_sys/cs/entities.rb +303 -99
  41. data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
  42. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
  43. data/lib/rgeo/coord_sys.rb +1 -20
  44. data/lib/rgeo/error.rb +15 -0
  45. data/lib/rgeo/feature/curve.rb +0 -11
  46. data/lib/rgeo/feature/factory.rb +26 -36
  47. data/lib/rgeo/feature/factory_generator.rb +6 -14
  48. data/lib/rgeo/feature/geometry.rb +146 -66
  49. data/lib/rgeo/feature/geometry_collection.rb +16 -9
  50. data/lib/rgeo/feature/line_string.rb +4 -5
  51. data/lib/rgeo/feature/linear_ring.rb +0 -1
  52. data/lib/rgeo/feature/multi_curve.rb +0 -6
  53. data/lib/rgeo/feature/multi_surface.rb +3 -4
  54. data/lib/rgeo/feature/point.rb +4 -5
  55. data/lib/rgeo/feature/polygon.rb +1 -2
  56. data/lib/rgeo/feature/surface.rb +3 -4
  57. data/lib/rgeo/feature/types.rb +69 -85
  58. data/lib/rgeo/geographic/factory.rb +98 -125
  59. data/lib/rgeo/geographic/interface.rb +69 -166
  60. data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
  61. data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
  62. data/lib/rgeo/geographic/projected_window.rb +36 -22
  63. data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
  64. data/lib/rgeo/geographic/simple_mercator_projector.rb +26 -25
  65. data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
  66. data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
  67. data/lib/rgeo/geographic/spherical_math.rb +17 -20
  68. data/lib/rgeo/geographic.rb +1 -1
  69. data/lib/rgeo/geos/capi_factory.rb +87 -158
  70. data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
  71. data/lib/rgeo/geos/ffi_factory.rb +105 -173
  72. data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
  73. data/lib/rgeo/geos/ffi_feature_methods.rb +105 -127
  74. data/lib/rgeo/geos/interface.rb +20 -59
  75. data/lib/rgeo/geos/utils.rb +5 -5
  76. data/lib/rgeo/geos/zm_factory.rb +53 -95
  77. data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
  78. data/lib/rgeo/geos.rb +8 -8
  79. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
  80. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
  81. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
  82. data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
  83. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
  84. data/lib/rgeo/impl_helper/utils.rb +21 -0
  85. data/lib/rgeo/impl_helper/valid_op.rb +350 -0
  86. data/lib/rgeo/impl_helper/validity_check.rb +139 -0
  87. data/lib/rgeo/impl_helper.rb +1 -0
  88. data/lib/rgeo/version.rb +1 -1
  89. data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
  90. data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
  91. data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
  92. data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
  93. data/lib/rgeo.rb +1 -3
  94. metadata +50 -13
  95. data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
  96. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
  97. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -19,29 +19,48 @@ module RGeo
19
19
  end
20
20
 
21
21
  def envelope
22
- factory.unproject(projection.envelope)
22
+ factory.unproject(projection.unsafe_envelope)
23
23
  end
24
24
 
25
- def empty?
26
- projection.empty?
25
+ def coordinate_dimension
26
+ factory.coordinate_dimension
27
+ end
28
+
29
+ def spatial_dimension
30
+ factory.spatial_dimension
31
+ end
32
+
33
+ def is_3d?
34
+ factory.property(:has_z_coordinate)
35
+ end
36
+
37
+ def measured?
38
+ factory.property(:has_m_coordinate)
27
39
  end
28
40
 
29
- def is_empty?
30
- warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
31
- empty?
41
+ def empty?
42
+ projection.empty?
32
43
  end
33
44
 
34
45
  def simple?
35
46
  projection.simple?
36
47
  end
37
48
 
38
- def is_simple?
39
- warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
40
- simple?
49
+ def valid?
50
+ projection.valid?
51
+ end
52
+
53
+ def invalid_reason
54
+ projection.invalid_reason
55
+ end
56
+
57
+ # (see RGeo::ImplHelper::ValidityCheck#make_valid)
58
+ def make_valid
59
+ factory.unproject projection.make_valid
41
60
  end
42
61
 
43
62
  def boundary
44
- boundary = projection.boundary
63
+ boundary = projection.unsafe_boundary
45
64
  boundary ? factory.unproject(boundary) : nil
46
65
  end
47
66
 
@@ -50,79 +69,79 @@ module RGeo
50
69
  end
51
70
 
52
71
  def disjoint?(rhs)
53
- projection.disjoint?(Feature.cast(rhs, factory).projection)
72
+ projection.unsafe_disjoint?(Feature.cast(rhs, factory).projection)
54
73
  end
55
74
 
56
75
  def intersects?(rhs)
57
- projection.intersects?(Feature.cast(rhs, factory).projection)
76
+ projection.unsafe_intersects?(Feature.cast(rhs, factory).projection)
58
77
  end
59
78
 
60
79
  def touches?(rhs)
61
- projection.touches?(Feature.cast(rhs, factory).projection)
80
+ projection.unsafe_touches?(Feature.cast(rhs, factory).projection)
62
81
  end
63
82
 
64
83
  def crosses?(rhs)
65
- projection.crosses?(Feature.cast(rhs, factory).projection)
84
+ projection.unsafe_crosses?(Feature.cast(rhs, factory).projection)
66
85
  end
67
86
 
68
87
  def within?(rhs)
69
- projection.within?(Feature.cast(rhs, factory).projection)
88
+ projection.unsafe_within?(Feature.cast(rhs, factory).projection)
70
89
  end
71
90
 
72
91
  def contains?(rhs)
73
- projection.contains?(Feature.cast(rhs, factory).projection)
92
+ projection.unsafe_contains?(Feature.cast(rhs, factory).projection)
74
93
  end
75
94
 
76
95
  def overlaps?(rhs)
77
- projection.overlaps?(Feature.cast(rhs, factory).projection)
96
+ projection.unsafe_overlaps?(Feature.cast(rhs, factory).projection)
78
97
  end
79
98
 
80
99
  def relate(rhs, pattern_)
81
- projection.relate(Feature.cast(rhs, factory).projection, pattern_)
100
+ projection.unsafe_relate(Feature.cast(rhs, factory).projection, pattern_)
82
101
  end
83
102
 
84
103
  def distance(rhs)
85
- projection.distance(Feature.cast(rhs, factory).projection)
104
+ projection.unsafe_distance(Feature.cast(rhs, factory).projection)
86
105
  end
87
106
 
88
107
  def buffer(distance)
89
- factory.unproject(projection.buffer(distance))
108
+ factory.unproject(projection.unsafe_buffer(distance))
90
109
  end
91
110
 
92
111
  def buffer_with_style(distance, end_cap_style, join_style, mitre_limit)
93
- factory.unproject(projection.buffer_with_style(distance, end_cap_style, join_style, mitre_limit))
112
+ factory.unproject(projection.unsafe_buffer_with_style(distance, end_cap_style, join_style, mitre_limit))
94
113
  end
95
114
 
96
115
  def simplify(tolerance)
97
- factory.unproject(projection.simplify(tolerance))
116
+ factory.unproject(projection.unsafe_simplify(tolerance))
98
117
  end
99
118
 
100
119
  def simplify_preserve_topology(tolerance)
101
- factory.unproject(projection.simplify_preserve_topology(tolerance))
120
+ factory.unproject(projection.unsafe_simplify_preserve_topology(tolerance))
102
121
  end
103
122
 
104
123
  def convex_hull
105
- factory.unproject(projection.convex_hull)
124
+ factory.unproject(projection.unsafe_convex_hull)
106
125
  end
107
126
 
108
127
  def intersection(rhs)
109
- factory.unproject(projection.intersection(Feature.cast(rhs, factory).projection))
128
+ factory.unproject(projection.unsafe_intersection(Feature.cast(rhs, factory).projection))
110
129
  end
111
130
 
112
131
  def union(rhs)
113
- factory.unproject(projection.union(Feature.cast(rhs, factory).projection))
132
+ factory.unproject(projection.unsafe_union(Feature.cast(rhs, factory).projection))
114
133
  end
115
134
 
116
135
  def difference(rhs)
117
- factory.unproject(projection.difference(Feature.cast(rhs, factory).projection))
136
+ factory.unproject(projection.unsafe_difference(Feature.cast(rhs, factory).projection))
118
137
  end
119
138
 
120
139
  def sym_difference(rhs)
121
- factory.unproject(projection.sym_difference(Feature.cast(rhs, factory).projection))
140
+ factory.unproject(projection.unsafe_sym_difference(Feature.cast(rhs, factory).projection))
122
141
  end
123
142
 
124
143
  def point_on_surface
125
- factory.unproject(projection.point_on_surface)
144
+ factory.unproject(projection.unsafe_point_on_surface)
126
145
  end
127
146
  end
128
147
 
@@ -154,7 +173,8 @@ module RGeo
154
173
 
155
174
  private
156
175
 
157
- def validate_geometry
176
+ # Ensure coordinates fall within a valid range.
177
+ def init_geometry
158
178
  @y = 85.0511287 if @y > 85.0511287
159
179
  @y = -85.0511287 if @y < -85.0511287
160
180
  super
@@ -163,48 +183,53 @@ module RGeo
163
183
 
164
184
  module ProjectedNCurveMethods # :nodoc:
165
185
  def length
166
- projection.length
186
+ projection.unsafe_length
167
187
  end
168
188
  end
169
189
 
170
190
  module ProjectedLineStringMethods # :nodoc:
171
191
  private
172
192
 
173
- def validate_geometry
193
+ # Ensure coordinates fall within a valid range.
194
+ def init_geometry
174
195
  @points = @points.map(&:canonical_point)
175
196
  super
176
197
  end
177
198
  end
178
199
 
200
+ module ProjectedLinearRingMethods # :nodoc:
201
+ def simple?
202
+ projection.valid?
203
+ end
204
+ end
205
+
179
206
  module ProjectedNSurfaceMethods # :nodoc:
180
207
  def area
181
- projection.area
208
+ projection.unsafe_area
182
209
  end
183
210
 
184
211
  def centroid
185
- factory.unproject(projection.centroid)
212
+ factory.unproject(projection.unsafe_centroid)
186
213
  end
187
214
  end
188
215
 
189
216
  module ProjectedPolygonMethods # :nodoc:
190
217
  private
191
218
 
192
- def validate_geometry
219
+ # Ensure projection is available.
220
+ def init_geometry
193
221
  super
194
- unless projection
195
- raise Error::InvalidGeometry, "Polygon failed assertions"
196
- end
222
+ raise Error::InvalidGeometry, "Polygon failed assertions" unless projection
197
223
  end
198
224
  end
199
225
 
200
226
  module ProjectedMultiPolygonMethods # :nodoc:
201
227
  private
202
228
 
203
- def validate_geometry
229
+ # Ensure projection is available.
230
+ def init_geometry
204
231
  super
205
- unless projection
206
- raise Error::InvalidGeometry, "MultiPolygon failed assertions"
207
- end
232
+ raise Error::InvalidGeometry, "MultiPolygon failed assertions" unless projection
208
233
  end
209
234
  end
210
235
  end
@@ -13,7 +13,6 @@ module RGeo
13
13
  # map visualization, an envelope in a projected coordinate system, or
14
14
  # a spatial constraint. It must be attached to a Geographic::Factory
15
15
  # that has a projection.
16
-
17
16
  class ProjectedWindow
18
17
  # Create a new ProjectedWindow given the Geographic::Factory, and the
19
18
  # x and y extents of the rectangle.
@@ -64,38 +63,33 @@ module RGeo
64
63
  to_s
65
64
  end
66
65
 
67
- def eql?(obj_) # :nodoc:
68
- return false unless obj_.is_a?(ProjectedWindow)
69
- @factory == obj_.factory && @x_min == obj_.x_min && @x_max == obj_.x_max &&
70
- @y_min = obj_.y_min && @y_max = obj_.y_max
66
+ def eql?(other) # :nodoc:
67
+ return false unless other.is_a?(ProjectedWindow)
68
+ @factory == other.factory && @x_min == other.x_min && @x_max == other.x_max &&
69
+ @y_min = other.y_min && @y_max = other.y_max
71
70
  end
72
71
  alias == eql?
73
72
 
74
73
  def hash # :nodoc:
75
- @factory.hash + @x_min.hash + @x_max.hash + @y_min.hash + @y_max.hash
74
+ [@factory, @x_min, @x_max, @y_min, @y_max].hash
76
75
  end
77
76
 
78
77
  # Returns the Geographic::Factory associated with this window.
79
78
  # Note that this factory is the overall geography factory, not the
80
79
  # projected factory (which can be obtained by calling
81
80
  # Geographic::Factory#projection_factory on this factory).
82
-
83
81
  attr_reader :factory
84
82
 
85
83
  # Returns the lower limit in the x (easting) direction.
86
-
87
84
  attr_reader :x_min
88
85
 
89
86
  # Returns the upper limit in the x (easting) direction.
90
-
91
87
  attr_reader :x_max
92
88
 
93
89
  # Returns the lower limit in the y (northing) direction.
94
-
95
90
  attr_reader :y_min
96
91
 
97
92
  # Returns the upper limit in the y (northing) direction.
98
-
99
93
  attr_reader :y_max
100
94
 
101
95
  # Returns true if the projection wraps along the x axis, and this
@@ -146,35 +140,45 @@ module RGeo
146
140
  # (lat/lng) space, as a Feature::Point object.
147
141
 
148
142
  def sw_point
149
- @sw ||= @factory.unproject(@factory.projection_factory.point(@x_min, @y_min))
143
+ return @sw_point if defined?(@sw_point)
144
+
145
+ @sw_point = @factory.unproject(@factory.projection_factory.point(@x_min, @y_min))
150
146
  end
151
147
 
152
148
  # Returns the southeast corner of the rectangle in _unprojected_
153
149
  # (lat/lng) space, as a Feature::Point object.
154
150
 
155
151
  def se_point
156
- @se ||= @factory.unproject(@factory.projection_factory.point(@x_max, @y_min))
152
+ return @se_point if defined?(@se_point)
153
+
154
+ @se_point = @factory.unproject(@factory.projection_factory.point(@x_max, @y_min))
157
155
  end
158
156
 
159
157
  # Returns the northwest corner of the rectangle in _unprojected_
160
158
  # (lat/lng) space, as a Feature::Point object.
161
159
 
162
160
  def nw_point
163
- @nw ||= @factory.unproject(@factory.projection_factory.point(@x_min, @y_max))
161
+ return @nw_point if defined?(@nw_point)
162
+
163
+ @nw_point = @factory.unproject(@factory.projection_factory.point(@x_min, @y_max))
164
164
  end
165
165
 
166
166
  # Returns the northeast corner of the rectangle in _unprojected_
167
167
  # (lat/lng) space, as a Feature::Point object.
168
168
 
169
169
  def ne_point
170
- @ne ||= @factory.unproject(@factory.projection_factory.point(@x_max, @y_max))
170
+ return @ne_point if defined?(@ne_point)
171
+
172
+ @ne_point = @factory.unproject(@factory.projection_factory.point(@x_max, @y_max))
171
173
  end
172
174
 
173
175
  # Returns the center of the rectangle in _unprojected_
174
176
  # (lat/lng) space, as a Feature::Point object.
175
177
 
176
178
  def center_point
177
- @center ||= @factory.unproject(@factory.projection_factory.point(*center_xy))
179
+ return @center_point if defined?(@center_point)
180
+
181
+ @center_point = @factory.unproject(@factory.projection_factory.point(*center_xy))
178
182
  end
179
183
 
180
184
  # Returns a random point inside the rectangle in _unprojected_
@@ -233,7 +237,7 @@ module RGeo
233
237
 
234
238
  def scaled_by(x_factor_, y_factor_ = nil)
235
239
  y_factor_ ||= x_factor_
236
- if x_factor_ != 1.0 || y_factor_ != 1.0
240
+ if x_factor_ != 1 || y_factor_ != 1
237
241
  x_, y_ = *center_xy
238
242
  xr_ = x_span * 0.5 * x_factor_
239
243
  yr_ = y_span * 0.5 * y_factor_
@@ -287,9 +291,14 @@ module RGeo
287
291
 
288
292
  def with_margin(x_margin_, y_margin_ = nil)
289
293
  y_margin_ ||= x_margin_
290
- if x_margin_ != 0.0 || y_margin_ != 0.0
291
- ProjectedWindow.new(@factory, @x_min - x_margin_, @y_min - y_margin_,
292
- @x_max + x_margin_, @y_max + y_margin_)
294
+ if x_margin_ != 0 || y_margin_ != 0
295
+ ProjectedWindow.new(
296
+ @factory,
297
+ @x_min - x_margin_,
298
+ @y_min - y_margin_,
299
+ @x_max + x_margin_,
300
+ @y_max + y_margin_
301
+ )
293
302
  else
294
303
  self
295
304
  end
@@ -318,8 +327,13 @@ module RGeo
318
327
  y_margin_ ||= x_margin_
319
328
  factory_ = point_.factory
320
329
  projection_ = factory_.project(point_)
321
- ProjectedWindow.new(factory_, projection_.x - x_margin_, projection_.y - y_margin_,
322
- projection_.x + x_margin_, projection_.y + y_margin_)
330
+ ProjectedWindow.new(
331
+ factory_,
332
+ projection_.x - x_margin_,
333
+ projection_.y - y_margin_,
334
+ projection_.x + x_margin_,
335
+ projection_.y + y_margin_
336
+ )
323
337
  end
324
338
 
325
339
  # Creates a new window that contains all of the given points.
@@ -8,7 +8,7 @@
8
8
 
9
9
  module RGeo
10
10
  module Geographic
11
- class Proj4Projector # :nodoc:
11
+ class Projector # :nodoc:
12
12
  def initialize(geography_factory, projection_factory)
13
13
  @geography_factory = geography_factory
14
14
  @projection_factory = projection_factory
@@ -42,14 +42,12 @@ module RGeo
42
42
  new(geography_factory, projection_factory)
43
43
  end
44
44
 
45
- def create_from_proj4(geography_factory, proj4, opts = {})
45
+ def create_from_opts(geography_factory, opts = {})
46
46
  projection_factory =
47
47
  Cartesian.preferred_factory(
48
- proj4: proj4,
49
48
  coord_sys: opts[:coord_sys], srid: opts[:srid],
49
+ coord_sys_class: opts[:coord_sys_class],
50
50
  buffer_resolution: opts[:buffer_resolution],
51
- lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
52
- uses_lenient_assertions: opts[:uses_lenient_assertions],
53
51
  has_z_coordinate: opts[:has_z_coordinate],
54
52
  has_m_coordinate: opts[:has_m_coordinate],
55
53
  wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
@@ -14,11 +14,8 @@ module RGeo
14
14
  def initialize(geography_factory, opts = {})
15
15
  @geography_factory = geography_factory
16
16
  @projection_factory = Cartesian.preferred_factory(srid: 3857,
17
- proj4: SimpleMercatorProjector._proj4_3857,
18
- coord_sys: SimpleMercatorProjector._coordsys_3857,
17
+ coord_sys: SimpleMercatorProjector._coordsys3857,
19
18
  buffer_resolution: opts[:buffer_resolution],
20
- lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
21
- uses_lenient_assertions: opts[:uses_lenient_assertions],
22
19
  has_z_coordinate: opts[:has_z_coordinate],
23
20
  has_m_coordinate: opts[:has_m_coordinate])
24
21
  end
@@ -35,8 +32,10 @@ module RGeo
35
32
  when Feature::Point
36
33
  rpd_ = ImplHelper::Math::RADIANS_PER_DEGREE
37
34
  radius = EQUATORIAL_RADIUS
38
- @projection_factory.point(geometry.x * rpd_ * radius,
39
- Math.log(Math.tan(Math::PI / 4.0 + geometry.y * rpd_ / 2.0)) * radius)
35
+ @projection_factory.point(
36
+ geometry.x * rpd_ * radius,
37
+ Math.log(Math.tan(Math::PI / 4.0 + geometry.y * rpd_ / 2.0)) * radius
38
+ )
40
39
  when Feature::Line
41
40
  @projection_factory.line(project(geometry.start_point), project(geometry.end_point))
42
41
  when Feature::LinearRing
@@ -62,8 +61,10 @@ module RGeo
62
61
  when Feature::Point
63
62
  dpr = ImplHelper::Math::DEGREES_PER_RADIAN
64
63
  radius = EQUATORIAL_RADIUS
65
- @geography_factory.point(geometry.x / radius * dpr,
66
- (2.0 * Math.atan(Math.exp(geometry.y / radius)) - Math::PI / 2.0) * dpr)
64
+ @geography_factory.point(
65
+ geometry.x / radius * dpr,
66
+ (2.0 * Math.atan(Math.exp(geometry.y / radius)) - Math::PI / 2.0) * dpr
67
+ )
67
68
  when Feature::Line
68
69
  @geography_factory.line(unproject(geometry.start_point), unproject(geometry.end_point))
69
70
  when Feature::LinearRing
@@ -71,8 +72,10 @@ module RGeo
71
72
  when Feature::LineString
72
73
  @geography_factory.line_string(geometry.points.map { |p| unproject(p) })
73
74
  when Feature::Polygon
74
- @geography_factory.polygon(unproject(geometry.exterior_ring),
75
- geometry.interior_rings.map { |p| unproject(p) })
75
+ @geography_factory.polygon(
76
+ unproject(geometry.exterior_ring),
77
+ geometry.interior_rings.map { |p| unproject(p) }
78
+ )
76
79
  when Feature::MultiPoint
77
80
  @geography_factory.multi_point(geometry.map { |p| unproject(p) })
78
81
  when Feature::MultiLineString
@@ -89,24 +92,22 @@ module RGeo
89
92
  end
90
93
 
91
94
  def limits_window
92
- @limits_window ||= ProjectedWindow.new(@geography_factory,
93
- -20_037_508.342789, -20_037_508.342789, 20_037_508.342789, 20_037_508.342789,
94
- is_limits: true)
95
- end
95
+ return @limits_window if defined?(@limits_window)
96
96
 
97
- def self._proj4_3857 # :nodoc:
98
- return unless CoordSys.supported?(:proj4)
99
- unless defined?(@proj4_3857)
100
- @proj4_3857 = CoordSys::Proj4.create("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")
101
- end
102
- @proj4_3857
97
+ @limits_window = ProjectedWindow.new(
98
+ @geography_factory,
99
+ -20_037_508.342789,
100
+ -20_037_508.342789,
101
+ 20_037_508.342789,
102
+ 20_037_508.342789,
103
+ is_limits: true
104
+ )
103
105
  end
104
106
 
105
- def self._coordsys_3857 # :nodoc:
106
- unless defined?(@coordsys_3857)
107
- @coordsys_3857 = CoordSys::CS.create_from_wkt('PROJCS["Popular Visualisation CRS / Mercator",GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","3785"],AXIS["X",EAST],AXIS["Y",NORTH]]')
108
- end
109
- @coordsys_3857
107
+ def self._coordsys3857 # :nodoc:
108
+ return @coordsys3857 if defined?(@coordsys3857)
109
+
110
+ @coordsys3857 = CoordSys::CONFIG.default_coord_sys_class.create(3857)
110
111
  end
111
112
  end
112
113
  end
@@ -8,78 +8,98 @@
8
8
 
9
9
  module RGeo
10
10
  module Geographic
11
- class SphericalPointImpl # :nodoc:
11
+ class SphericalPointImpl
12
12
  include Feature::Point
13
+ include ImplHelper::ValidityCheck
13
14
  include ImplHelper::BasicGeometryMethods
14
15
  include ImplHelper::BasicPointMethods
16
+ include ImplHelper::ValidOp
15
17
  include SphericalGeometryMethods
16
18
  include SphericalPointMethods
17
19
  end
18
20
 
19
- class SphericalLineStringImpl # :nodoc:
21
+ class SphericalLineStringImpl
20
22
  include Feature::LineString
23
+ include ImplHelper::ValidityCheck
21
24
  include ImplHelper::BasicGeometryMethods
22
25
  include ImplHelper::BasicLineStringMethods
26
+ include ImplHelper::ValidOp
23
27
  include SphericalGeometryMethods
24
28
  include SphericalLineStringMethods
25
29
  end
26
30
 
27
- class SphericalLineImpl # :nodoc:
31
+ class SphericalLineImpl
28
32
  include Feature::Line
33
+ include ImplHelper::ValidityCheck
29
34
  include ImplHelper::BasicGeometryMethods
30
35
  include ImplHelper::BasicLineStringMethods
31
36
  include ImplHelper::BasicLineMethods
37
+ include ImplHelper::ValidOp
32
38
  include SphericalGeometryMethods
33
39
  include SphericalLineStringMethods
34
40
  end
35
41
 
36
- class SphericalLinearRingImpl # :nodoc:
42
+ class SphericalLinearRingImpl
37
43
  include Feature::LinearRing
44
+ include ImplHelper::ValidityCheck
38
45
  include ImplHelper::BasicGeometryMethods
39
46
  include ImplHelper::BasicLineStringMethods
40
47
  include ImplHelper::BasicLinearRingMethods
48
+ include ImplHelper::ValidOp
41
49
  include SphericalGeometryMethods
42
50
  include SphericalLineStringMethods
43
51
  end
44
52
 
45
- class SphericalPolygonImpl # :nodoc:
53
+ class SphericalPolygonImpl
46
54
  include Feature::Polygon
55
+ include ImplHelper::ValidityCheck
47
56
  include ImplHelper::BasicGeometryMethods
48
57
  include ImplHelper::BasicPolygonMethods
58
+ include ImplHelper::ValidOp
49
59
  include SphericalGeometryMethods
50
60
  include SphericalPolygonMethods
51
61
  end
52
62
 
53
- class SphericalGeometryCollectionImpl # :nodoc:
63
+ class SphericalGeometryCollectionImpl
54
64
  include Feature::GeometryCollection
65
+ include ImplHelper::ValidityCheck
55
66
  include ImplHelper::BasicGeometryMethods
56
67
  include ImplHelper::BasicGeometryCollectionMethods
68
+ include ImplHelper::ValidOp
57
69
  include SphericalGeometryMethods
58
70
  end
59
71
 
60
- class SphericalMultiPointImpl # :nodoc:
72
+ class SphericalMultiPointImpl
61
73
  include Feature::MultiPoint
74
+ include ImplHelper::ValidityCheck
62
75
  include ImplHelper::BasicGeometryMethods
63
76
  include ImplHelper::BasicGeometryCollectionMethods
64
77
  include ImplHelper::BasicMultiPointMethods
78
+ include ImplHelper::ValidOp
65
79
  include SphericalGeometryMethods
66
80
  end
67
81
 
68
- class SphericalMultiLineStringImpl # :nodoc:
82
+ class SphericalMultiLineStringImpl
69
83
  include Feature::MultiLineString
84
+ include ImplHelper::ValidityCheck
70
85
  include ImplHelper::BasicGeometryMethods
71
86
  include ImplHelper::BasicGeometryCollectionMethods
72
87
  include ImplHelper::BasicMultiLineStringMethods
88
+ include ImplHelper::ValidOp
73
89
  include SphericalGeometryMethods
74
90
  include SphericalMultiLineStringMethods
75
91
  end
76
92
 
77
- class SphericalMultiPolygonImpl # :nodoc:
93
+ class SphericalMultiPolygonImpl
78
94
  include Feature::MultiPolygon
95
+ include ImplHelper::ValidityCheck
79
96
  include ImplHelper::BasicGeometryMethods
80
97
  include ImplHelper::BasicGeometryCollectionMethods
81
98
  include ImplHelper::BasicMultiPolygonMethods
99
+ include ImplHelper::ValidOp
82
100
  include SphericalGeometryMethods
83
101
  end
102
+
103
+ ImplHelper::ValidityCheck.override_classes
84
104
  end
85
105
  end