rgeo 3.0.0.pre.rc.2 → 3.0.0.pre.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/geos_c_impl/analysis.c +26 -23
  4. data/ext/geos_c_impl/analysis.h +8 -5
  5. data/ext/geos_c_impl/coordinates.c +27 -21
  6. data/ext/geos_c_impl/coordinates.h +5 -2
  7. data/ext/geos_c_impl/errors.c +15 -8
  8. data/ext/geos_c_impl/errors.h +4 -1
  9. data/ext/geos_c_impl/extconf.rb +40 -30
  10. data/ext/geos_c_impl/factory.c +367 -387
  11. data/ext/geos_c_impl/factory.h +59 -48
  12. data/ext/geos_c_impl/geometry.c +368 -320
  13. data/ext/geos_c_impl/geometry.h +5 -5
  14. data/ext/geos_c_impl/geometry_collection.c +256 -183
  15. data/ext/geos_c_impl/geometry_collection.h +6 -7
  16. data/ext/geos_c_impl/globals.c +99 -21
  17. data/ext/geos_c_impl/globals.h +3 -2
  18. data/ext/geos_c_impl/line_string.c +229 -198
  19. data/ext/geos_c_impl/line_string.h +5 -6
  20. data/ext/geos_c_impl/main.c +8 -9
  21. data/ext/geos_c_impl/point.c +62 -63
  22. data/ext/geos_c_impl/point.h +4 -5
  23. data/ext/geos_c_impl/polygon.c +116 -84
  24. data/ext/geos_c_impl/polygon.h +10 -8
  25. data/ext/geos_c_impl/preface.h +4 -13
  26. data/ext/geos_c_impl/ruby_more.c +35 -40
  27. data/ext/geos_c_impl/ruby_more.h +3 -2
  28. data/lib/rgeo/cartesian/bounding_box.rb +1 -1
  29. data/lib/rgeo/cartesian/factory.rb +8 -43
  30. data/lib/rgeo/cartesian/feature_methods.rb +0 -5
  31. data/lib/rgeo/cartesian/interface.rb +6 -5
  32. data/lib/rgeo/coord_sys/cs/entities.rb +214 -0
  33. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +15 -8
  34. data/lib/rgeo/coord_sys.rb +1 -9
  35. data/lib/rgeo/feature/curve.rb +0 -10
  36. data/lib/rgeo/feature/factory.rb +1 -9
  37. data/lib/rgeo/feature/factory_generator.rb +3 -7
  38. data/lib/rgeo/feature/geometry.rb +0 -10
  39. data/lib/rgeo/feature/multi_curve.rb +0 -5
  40. data/lib/rgeo/feature/types.rb +5 -5
  41. data/lib/rgeo/geographic/factory.rb +9 -42
  42. data/lib/rgeo/geographic/interface.rb +28 -99
  43. data/lib/rgeo/geographic/projected_feature_methods.rb +0 -10
  44. data/lib/rgeo/geographic/projected_window.rb +1 -1
  45. data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -3
  46. data/lib/rgeo/geographic/simple_mercator_projector.rb +1 -10
  47. data/lib/rgeo/geographic/spherical_feature_methods.rb +0 -5
  48. data/lib/rgeo/geographic.rb +1 -1
  49. data/lib/rgeo/geos/capi_factory.rb +37 -91
  50. data/lib/rgeo/geos/capi_feature_classes.rb +0 -29
  51. data/lib/rgeo/geos/ffi_factory.rb +52 -92
  52. data/lib/rgeo/geos/ffi_feature_methods.rb +1 -31
  53. data/lib/rgeo/geos/interface.rb +5 -20
  54. data/lib/rgeo/geos/zm_factory.rb +5 -36
  55. data/lib/rgeo/geos/zm_feature_methods.rb +1 -26
  56. data/lib/rgeo/geos.rb +2 -5
  57. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +1 -14
  58. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -19
  59. data/lib/rgeo/impl_helper/basic_point_methods.rb +0 -10
  60. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +1 -9
  61. data/lib/rgeo/impl_helper/utils.rb +27 -0
  62. data/lib/rgeo/impl_helper/validity_check.rb +3 -3
  63. data/lib/rgeo/version.rb +1 -1
  64. data/lib/rgeo/wkrep/wkb_generator.rb +68 -53
  65. data/lib/rgeo/wkrep/wkb_parser.rb +19 -16
  66. data/lib/rgeo/wkrep/wkt_generator.rb +34 -34
  67. data/lib/rgeo/wkrep/wkt_parser.rb +26 -23
  68. data/lib/rgeo.rb +1 -3
  69. metadata +7 -6
