rgeo 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc0fdafb5f2260dd8e4310275cdb5d07be71c7cdeb39c86d5aa6931a454df3cf
4
- data.tar.gz: 1b47209e5205243eb568ed50eea430279c629a1c16cb290253de809dd3a99ee2
3
+ metadata.gz: 792e1494e9ef340bb740e8675b2ce67e4d02fa6c4333ad93c523e348e5153812
4
+ data.tar.gz: a4051c1728401caca45807c9e786a5e5130761c95a95ff6bdb60265130aa2049
5
5
  SHA512:
6
- metadata.gz: 40a807a8aa741e30715c5b7dc1a487ae9682c149ff3c94b7f370190fbf804c1f11ac034c0f697a923b49cef3f763121224c1e1cef6eafc5b9721a1ba0f6d4344
7
- data.tar.gz: 72bec2c1432b56a2bb5ea50809f0d15d157c5c1e30379e756fb089c4dcd62a455d66783036e2d742c33ae552fe0f3a2ef40e53b07a26c6ccab21a2489f4f9214
6
+ metadata.gz: 3a6ee8000fd92f7bef89915d9d7e11aea0fb413248778d0f5e5218516d98cc6d16afba66d92c670c9f0539d37a6c7e934a5fcc3ad839626d7299b7c5ae8ffc57
7
+ data.tar.gz: 580f0a56261c8ab5698e14a78e7f61bcdb8fa362160db4ed1662dbb792d1d8ec7272a1e3387568b00c6b8403547aae128363ad230cf622ec5b5908a0e17b8d6f
data/README.md CHANGED
@@ -5,11 +5,10 @@
5
5
 
6
6
  RGeo is a geospatial data library for Ruby.
7
7
 
8
- :warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning:
8
+ ***Contributors Wanted!***
9
9
 