@@ -20,83 +20,64 @@ module RGeo
20
20
  #
21
21
  # See RGeo::Geos.factory for a list of supported options.
22
22
 
23
- def create(opts_ = {})
23
+ def create(opts = {})
24
24
  # Make sure GEOS is available
25
25
  return unless respond_to?(:_create)
26
26
 
27
27
  # Get flags to pass to the C extension
28
28
  flags = 0
29
- flags |= 2 if opts_[:has_z_coordinate]
30
- flags |= 4 if opts_[:has_m_coordinate]
29
+ flags |= 2 if opts[:has_z_coordinate]
30
+ flags |= 4 if opts[:has_m_coordinate]
31
31
  if flags & 6 == 6
32
32
  raise Error::UnsupportedOperation, "GEOS cannot support both Z and M coordinates at the same time."
33
33
  end
34
- flags |= 8 unless opts_[:auto_prepare] == :disabled
34
+ flags |= 8 unless opts[:auto_prepare] == :disabled
35
35
 
36
36
  # Buffer resolution
37
- buffer_resolution_ = opts_[:buffer_resolution].to_i
38
- buffer_resolution_ = 1 if buffer_resolution_ < 1
37
+ buffer_resolution = opts[:buffer_resolution].to_i
38
+ buffer_resolution = 1 if buffer_resolution < 1
39
39
 
40
40
  # Interpret the generator options
41
- wkt_generator_ = opts_[:wkt_generator]
42
- case wkt_generator_
43
- when :geos
44
- wkt_generator_ = nil
41
+ wkt_generator = opts[:wkt_generator]
42
+ case wkt_generator
45
43
  when Hash
46
- wkt_generator_ = WKRep::WKTGenerator.new(wkt_generator_)
44
+ wkt_generator = WKRep::WKTGenerator.new(wkt_generator)
47
45
  else
48
- wkt_generator_ = WKRep::WKTGenerator.new(convert_case: :upper)
46
+ wkt_generator = nil
49
47
  end
50
- wkb_generator_ = opts_[:wkb_generator]
51
- case wkb_generator_
52
- when :geos
53
- wkb_generator_ = nil
48
+ wkb_generator = opts[:wkb_generator]
49
+ case wkb_generator
54
50
  when Hash
55
- wkb_generator_ = WKRep::WKBGenerator.new(wkb_generator_)
51
+ wkb_generator = WKRep::WKBGenerator.new(wkb_generator)
56
52
  else
57
- wkb_generator_ = WKRep::WKBGenerator.new
53
+ wkb_generator = nil
58
54
  end
59
55
 
60
- # Coordinate system (srid, proj4, and coord_sys)
61
- srid_ = opts_[:srid]
62
- proj4_ = opts_[:proj4]
63
- if proj4_ && CoordSys.check!(:proj4)
64
- if proj4_.is_a?(String) || proj4_.is_a?(Hash)
65
- proj4_ = CoordSys::Proj4.create(proj4_)
66
- end
67
- else
68
- proj4_ = nil
69
- end
70
- coord_sys_ = opts_[:coord_sys]
71
- if coord_sys_.is_a?(String)
72
- coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_)
73
- end
74
- srid_ ||= coord_sys_.authority_code if coord_sys_
56
+ # Coordinate system (srid and coord_sys)
57
+ coord_sys_info = ImplHelper::Utils.setup_coord_sys(opts[:srid], opts[:coord_sys], opts[:coord_sys_class])
58
+ srid = coord_sys_info[:srid]
59
+ coord_sys = coord_sys_info[:coord_sys]
75
60
 
76
61
  # Create the factory and set instance variables
77
- result = _create(flags, srid_.to_i, buffer_resolution_,
78
- wkt_generator_, wkb_generator_, proj4_, coord_sys_)
62
+ result = _create(flags, srid.to_i, buffer_resolution,
63
+ wkt_generator, wkb_generator, coord_sys)
79
64
 
80
65
  # Interpret parser options
81
- wkt_parser_ = opts_[:wkt_parser]
82
- case wkt_parser_
83
- when :geos
84
- wkt_parser_ = nil
66
+ wkt_parser = opts[:wkt_parser]
67
+ case wkt_parser
85
68
  when Hash
86
- wkt_parser_ = WKRep::WKTParser.new(result, wkt_parser_)
69
+ wkt_parser = WKRep::WKTParser.new(result, wkt_parser)
87
70
  else
88
- wkt_parser_ = WKRep::WKTParser.new(result)
71
+ wkt_parser = nil
89
72
  end
90
- wkb_parser_ = opts_[:wkb_parser]
91
- case wkb_parser_
92
- when :geos
93
- wkb_parser_ = nil
73
+ wkb_parser = opts[:wkb_parser]
74
+ case wkb_parser
94
75
  when Hash
95
- wkb_parser_ = WKRep::WKBParser.new(result, wkb_parser_)
76
+ wkb_parser = WKRep::WKBParser.new(result, wkb_parser)
96
77
  else
97
- wkb_parser_ = WKRep::WKBParser.new(result)
78
+ wkb_parser = nil
98
79
  end
99
- result._set_wkrep_parsers(wkt_parser_, wkb_parser_)
80
+ result._set_wkrep_parsers(wkt_parser, wkb_parser)
100
81
 
101
82
  # Return the result
102
83
  result
@@ -115,14 +96,14 @@ module RGeo
115
96
  def eql?(rhs_)
116
97
  rhs_.is_a?(CAPIFactory) && rhs_.srid == _srid &&
117
98
  rhs_._buffer_resolution == _buffer_resolution && rhs_._flags == _flags &&
118
- rhs_.proj4 == _proj4
99
+ rhs_.coord_sys == coord_sys
119
100
  end
120
101
  alias == eql?
121
102
 
122
103
  # Standard hash code
123
104
 
124
105
  def hash
125
- @hash ||= [_srid, _buffer_resolution, _flags, _proj4].hash
106
+ @hash ||= [_srid, _buffer_resolution, _flags].hash
126
107
  end
127
108
 
128
109
  # Marshal support
@@ -139,9 +120,6 @@ module RGeo
139
120
  "wkbp" => _wkb_parser ? _wkb_parser.properties : {},
140
121
  "apre" => auto_prepare
141
122
  }
142
- if (proj4_ = _proj4)
143
- hash_["proj4"] = proj4_.marshal_dump
144
- end
145
123
  if (coord_sys_ = _coord_sys)
146
124
  hash_["cs"] = coord_sys_.to_wkt
147
125
  end
@@ -149,14 +127,8 @@ module RGeo
149
127
  end
150
128
 
151
129
  def marshal_load(data_) # :nodoc:
152
- if (proj4_data_ = data_["proj4"]) && CoordSys.check!(:proj4)
153
- proj4_ = CoordSys::Proj4.allocate
154
- proj4_.marshal_load(proj4_data_)
155
- else
156
- proj4_ = nil
157
- end
158
130
  if (coord_sys_data_ = data_["cs"])
159
- coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
131
+ coord_sys_ = CoordSys::CONFIG.default_coord_sys_class.create_from_wkt(coord_sys_data_)
160
132
  else
161
133
  coord_sys_ = nil
162
134
  end
@@ -171,7 +143,6 @@ module RGeo
171
143
  wkt_parser: symbolize_hash(data_["wktp"]),
172
144
  wkb_parser: symbolize_hash(data_["wkbp"]),
173
145
  auto_prepare: data_["apre"],
174
- proj4: proj4_,
175
146
  coord_sys: coord_sys_
176
147
  )
177
148
  )
@@ -189,28 +160,14 @@ module RGeo
189
160
  coder_["wkt_parser"] = _wkt_parser ? _wkt_parser.properties : {}
190
161
  coder_["wkb_parser"] = _wkb_parser ? _wkb_parser.properties : {}
191
162
  coder_["auto_prepare"] = auto_prepare
192
- if (proj4_ = _proj4)
193
- str_ = proj4_.original_str || proj4_.canonical_str
194
- coder_["proj4"] = proj4_.radians? ? { "proj4" => str_, "radians" => true } : str_
195
- end
196
163
  if (coord_sys_ = _coord_sys)
197
164
  coder_["coord_sys"] = coord_sys_.to_wkt
198
165
  end
199
166
  end
200
167
 
201
168
  def init_with(coder_) # :nodoc:
202
- if (proj4_data_ = coder_["proj4"])
203
- CoordSys.check!(:proj4)
204
- if proj4_data_.is_a?(Hash)
205
- proj4_ = CoordSys::Proj4.create(proj4_data_["proj4"], radians: proj4_data_["radians"])
206
- else
207
- proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
208
- end
209
- else
210
- proj4_ = nil
211
- end
212
169
  if (coord_sys_data_ = coder_["cs"])