10
- This organization is looking for maintainers, see [this issue](https://github.com/rgeo/rgeo/issues/216) for more information.
10
+ If you use RGeo and are interested in contributing, please check out our [open issues](https://github.com/rgeo/rgeo/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22%2C%22help+wanted%22) to see if there's anything you're able to help with.
11
11
 
12
- :warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning:
13
12
 
14
13
  ### Summary
15
14
 
@@ -45,6 +45,7 @@ if have_header("geos_c.h")
45
45
  have_func("GEOSPreparedDisjoint_r", "geos_c.h")
46
46
  have_func("GEOSUnaryUnion_r", "geos_c.h")
47
47
  have_func("GEOSCoordSeq_isCCW_r", "geos_c.h")
48
+ have_func("GEOSDensify", "geos_c.h")
48
49
  have_func("rb_memhash", "ruby.h")
49
50
  have_func("rb_gc_mark_movable", "ruby.h")
50
51
  end
@@ -378,6 +378,7 @@ method_factory_write_for_marshal(VALUE self, VALUE obj)
378
378
  wkb_writer = self_data->marshal_wkb_writer;
379
379
  if (!wkb_writer) {
380
380
  wkb_writer = GEOSWKBWriter_create();
381
+ GEOSWKBWriter_setOutputDimension(wkb_writer, 2);
381
382
  if (has_3d) {
382
383
  GEOSWKBWriter_setOutputDimension(wkb_writer, 3);
383
384
  }
@@ -427,6 +428,7 @@ method_factory_write_for_psych(VALUE self, VALUE obj)
427
428
  wkt_writer = self_data->psych_wkt_writer;
428
429
  if (!wkt_writer) {
429
430
  wkt_writer = GEOSWKTWriter_create();
431
+ GEOSWKTWriter_setOutputDimension(wkt_writer, 2);
430
432
  GEOSWKTWriter_setTrim(wkt_writer, 1);
431
433
  if (has_3d) {
432
434
  GEOSWKTWriter_setOutputDimension(wkt_writer, 3);
@@ -266,6 +266,7 @@ method_geometry_as_text(VALUE self)
266
266
  wkt_writer = factory_data->wkt_writer;
267
267
  if (!wkt_writer) {
268
268
  wkt_writer = GEOSWKTWriter_create();
269
+ GEOSWKTWriter_setOutputDimension(wkt_writer, 2);
269
270
  GEOSWKTWriter_setTrim(wkt_writer, 1);
270
271
  factory_data->wkt_writer = wkt_writer;
271
272
  }
@@ -304,6 +305,7 @@ method_geometry_as_binary(VALUE self)
304
305
 
305
306
  if (!wkb_writer) {
306
307
  wkb_writer = GEOSWKBWriter_create();
308
+ GEOSWKBWriter_setOutputDimension(wkb_writer, 2);
307
309
  factory_data->wkb_writer = wkb_writer;
308
310
  }
309
311
  str = (char*)GEOSWKBWriter_write(wkb_writer, self_geom, &size);
@@ -738,6 +740,27 @@ method_geometry_buffer(VALUE self, VALUE distance)
738
740
  return result;
739
741
  }
740
742
 
743
+ #ifdef RGEO_GEOS_SUPPORTS_DENSIFY
744
+ static VALUE
745
+ method_geometry_segmentize(VALUE self, VALUE max_segment_length)
746
+ {
747
+ VALUE result;
748
+ RGeo_GeometryData* self_data;
749
+ const GEOSGeometry* self_geom;
750
+ VALUE factory;
751
+
752
+ result = Qnil;
753
+ self_data = RGEO_GEOMETRY_DATA_PTR(self);
754
+ self_geom = self_data->geom;
755
+ if (self_geom) {
756
+ factory = self_data->factory;
757
+ result = rgeo_wrap_geos_geometry(
758
+ factory, GEOSDensify(self_geom, rb_num2dbl(max_segment_length)), Qnil);
759
+ }
760
+ return result;
761
+ }
762
+ #endif
763
+
741
764
  static VALUE
742
765
  method_geometry_buffer_with_style(VALUE self,
743
766
  VALUE distance,
@@ -1306,6 +1329,10 @@ rgeo_init_geos_geometry()
1306
1329
  geos_geometry_methods, "make_valid", method_geometry_make_valid, 0);
1307
1330
  rb_define_method(
1308
1331
  geos_geometry_methods, "polygonize", method_geometry_polygonize, 0);
1332
+ #ifdef RGEO_GEOS_SUPPORTS_DENSIFY
1333
+ rb_define_method(
1334
+ geos_geometry_methods, "segmentize", method_geometry_segmentize, 1);
1335
+ #endif
1309
1336
  }
1310
1337
 
1311
1338
  RGEO_END_C
@@ -23,6 +23,9 @@
23
23
  #ifdef HAVE_GEOSCOORDSEQ_ISCCW_R
24
24
  #define RGEO_GEOS_SUPPORTS_ISCCW
25
25
  #endif
26
+ #ifdef HAVE_GEOSDENSIFY
27
+ #define RGEO_GEOS_SUPPORTS_DENSIFY
28
+ #endif
26
29
  #ifdef HAVE_RB_GC_MARK_MOVABLE
27
30
  #define mark rb_gc_mark_movable
28
31
  #else
@@ -251,6 +251,7 @@ module RGeo
251
251
  # :startdoc:
252
252
 
253
253
  def initialize(name, orientation) # :nodoc:
254
+ super()
254
255
  @name = name
255
256
  @orientation =
256
257
  case orientation
@@ -302,6 +303,7 @@ module RGeo
302
303
  # system that the projected coordinate system is based on.
303
304
  class ProjectionParameter < Base
304
305
  def initialize(name, value) # :nodoc:
306
+ super()
305
307
  @name = name
306
308
  @value = value.to_f
307
309
  end
@@ -339,6 +341,7 @@ module RGeo
339
341
  # points East, and the Z axis points North.
340
342
  class WGS84ConversionInfo < Base
341
343
  def initialize(dx_meters, dy_meters, dz_meters, ex_arc_seconds, ey_arc_seconds, ez_arc_seconds, ppm) # :nodoc:
344
+ super()
342
345
  @dx = dx_meters.to_f
343
346
  @dy = dy_meters.to_f
344
347
  @dz = dz_meters.to_f
@@ -427,6 +430,7 @@ module RGeo
427
430
  class Info < Base
428
431
  def initialize(name, authority = nil, authority_code = nil, abbreviation = nil, init_alias = nil,
429
432
  remarks = nil, extensions = nil) # :nodoc:
433
+ super()
430
434
  @name = name
431
435
  @authority = authority ? authority.to_s : nil
432
436
  @authority_code = authority_code ? authority_code.to_s : nil
@@ -191,21 +191,15 @@ module RGeo
191
191
  if nfactory == factory
192
192
  force_new ? obj.dup : obj
193
193
  elsif type == Point
194
- cs = ncs = nil
195
- if project
196
- cs = factory.coord_sys
197
- ncs = nfactory.coord_sys
198
- end
199
- hasz = factory.property(:has_z_coordinate)
200
- nhasz = nfactory.property(:has_z_coordinate)
201
- if cs && ncs
202
- coords = cs.transform_coords(ncs, obj.x, obj.y, hasz ? obj.z : nil)
203
- coords << (hasz ? obj.z : 0.0) if nhasz && coords.size < 3
204
- else
205
- coords = [obj.x, obj.y]
206
- coords << (hasz ? obj.z : 0.0) if nhasz
207
- end
208
- coords << (factory.property(:has_m_coordinate) ? obj.m : 0.0) if nfactory.property(:has_m_coordinate)
194
+ z = factory.property(:has_z_coordinate) ? obj.z : nil
195
+ coords = if project && (cs = factory.coord_sys) && (ncs = nfactory.coord_sys)
196
+ cs.transform_coords(ncs, obj.x, obj.y, z)
197
+ else
198
+ [obj.x, obj.y]
199
+ end
200
+ coords << (z || 0.0) if nfactory.property(:has_z_coordinate) && coords.size < 3
201
+ m = factory.property(:has_m_coordinate) ? obj.m : nil
202
+ coords << (m || 0.0) if nfactory.property(:has_m_coordinate)
209
203
  nfactory.point(*coords)
210
204
  elsif type == Line
211
205
  nfactory.line(cast(obj.start_point, nfactory, opts), cast(obj.end_point, nfactory, opts))
@@ -106,7 +106,7 @@ module RGeo
106
106
  "Spherical",
107
107
  has_z_coordinate: opts[:has_z_coordinate],
108
108
  has_m_coordinate: opts[:has_m_coordinate],
109
- coord_sys: coord_sys || coord_sys_4055,
109
+ coord_sys: coord_sys || coord_sys4055,
110
110
  buffer_resolution: opts[:buffer_resolution],
111
111
  wkt_parser: opts[:wkt_parser],
112
112
  wkb_parser: opts[:wkb_parser],
@@ -189,7 +189,7 @@ module RGeo
189
189
  def simple_mercator_factory(opts = {})
190
190
  factory = Geographic::Factory.new(
191
191
  "Projected",
192
- coord_sys: coord_sys_4326,
192
+ coord_sys: coord_sys4326,
193
193
  srid: 4326,
194
194
  wkt_parser: opts[:wkt_parser],
195
195
  wkb_parser: opts[:wkb_parser],
@@ -379,16 +379,16 @@ module RGeo
379
379
 
380
380
  private
381
381
 
382
- def coord_sys_4055
383
- return @coord_sys_4055 if defined?(@coord_sys_4055)
382
+ def coord_sys4055
383
+ return @coord_sys4055 if defined?(@coord_sys4055)
384
384
 
385
- @coord_sys_4055 = CoordSys::CONFIG.default_coord_sys_class.create(4055)
385
+ @coord_sys4055 = CoordSys::CONFIG.default_coord_sys_class.create(4055)
386
386
  end
387
387
 
388
- def coord_sys_4326
389
- return @coord_sys_4326 if defined?(@coord_sys_4326)
388
+ def coord_sys4326
389
+ return @coord_sys4326 if defined?(@coord_sys4326)
390
390
 
391
- @coord_sys_4326 = CoordSys::CONFIG.default_coord_sys_class.create(4326)
391
+ @coord_sys4326 = CoordSys::CONFIG.default_coord_sys_class.create(4326)
392
392
  end
393
393
  end
394
394
  end
@@ -14,7 +14,7 @@ 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
- coord_sys: SimpleMercatorProjector._coordsys_3857,
17
+ coord_sys: SimpleMercatorProjector._coordsys3857,
18
18
  buffer_resolution: opts[:buffer_resolution],
19
19
  has_z_coordinate: opts[:has_z_coordinate],
20
20
  has_m_coordinate: opts[:has_m_coordinate])
@@ -104,10 +104,10 @@ module RGeo
104
104
  )
105
105
  end
106
106
 
107
- def self._coordsys_3857 # :nodoc:
108
- return @coordsys_3857 if defined?(@coordsys_3857)
107
+ def self._coordsys3857 # :nodoc:
108
+ return @coordsys3857 if defined?(@coordsys3857)
109
109
 
110
- @coordsys_3857 = CoordSys::CONFIG.default_coord_sys_class.create(3857)
110
+ @coordsys3857 = CoordSys::CONFIG.default_coord_sys_class.create(3857)
111
111
  end
112
112
  end
113
113
  end
@@ -56,6 +56,7 @@ module RGeo
56
56
  @wkt_writer = nil
57
57
  else
58
58
  @wkt_writer = ::Geos::WktWriter.new
59
+ @wkt_writer.output_dimensions = 2
59
60
  @wkt_writer.trim = true
60
61
  @wkt_generator = nil
61
62
  end
@@ -66,6 +67,7 @@ module RGeo
66
67
  @wkb_writer = nil
67
68
  else
68
69
  @wkb_writer = ::Geos::WkbWriter.new
70
+ @wkb_writer.output_dimensions = 2
69
71
  @wkb_generator = nil
70
72
  end
71
73
 
@@ -295,10 +297,8 @@ module RGeo
295
297
  inner_rings = inner_rings.to_a unless inner_rings.is_a?(Array)
296
298
  return unless RGeo::Feature::LineString.check_type(outer_ring)
297
299
  outer_ring = create_fg_linear_ring(outer_ring.points)
298
- inner_rings = inner_rings.map do |r|
299
- return unless RGeo::Feature::LineString.check_type(r)
300
- create_fg_linear_ring(r.points)
301
- end
300
+ return unless inner_rings.all? { |r| RGeo::Feature::LineString.check_type(r) }
301
+ inner_rings = inner_rings.map { |r| create_fg_linear_ring(r.points) }
302
302
  inner_rings.compact!
303
303
  fg_geom = ::Geos::Utils.create_polygon(outer_ring, *inner_rings)
304
304
  FFIPolygonImpl.new(self, fg_geom, nil)
@@ -327,16 +327,16 @@ module RGeo
327
327
  def multi_point(elems)
328
328
  elems = elems.to_a unless elems.is_a?(Array)
329
329
  elems = elems.map do |elem|
330
- elem = RGeo::Feature.cast(
330
+ RGeo::Feature.cast(
331
331
  elem,
332
332
  self,
333
333
  RGeo::Feature::Point,
334
334
  :force_new,
335
335
  :keep_subtype
336
336
  )
337
- return unless elem
338
- elem.detach_fg_geom
339
337
  end
338
+ return unless elems.all?
339
+ elems = elems.map(&:detach_fg_geom)
340
340
  klasses = Array.new(elems.size, FFIPointImpl)
341
341
  fg_geom = ::Geos::Utils.create_collection(::Geos::GeomTypes::GEOS_MULTIPOINT, elems)
342
342
  FFIMultiPointImpl.new(self, fg_geom, klasses)
@@ -449,6 +449,7 @@ module RGeo
449
449
  def write_for_marshal(geom)
450
450
  if Utils.ffi_supports_set_output_dimension || !@_has_3d
451
451
  wkb_writer = ::Geos::WkbWriter.new
452
+ wkb_writer.output_dimensions = 2
452
453
  wkb_writer.output_dimensions = 3 if @_has_3d
453
454
  wkb_writer.write(geom.fg_geom)
454
455
  else
@@ -463,6 +464,7 @@ module RGeo
463
464
  def write_for_psych(geom)
464
465
  if Utils.ffi_supports_set_output_dimension || !@_has_3d
465
466
  wkt_writer = ::Geos::WktWriter.new
467
+ wkt_writer.output_dimensions = 2
466
468
  wkt_writer.trim = true
467
469
  wkt_writer.output_dimensions = 3 if @_has_3d
468
470
  wkt_writer.write(geom.fg_geom)
@@ -485,8 +487,8 @@ module RGeo
485
487
  size += 1
486
488
  end
487
489
  cs = ::Geos::CoordinateSequence.new(size, 3)
490
+ return unless points.all? { |p| RGeo::Feature::Point.check_type(p) }
488
491
  points.each_with_index do |p, i|
489
- return unless RGeo::Feature::Point.check_type(p)
490
492
  cs.set_x(i, p.x)
491
493
  cs.set_y(i, p.y)
492
494
  if @has_z
@@ -168,43 +168,43 @@ module RGeo
168
168
 
169
169
  def disjoint?(rhs)
170
170
  fg = factory.convert_to_fg_geometry(rhs)
171
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
171
+ prep = request_prepared if Utils.ffi_supports_prepared_level2
172
172
  prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
173
173
  end
174
174
 
175
175
  def intersects?(rhs)
176
176
  fg = factory.convert_to_fg_geometry(rhs)
177
- prep = request_prepared if Utils.ffi_supports_prepared_level_1
177
+ prep = request_prepared if Utils.ffi_supports_prepared_level1
178
178
  prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
179
179
  end
180
180
 
181
181
  def touches?(rhs)
182
182
  fg = factory.convert_to_fg_geometry(rhs)
183
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
183
+ prep = request_prepared if Utils.ffi_supports_prepared_level2
184
184
  prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
185
185
  end
186
186
 
187
187
  def crosses?(rhs)
188
188
  fg = factory.convert_to_fg_geometry(rhs)
189
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
189
+ prep = request_prepared if Utils.ffi_supports_prepared_level2
190
190
  prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
191
191
  end
192
192
 
193
193
  def within?(rhs)
194
194
  fg = factory.convert_to_fg_geometry(rhs)
195
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
195
+ prep = request_prepared if Utils.ffi_supports_prepared_level2
196
196
  prep ? prep.within?(fg) : @fg_geom.within?(fg)
197
197
  end
198
198
 
199
199
  def contains?(rhs)
200
200
  fg = factory.convert_to_fg_geometry(rhs)
201
- prep = request_prepared if Utils.ffi_supports_prepared_level_1
201
+ prep = request_prepared if Utils.ffi_supports_prepared_level1
202
202
  prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
203
203
  end
204
204
 
205
205
  def overlaps?(rhs)
206
206
  fg = factory.convert_to_fg_geometry(rhs)
207
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
207
+ prep = request_prepared if Utils.ffi_supports_prepared_level2
208
208
  prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
209
209
  end
210
210
 
@@ -212,7 +212,6 @@ module RGeo
212
212
  fg = factory.convert_to_fg_geometry(rhs)
213
213
  @fg_geom.relate_pattern(fg, pattern)
214
214
  end
215
- alias relate relate? # DEPRECATED
216
215
 
217
216
  def distance(rhs)
218
217
  fg = factory.convert_to_fg_geometry(rhs)
@@ -55,11 +55,11 @@ module RGeo
55
55
  end
56
56
  end
57
57
 
58
- def ffi_supports_prepared_level_1
58
+ def ffi_supports_prepared_level1
59
59
  FFI_SUPPORTED && ::Geos::FFIGeos.respond_to?(:GEOSPreparedContains_r)
60
60
  end
61
61
 
62
- def ffi_supports_prepared_level_2
62
+ def ffi_supports_prepared_level2
63
63
  FFI_SUPPORTED && ::Geos::FFIGeos.respond_to?(:GEOSPreparedDisjoint_r)
64
64
  end
65
65
 
@@ -128,7 +128,6 @@ module RGeo
128
128
  def relate?(rhs, pattern)
129
129
  @zgeometry.relate?(RGeo::Feature.cast(rhs, self).z_geometry, pattern)
130
130
  end
131
- alias relate relate? # DEPRECATED
132
131
 
133
132
  def distance(rhs)
134
133
  @zgeometry.distance(RGeo::Feature.cast(rhs, self).z_geometry)
data/lib/rgeo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RGeo
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-25 00:00:00.000000000 Z
12
+ date: 2023-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi-geos
@@ -238,14 +238,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
238
  requirements:
239
239
  - - ">="
240
240
  - !ruby/object:Gem::Version
241
- version: 2.6.0
241
+ version: 2.7.7
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  requirements:
244
244
  - - ">="
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  requirements: []
248
- rubygems_version: 3.1.4
248
+ rubygems_version: 3.2.33
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: RGeo is a geospatial data library for Ruby.