213
- coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
170
+ coord_sys_ = CoordSys::CONFIG.default_coord_sys_class.create_from_wkt(coord_sys_data_.to_s)
214
171
  else
215
172
  coord_sys_ = nil
216
173
  end
@@ -225,7 +182,6 @@ module RGeo
225
182
  wkt_parser: symbolize_hash(coder_["wkt_parser"]),
226
183
  wkb_parser: symbolize_hash(coder_["wkb_parser"]),
227
184
  auto_prepare: coder_["auto_prepare"] == "disabled" ? :disabled : :simple,
228
- proj4: proj4_,
229
185
  coord_sys: coord_sys_
230
186
  )
231
187
  )
@@ -276,11 +232,7 @@ module RGeo
276
232
  if (wkb_parser_ = _wkb_parser)
277
233
  wkb_parser_.parse(str_)
278
234
  else
279
- if str_[0] == "\x00" || str_[0] == "\x01"
280
- _parse_wkb_impl(str_)
281
- else
282
- _parse_wkb_impl([str_].pack('H*'))
283
- end
235
+ _parse_wkb_impl(str_)
284
236
  end
285
237
  end
286
238
 
@@ -351,12 +303,6 @@ module RGeo
351
303
  raise(RGeo::Error::InvalidGeometry, "Parse error")
352
304
  end
353
305
 
354
- # See RGeo::Feature::Factory#proj4
355
-
356
- def proj4
357
- _proj4
358
- end
359
-
360
306
  # See RGeo::Feature::Factory#coord_sys
361
307
 
362
308
  def coord_sys
@@ -375,10 +321,10 @@ module RGeo
375
321
  case original
376
322
  when CAPIGeometryMethods
377
323
  # Optimization if we're just changing factories, but the
378
- # factories are zm-compatible and proj4-compatible.
324
+ # factories are zm-compatible and coord_sys-compatible.
379
325
  if original.factory != self && ntype == type &&
380
326
  original.factory._flags & FLAG_SUPPORTS_Z_OR_M == _flags & FLAG_SUPPORTS_Z_OR_M &&
381
- (!project || original.factory.proj4 == _proj4)
327
+ (!project || original.factory.coord_sys == coord_sys)
382
328
  result = original.dup
383
329
  result.factory = self
384
330
  return result
@@ -386,7 +332,7 @@ module RGeo
386
332
  # LineString conversion optimization.
387
333
  if (original.factory != self || ntype != type) &&
388
334
  original.factory._flags & FLAG_SUPPORTS_Z_OR_M == _flags & FLAG_SUPPORTS_Z_OR_M &&
389
- (!project || original.factory.proj4 == _proj4) &&
335
+ (!project || original.factory.coord_sys == coord_sys) &&
390
336
  type.subtype_of?(Feature::LineString) && ntype.subtype_of?(Feature::LineString)
391
337
  return IMPL_CLASSES[ntype]._copy_from(self, original)
392
338
  end
@@ -24,16 +24,6 @@ module RGeo
24
24
  factory.supports_z? ? 3 : 2
25
25
  end
26
26
 
27
- def is_empty? # rubocop:disable Naming/PredicateName
28
- warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
29
- empty?
30
- end
31
-
32
- def is_simple? # rubocop:disable Naming/PredicateName
33
- warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
34
- simple?
35
- end
36
-
37
27
  def is_3d?
38
28
  factory.supports_z?
39
29
  end
@@ -81,25 +71,6 @@ module RGeo
81
71
  alias to_s as_text
82
72
  end
83
73
 
84
- module CAPIMultiLineStringMethods # :nodoc:
85
- def is_closed? # rubocop:disable Naming/PredicateName
86
- warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
87
- closed?
88
- end
89
- end
90
-
91
- module CAPILineStringMethods # :nodoc:
92
- def is_closed? # rubocop:disable Naming/PredicateName
93
- warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
94
- closed?
95
- end
96
-
97
- def is_ring? # rubocop:disable Naming/PredicateName
98
- warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
99
- ring?
100
- end
101
- end
102
-
103
74
  module CAPIGeometryCollectionMethods # :nodoc:
104
75
  include Enumerable
105
76
  end
@@ -33,75 +33,52 @@ module RGeo
33
33
  @_has_3d = @has_z || @has_m
34
34
  @buffer_resolution = opts[:buffer_resolution].to_i
35
35
  @buffer_resolution = 1 if @buffer_resolution < 1
36
- @_auto_prepare = opts[:auto_prepare] == :disabled ? false : true
36
+ @_auto_prepare = opts[:auto_prepare] != :disabled
37
37
 
38
38
  # Interpret the generator options
39
- wkt_generator_ = opts[:wkt_generator]
40
- case wkt_generator_
41
- when :geos
42
- @wkt_writer = ::Geos::WktWriter.new
43
- @wkt_generator = nil
39
+ wkt_generator = opts[:wkt_generator]
40
+ case wkt_generator
44
41
  when Hash
45
- @wkt_generator = WKRep::WKTGenerator.new(wkt_generator_)
42
+ @wkt_generator = WKRep::WKTGenerator.new(wkt_generator)
46
43
  @wkt_writer = nil
47
44
  else
48
- @wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
49
- @wkt_writer = nil
45
+ @wkt_writer = ::Geos::WktWriter.new
46
+ @wkt_writer.trim = true
47
+ @wkt_generator = nil
50
48
  end
51
- wkb_generator_ = opts[:wkb_generator]
52
- case wkb_generator_
53
- when :geos
54
- @wkb_writer = ::Geos::WkbWriter.new
55
- @wkb_generator = nil
49
+ wkb_generator = opts[:wkb_generator]
50
+ case wkb_generator
56
51
  when Hash
57
- @wkb_generator = WKRep::WKBGenerator.new(wkb_generator_)
52
+ @wkb_generator = WKRep::WKBGenerator.new(wkb_generator)
58
53
  @wkb_writer = nil
59
54
  else
60
- @wkb_generator = WKRep::WKBGenerator.new
61
- @wkb_writer = nil
55
+ @wkb_writer = ::Geos::WkbWriter.new
56
+ @wkb_generator = nil
62
57
  end
63
58
 
64
- # Coordinate system (srid, proj4, and coord_sys)
65
- @srid = opts[:srid]
66
- @proj4 = opts[:proj4]
67
- if @proj4 && CoordSys.check!(:proj4)
68
- if @proj4.is_a?(String) || @proj4.is_a?(Hash)
69
- @proj4 = CoordSys::Proj4.create(@proj4)
70
- end
71
- else
72
- @proj4 = nil
73
- end
74
- @coord_sys = opts[:coord_sys]
75
- if @coord_sys.is_a?(String)
76
- @coord_sys = CoordSys::CS.create_from_wkt(@coord_sys)
77
- end
78
- @srid ||= @coord_sys.authority_code if @coord_sys
79
- @srid = @srid.to_i
59
+ # Coordinate system (srid and coord_sys)
60
+ coord_sys_info = ImplHelper::Utils.setup_coord_sys(opts[:srid], opts[:coord_sys], opts[:coord_sys_class])
61
+ @srid = coord_sys_info[:srid]
62
+ @coord_sys = coord_sys_info[:coord_sys]
80
63
 
81
64
  # Interpret parser options
82
65
  wkt_parser = opts[:wkt_parser]
83
66
  case wkt_parser
84
- when :geos
85
- @wkt_reader = ::Geos::WktReader.new
86
- @wkt_parser = nil
87
67
  when Hash
88
68
  @wkt_parser = WKRep::WKTParser.new(self, wkt_parser)
89
69
  @wkt_reader = nil
90
70
  else
91
- @wkt_parser = WKRep::WKTParser.new(self)
92
- @wkt_reader = nil
71
+ @wkt_reader = ::Geos::WktReader.new
72
+ @wkt_parser = nil
93
73
  end
94
74
  wkb_parser = opts[:wkb_parser]
95
75
  case wkb_parser
96
- when :geos
97
- @wkb_reader = ::Geos::WkbReader.new
98
- @wkb_parser = nil
99
76
  when Hash
100
77
  @wkb_parser = WKRep::WKBParser.new(self, wkb_parser)
101
78
  @wkb_reader = nil
102
79
  else
103
- @wkb_parser = WKRep::WKBParser.new(self)
104
- @wkb_reader = nil
80
+ @wkb_reader = ::Geos::WkbReader.new
81
+ @wkb_parser = nil
105
82
  end
106
83
  end
107
84
  attr_reader :coordinate_dimension, :spatial_dimension
@@ -119,14 +96,14 @@ module RGeo
119
96
  @has_z == rhs.property(:has_z_coordinate) &&
120
97
  @has_m == rhs.property(:has_m_coordinate) &&
121
98
  @buffer_resolution == rhs.property(:buffer_resolution) &&
122
- @proj4.eql?(rhs.proj4)
99
+ @coord_sys.eql?(rhs.coord_sys)
123
100
  end
124
101
  alias == eql?
125
102
 
126
103
  # Standard hash code
127
104
 
128
105
  def hash
129
- @hash ||= [@srid, @has_z, @has_m, @buffer_resolution, @proj4].hash
106
+ @hash ||= [@srid, @has_z, @has_m, @buffer_resolution, @coord_sys].hash
130
107
  end
131
108
 
132
109
  # Marshal support
@@ -137,26 +114,19 @@ module RGeo
137
114
  "hasm" => @has_m,
138
115
  "srid" => @srid,
139
116
  "bufr" => @buffer_resolution,
140
- "wktg" => @wkt_generator.properties,
141
- "wkbg" => @wkb_generator.properties,
142
- "wktp" => @wkt_parser.properties,
143
- "wkbp" => @wkb_parser.properties,
117
+ "wktg" => @wkt_generator&.properties,
118
+ "wkbg" => @wkb_generator&.properties,
119
+ "wktp" => @wkt_parser&.properties,
120
+ "wkbp" => @wkb_parser&.properties,
144
121
  "apre" => @_auto_prepare
145
122
  }
146
- hash["proj4"] = @proj4.marshal_dump if @proj4
147
123
  hash["cs"] = @coord_sys.to_wkt if @coord_sys
148
124
  hash
149
125
  end
150
126
 
151
127
  def marshal_load(data) # :nodoc:
152
- if (proj4_data = data["proj4"]) && CoordSys.check!(:proj4)
153
- proj4 = CoordSys::Proj4.allocate
154
- proj4.marshal_load(proj4_data)
155
- else
156
- proj4 = nil
157
- end
158
128
  if (coord_sys_data = data["cs"])
159
- coord_sys = CoordSys::CS.create_from_wkt(coord_sys_data)
129
+ coord_sys = CoordSys::CONFIG.default_coord_sys_class.create_from_wkt(coord_sys_data)
160
130
  else
161
131
  coord_sys = nil
162
132
  end
@@ -165,12 +135,11 @@ module RGeo
165
135
  has_m_coordinate: data["hasm"],
166
136
  srid: data["srid"],
167
137
  buffer_resolution: data["bufr"],
168
- wkt_generator: symbolize_hash(data["wktg"]),
169
- wkb_generator: symbolize_hash(data["wkbg"]),
170
- wkt_parser: symbolize_hash(data["wktp"]),
171
- wkb_parser: symbolize_hash(data["wkbp"]),
138
+ wkt_generator: data["wktg"] && symbolize_hash(data["wktg"]),
139
+ wkb_generator: data["wkbg"] && symbolize_hash(data["wkbg"]),
140
+ wkt_parser: data["wktp"] && symbolize_hash(data["wktp"]),
141
+ wkb_parser: data["wkbp"] && symbolize_hash(data["wkbp"]),
172
142
  auto_prepare: (data["apre"] ? :simple : :disabled),
173
- proj4: proj4,
174
143
  coord_sys: coord_sys
175
144
  )
176
145
  end
@@ -182,31 +151,17 @@ module RGeo
182
151
  coder["has_m_coordinate"] = @has_m
183
152
  coder["srid"] = @srid
184
153
  coder["buffer_resolution"] = @buffer_resolution
185
- coder["wkt_generator"] = @wkt_generator.properties
186
- coder["wkb_generator"] = @wkb_generator.properties
187
- coder["wkt_parser"] = @wkt_parser.properties
188
- coder["wkb_parser"] = @wkb_parser.properties
154
+ coder["wkt_generator"] = @wkt_generator&.properties
155
+ coder["wkb_generator"] = @wkb_generator&.properties
156
+ coder["wkt_parser"] = @wkt_parser&.properties
157
+ coder["wkb_parser"] = @wkb_parser&.properties
189
158
  coder["auto_prepare"] = @_auto_prepare ? "simple" : "disabled"
190
- if @proj4
191
- str = @proj4.original_str || @proj4.canonical_str
192
- coder["proj4"] = @proj4.radians? ? { "proj4" => str, "radians" => true } : str
193
- end
194
159
  coder["coord_sys"] = @coord_sys.to_wkt if @coord_sys
195
160
  end
196
161
 
197
162
  def init_with(coder) # :nodoc:
198
- if (proj4_data = coder["proj4"])
199
- CoordSys.check!(:proj4)
200
- if proj4_data.is_a?(Hash)
201
- proj4 = CoordSys::Proj4.create(proj4_data["proj4"], radians: proj4_data["radians"])
202
- else
203
- proj4 = CoordSys::Proj4.create(proj4_data.to_s)
204
- end
205
- else
206
- proj4 = nil
207
- end
208
163
  if (coord_sys_data = coder["cs"])
209
- coord_sys = CoordSys::CS.create_from_wkt(coord_sys_data.to_s)
164
+ coord_sys = CoordSys::CONFIG.default_coord_sys_class.create_from_wkt(coord_sys_data.to_s)
210
165
  else
211
166
  coord_sys = nil
212
167
  end
@@ -215,12 +170,11 @@ module RGeo
215
170
  has_m_coordinate: coder["has_m_coordinate"],
216
171
  srid: coder["srid"],
217
172
  buffer_resolution: coder["buffer_resolution"],
218
- wkt_generator: symbolize_hash(coder["wkt_generator"]),
219
- wkb_generator: symbolize_hash(coder["wkb_generator"]),
220
- wkt_parser: symbolize_hash(coder["wkt_parser"]),
221
- wkb_parser: symbolize_hash(coder["wkb_parser"]),
173
+ wkt_generator: coder["wkt_generator"] && symbolize_hash(coder["wkt_generator"]),
174
+ wkb_generator: coder["wkb_generator"] && symbolize_hash(coder["wkb_generator"]),
175
+ wkt_parser: coder["wkt_parser"] && symbolize_hash(coder["wkt_parser"]),
176
+ wkb_parser: coder["wkb_parser"] && symbolize_hash(coder["wkb_parser"]),
222
177
  auto_prepare: coder["auto_prepare"] == "disabled" ? :disabled : :simple,
223
- proj4: proj4,
224
178
  coord_sys: coord_sys
225
179
  )
226
180
  end
@@ -253,7 +207,11 @@ module RGeo
253
207
  # See RGeo::Feature::Factory#parse_wkt
254
208
  def parse_wkt(str)
255
209
  if @wkt_reader
256
- wrap_fg_geom(@wkt_reader.read(str), nil)
210
+ begin
211
+ wrap_fg_geom(@wkt_reader.read(str), nil)
212
+ rescue ::Geos::WktReader::ParseError => e
213
+ raise RGeo::Error::ParseError, e.message.partition(":").last
214
+ end
257
215
  else
258
216
  @wkt_parser.parse(str)
259
217
  end
@@ -263,7 +221,12 @@ module RGeo
263
221
 
264
222
  def parse_wkb(str)
265
223
  if @wkb_reader
266
- wrap_fg_geom(@wkb_reader.read(str), nil)
224
+ begin
225
+ meth = str[0].match?(/[0-9a-fA-F]/) ? :read_hex : :read
226
+ wrap_fg_geom(@wkb_reader.public_send(meth, str), nil)
227
+ rescue ::Geos::WkbReader::ParseError => e
228
+ raise RGeo::Error::ParseError, e.message.partition(":").last
229
+ end
267
230
  else
268
231
  @wkb_parser.parse(str)
269
232
  end
@@ -404,10 +367,6 @@ module RGeo
404
367
  FFIMultiPolygonImpl.new(self, fg_geom, klasses)
405
368
  end
406
369
 
407
- # See RGeo::Feature::Factory#proj4
408
-
409
- attr_reader :proj4
410
-
411
370
  # See RGeo::Feature::Factory#coord_sys
412
371
 
413
372
  attr_reader :coord_sys
@@ -505,6 +464,7 @@ module RGeo
505
464
  def write_for_psych(geom)
506
465
  if Utils.ffi_supports_set_output_dimension || !@_has_3d
507
466
  wkt_writer = ::Geos::WktWriter.new
467
+ wkt_writer.trim = true
508
468
  wkt_writer.output_dimensions = 3 if @_has_3d
509
469
  wkt_writer.write(geom.fg_geom)
510
470
  else
@@ -125,20 +125,10 @@ module RGeo
125
125
  @fg_geom.empty?
126
126
  end
127
127
 
128
- def is_empty?
129
- warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
130
- empty?
131
- end
132
-
133
128
  def simple?
134
129
  @fg_geom.simple?
135
130
  end
136
131
 
137
- def is_simple?
138
- warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
139
- simple?
140
- end
141
-
142
132
  def is_3d?
143
133
  factory.property(:has_z_coordinate)
144
134
  end
@@ -415,20 +405,10 @@ module RGeo
415
405
  @fg_geom.closed?
416
406
  end
417
407
 
418
- def is_closed?
419
- warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
420
- closed?
421
- end
422
-
423
408
  def ring?
424
409
  @fg_geom.ring?
425
410
  end
426
411
 
427
- def is_ring?
428
- warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
429
- ring?
430
- end
431
-
432
412
  def rep_equals?(rhs)
433
413
  rhs.class == self.class && rhs.factory.eql?(@factory) &&
434
414
  Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
@@ -565,12 +545,7 @@ module RGeo
565
545
  end
566
546
 
567
547
  def hash
568
- @hash ||= begin
569
- hash = [@factory, geometry_type].hash
570
- (0...num_geometries).inject(hash) do |h, i|
571
- (1_664_525 * h + geometry_n(i).hash).hash
572
- end
573
- end
548
+ @hash ||= [@factory, geometry_type, *(0...num_geometries).map { |i| geometry_n(i) }].hash
574
549
  end
575
550
 
576
551
  def each
@@ -615,11 +590,6 @@ module RGeo
615
590
  true
616
591
  end
617
592
 
618
- def is_closed?
619
- warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
620
- closed?
621
- end
622
-
623
593
  def coordinates
624
594
  each.map(&:coordinates)
625
595
  end
@@ -38,11 +38,6 @@ module RGeo
38
38
  ZMGeometryMethods === object && CAPIGeometryMethods === object.z_geometry)
39
39
  end
40
40
 
41
- def is_capi_geos?(object)
42
- warn "The is_capi_geos? method is deprecated, please use the capi_geos? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
43
- capi_geos?(object)
44
- end
45
-
46
41
  # Returns true if the given feature is an FFI GEOS feature, or if
47
42
  # the given factory is an FFI GEOS factory.
48
43
 
@@ -53,11 +48,6 @@ module RGeo
53
48
  ZMGeometryMethods === object && FFIGeometryMethods === object.z_geometry)
54
49
  end
55
50
 
56
- def is_ffi_geos?(object)
57
- warn "The is_ffi_geos? method is deprecated, please use the ffi_geos? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
58
- ffi_geos?(object)
59
- end
60
-
61
51
  # Returns true if the given feature is a GEOS feature, or if the given
62
52
  # factory is a GEOS factory. Does not distinguish between CAPI and FFI.
63
53
 
@@ -67,11 +57,6 @@ module RGeo
67
57
  ZMFactory === object || ZMGeometryMethods === object
68
58
  end
69
59
 
70
- def is_geos?(object)
71
- warn "The is_geos? method is deprecated, please use the geos? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
72
- geos?(object)
73
- end
74
-
75
60
  # Returns the GEOS library version as a string of the format "x.y.z".
76
61
  # Returns nil if GEOS is not available.
77
62
 
@@ -127,14 +112,14 @@ module RGeo
127
112
  # [<tt>:srid</tt>]
128
113
  # Set the SRID returned by geometries created by this factory.
129
114
  # Default is 0.
130
- # [<tt>:proj4</tt>]
131
- # The coordinate system in Proj4 format, either as a
132
- # CoordSys::Proj4 object or as a string or hash representing the
133
- # proj4 format. Optional.
134
115
  # [<tt>:coord_sys</tt>]
135
116
  # The coordinate system in OGC form, either as a subclass of
136
117
  # CoordSys::CS::CoordinateSystem, or as a string in WKT format.
137
- # Optional.
118
+ # Optional. If not provided, but <tt>:srid</tt> is, a coord_sys
119
+ # will be created using the CS::CONFIG.default_coord_sys_class.
120
+ # [<tt>:coord_sys_class</tt>]
121
+ # The coordinate system implementation to use if you do not want to
122
+ # use the CS::CONFIG.default_coord_sys_class. Optional.
138
123
  # [<tt>:has_z_coordinate</tt>]
139
124
  # Support <tt>z_coordinate</tt>. Default is false.
140
125
  # [<tt>:has_m_coordinate</tt>]