ffi-geos 1.0.0 → 1.1.0

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
  SHA1:
3
- metadata.gz: 6bc526266d55420dc48080bdd5e692892c7dbb2a
4
- data.tar.gz: f7677af86f57eb3d0a9be0b8b1755b3ddc423ffb
3
+ metadata.gz: 105d67e566f0d38c5d679438643095c0b633c7cc
4
+ data.tar.gz: e1b981680f31f9b0b71cb8057ca4e588e03d5d04
5
5
  SHA512:
6
- metadata.gz: 203cff10e29ac37807026ddc9a2d70965fe368df68ca2a03ea3fa74c28f5604ac86a03e33f5430461e0d0b109194bec66036c24d32058285ce6b03a6a815b33e
7
- data.tar.gz: 35a98846b51df19ab97ccc39f610ee442b59a5f1c423b9b58870cda443d66476dff0dccad0340909a8906da1eacb86611eabbc287412ae0456f6bdcd8d92d4c8
6
+ metadata.gz: abb46c8314cfe017c9802c97b42f621e8ff2f1b84b5a23ca46b26d9ccaf2cefeb77731febde0b70350fed80b3f4c7d0a67373a5779abaad514293c47c3df5126
7
+ data.tar.gz: d79aa2d5154f1ed6f1bf10001a7a849ccff83f3f08d8b4f4c35fb158bbd8e8ce6296db127632bd47d9389993dcc2cdf6bbe4f487d4fc0c52bd2257383531e0ea
data/.travis.yml CHANGED
@@ -1,11 +1,14 @@
1
+ cache: bundler
2
+ sudo: false
1
3
  language: ruby
2
4
  rvm:
3
- - 2.1.1
4
- - 2.1.0
5
+ - 2.2.3
6
+ - 2.1.7
5
7
  - 2.0.0
6
8
  - 1.9.3
7
- - 1.8.7
8
9
  - rbx-2
9
- before_install:
10
- - sudo apt-get update
11
- - sudo apt-get install libgeos-dev
10
+ - jruby-19mode
11
+ addons:
12
+ apt:
13
+ packages:
14
+ - libgeos-c1
data/Gemfile CHANGED
@@ -15,6 +15,7 @@ end
15
15
 
16
16
  if RUBY_VERSION >= '1.9'
17
17
  gem "simplecov"
18
+ gem "guard"
18
19
  gem 'guard-minitest'
19
20
  end
20
21
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 J Smith <dark.panda@gmail.com>
1
+ Copyright (c) 2010-2015 J Smith <dark.panda@gmail.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.rdoc CHANGED
@@ -7,12 +7,15 @@
7
7
  * GEOS version 3.3.0 or greater. GEOS 3.2.2 and below will work to an extent,
8
8
  but some features and methods will be disabled or missing.
9
9
 
10
- Ruby versions known to work:
10
+ Ruby versions known to work according to travis-ci and local testing:
11
11
 
12
- * Ruby MRI 1.8.7, 1.9.2, 1.9.3, 2.0+ x86_64, OSX 10.6.5+
13
- * Ruby MRI 1.8.7, 1.9.2, 1.9.3, 2.0+ i386, linux
14
- * Ruby MRI 1.8.7, 1.9.2, 1.9.3, 2.0+ x86_64, linux
15
- * JRuby 1.6+, x86_64 OSX 10.6.5+
12
+ * Ruby MRI 1.9.3, 2.0+, 2.1+, 2.2+
13
+ * Ruby MRI 1.8.7 works but as Ruby 1.8 is no longer being maintained, there's
14
+ no guarantee this will continue in the future and is therefore no longer
15
+ being tested with the same rigour as more modern versions of Ruby.
16
+ * Rubinius 2
17
+ * JRuby 1.6+, with the exception of versions of JRuby prior to 1.6.3 as per
18
+ below. This includes both 1.8 and 1.9 modes.
16
19
 
17
20
  === JRuby Notes
18
21
 
@@ -72,11 +75,15 @@ Ruby bindings along with the following enhancements and additions:
72
75
  convenience methods and geometry conversion and manipulation methods.
73
76
 
74
77
  * *NEW IN ffi-geos 1.0.0* -- all errors thrown by ffi-geos are now instances of
75
- `Geos::Error` or subclasses thereof. `Geos::Error` itself is a descendant
76
- of `RuntimeError` as is the case with the native Geos extension. This means
77
- that code like `rescue RuntimeError` should still work but you can now
78
+ Geos::Error or subclasses thereof. Geos::Error itself is a descendant
79
+ of RuntimeError as is the case with the native Geos extension. This means
80
+ that code like rescue RuntimeError should still work but you can now
78
81
  further capture more precise error types by capturing errors like
79
- `Geos::Error`, `Geos::ParseError`, etc.
82
+ Geos::Error, Geos::ParseError, etc.
83
+
84
+ * *NEW IN ffi-geos 1.0.0* -- new methods for Geom::Geometry#voronoi_diagram,
85
+ Geos::MultiLineString#closed? and Geos::Geometry#clip_by_rect when using
86
+ GEOS 3.5.0+.
80
87
 
81
88
  == Thanks
82
89
 
data/lib/ffi-geos.rb CHANGED
@@ -138,6 +138,10 @@ module Geos
138
138
 
139
139
  FFI_LAYOUT = {
140
140
  #### Utility functions ####
141
+
142
+ # Initialization and cleanup
143
+
144
+ # deprecated in GEOS 3.5.0+
141
145
  :initGEOS_r => [
142
146
  :pointer,
143
147
 
@@ -152,6 +156,26 @@ module Geos
152
156
  # void, *handle
153
157
  :void, :pointer
154
158
  ],
159
+ # / deprecated in GEOS 3.5.0+
160
+
161
+ # GEOS 3.5.0+
162
+ :GEOS_init_r => [ :pointer ],
163
+
164
+ :GEOSContext_setNoticeMessageHandler_r => [
165
+ # void, *handle, callback, *void
166
+ :void, :pointer, callback([ :string, :string ], :void), :pointer
167
+ ],
168
+
169
+ :GEOSContext_setErrorMessageHandler_r => [
170
+ # void, *handle, callback, *void
171
+ :void, :pointer, callback([ :string, :string ], :void), :pointer
172
+ ],
173
+
174
+ :GEOS_finish_r => [
175
+ # void, *handle
176
+ :void, :pointer
177
+ ],
178
+ # / GEOS 3.5.0+
155
179
 
156
180
  :GEOS_interruptRegisterCallback => [
157
181
  :pointer,
@@ -430,6 +454,11 @@ module Geos
430
454
  :pointer, :pointer, :pointer
431
455
  ],
432
456
 
457
+ :GEOSClipByRect_r => [
458
+ # *geom, *handle, *geom, xmin, ymin, xmax, ymax
459
+ :pointer, :pointer, :pointer, :double, :double, :double, :double
460
+ ],
461
+
433
462
  :GEOSGetCentroid_r => [
434
463
  # *geom, *handle, *geom
435
464
  :pointer, :pointer, :pointer
@@ -475,6 +504,11 @@ module Geos
475
504
  :pointer, :pointer, :pointer, :double, :int
476
505
  ],
477
506
 
507
+ :GEOSVoronoiDiagram_r => [
508
+ # *geom, *handle, *geom, *envelope, tolerance, only_edges
509
+ :pointer, :pointer, :pointer, :pointer, :double, :int
510
+ ],
511
+
478
512
  :GEOSRelate_r => [
479
513
  # string, *handle, *geom_a, *geom_b
480
514
  :string, :pointer, :pointer, :pointer
@@ -1004,27 +1038,43 @@ module Geos
1004
1038
  class Handle
1005
1039
  attr_reader :ptr
1006
1040
 
1007
- def initialize
1008
- @ptr = FFI::AutoPointer.new(
1009
- FFIGeos.initGEOS_r(
1010
- @notice_handler = self.method(:notice_handler),
1011
- @error_handler = self.method(:error_handler)
1012
- ),
1013
- self.class.method(:release)
1014
- )
1015
- end
1041
+ if FFIGeos.respond_to?(:GEOS_init_r)
1042
+ def initialize
1043
+ @ptr = FFI::AutoPointer.new(FFIGeos.GEOS_init_r, self.class.method(:release))
1016
1044
 
1017
- def self.release(ptr)
1018
- FFIGeos.finishGEOS_r(ptr)
1019
- end
1045
+ FFIGeos.GEOSContext_setNoticeMessageHandler_r(@ptr, @notice_handler = self.method(:notice_handler), nil)
1046
+ FFIGeos.GEOSContext_setErrorMessageHandler_r(@ptr, @error_handler = self.method(:error_handler), nil)
1047
+ end
1020
1048
 
1021
- def notice_handler(*args)
1022
- # no-op, just to appease initGEOS.
1023
- end
1049
+ def self.release(ptr)
1050
+ FFIGeos.GEOS_finish_r(ptr)
1051
+ end
1024
1052
 
1025
- def error_handler(*args)
1026
- raise Geos::GEOSException.new(args[0] % args[1])
1053
+ # Deprecated initialization and teardown...
1054
+ else
1055
+ def initialize
1056
+ @ptr = FFI::AutoPointer.new(
1057
+ FFIGeos.initGEOS_r(
1058
+ @notice_handler = self.method(:notice_handler),
1059
+ @error_handler = self.method(:error_handler)
1060
+ ),
1061
+ self.class.method(:release)
1062
+ )
1063
+ end
1064
+
1065
+ def self.release(ptr)
1066
+ FFIGeos.finishGEOS_r(ptr)
1067
+ end
1027
1068
  end
1069
+
1070
+ private
1071
+ def notice_handler(*args)
1072
+ # no-op, just to appease initGEOS.
1073
+ end
1074
+
1075
+ def error_handler(*args)
1076
+ raise Geos::GEOSException.new(args[0] % args[1])
1077
+ end
1028
1078
  end
1029
1079
 
1030
1080
  class << self
@@ -69,7 +69,7 @@ module Geos
69
69
  end
70
70
 
71
71
  def single_sided=(value)
72
- if bool_result(FFIGeos.GEOSBufferParams_setSingleSided_r(Geos.current_handle, ptr, value ? 1 : 0))
72
+ if bool_result(FFIGeos.GEOSBufferParams_setSingleSided_r(Geos.current_handle, ptr, Geos::Tools.bool_to_int(value)))
73
73
  @params[:single_sided] = value
74
74
  end
75
75
  end
@@ -109,7 +109,7 @@ module Geos
109
109
  if points
110
110
  points.each_with_index do |point, idx|
111
111
  point.each_with_index do |val, dim|
112
- self.set_ordinate(idx, dim, val.to_f)
112
+ self.set_ordinate(idx, dim, val)
113
113
  end
114
114
  end
115
115
  end
@@ -164,24 +164,24 @@ module Geos
164
164
  # Sets the x value of a coordinate. Can also be set via #x[]=.
165
165
  def set_x(idx, val)
166
166
  self.check_bounds(idx)
167
- FFIGeos.GEOSCoordSeq_setX_r(Geos.current_handle, self.ptr, idx, val)
167
+ FFIGeos.GEOSCoordSeq_setX_r(Geos.current_handle, self.ptr, idx, val.to_f)
168
168
  end
169
169
 
170
170
  # Sets the y value of a coordinate. Can also be set via #y[]=.
171
171
  def set_y(idx, val)
172
172
  self.check_bounds(idx)
173
- FFIGeos.GEOSCoordSeq_setY_r(Geos.current_handle, self.ptr, idx, val)
173
+ FFIGeos.GEOSCoordSeq_setY_r(Geos.current_handle, self.ptr, idx, val.to_f)
174
174
  end
175
175
 
176
176
  # Sets the z value of a coordinate. Can also be set via #z[]=.
177
177
  def set_z(idx, val)
178
178
  self.check_bounds(idx)
179
- FFIGeos.GEOSCoordSeq_setZ_r(Geos.current_handle, self.ptr, idx, val)
179
+ FFIGeos.GEOSCoordSeq_setZ_r(Geos.current_handle, self.ptr, idx, val.to_f)
180
180
  end
181
181
 
182
182
  def set_ordinate(idx, dim, val)
183
183
  self.check_bounds(idx)
184
- FFIGeos.GEOSCoordSeq_setOrdinate_r(Geos.current_handle, self.ptr, idx, dim, val)
184
+ FFIGeos.GEOSCoordSeq_setOrdinate_r(Geos.current_handle, self.ptr, idx, dim, val.to_f)
185
185
  end
186
186
 
187
187
  # Gets the x value of a coordinate. Can also be retrieved via #x[].
@@ -207,6 +207,14 @@ module Geos
207
207
  end
208
208
  alias :representative_point :point_on_surface
209
209
 
210
+ if FFIGeos.respond_to?(:GEOSClipByRect_r)
211
+ # Available in GEOS 3.5.0+.
212
+ def clip_by_rect(xmin, ymin, xmax, ymax)
213
+ cast_geometry_ptr(FFIGeos.GEOSClipByRect_r(Geos.current_handle, self.ptr, xmin, ymin, xmax, ymax))
214
+ end
215
+ alias :clip_by_rectangle :clip_by_rect
216
+ end
217
+
210
218
  def centroid
211
219
  cast_geometry_ptr(FFIGeos.GEOSGetCentroid_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
212
220
  end
@@ -566,8 +574,49 @@ module Geos
566
574
  end
567
575
 
568
576
  if FFIGeos.respond_to?(:GEOSDelaunayTriangulation_r)
569
- def delaunay_triangulation(tolerance, options = {})
570
- cast_geometry_ptr(FFIGeos.GEOSDelaunayTriangulation_r(Geos.current_handle, self.ptr, tolerance, options[:only_edges] ? 1 : 0))
577
+ # :call-seq:
578
+ # delaunay_triangulation(options = {})
579
+ # delaunay_triangulation(tolerance, options = {})
580
+ #
581
+ # Options:
582
+ #
583
+ # * :tolerance
584
+ # * :only_edges
585
+ def delaunay_triangulation(*args)
586
+ options = extract_options!(args)
587
+
588
+ tolerance = args.first || options[:tolerance] || 0.0
589
+ only_edges = bool_to_int(options[:only_edges])
590
+
591
+ cast_geometry_ptr(FFIGeos.GEOSDelaunayTriangulation_r(Geos.current_handle, self.ptr, tolerance, only_edges))
592
+ end
593
+ end
594
+
595
+ if FFIGeos.respond_to?(:GEOSVoronoiDiagram_r)
596
+ # Available in GEOS 3.5.0+
597
+ #
598
+ # :call-seq:
599
+ # voronoi_diagram(options = {})
600
+ # voronoi_diagram(tolerance, options = {})
601
+ #
602
+ # Options:
603
+ #
604
+ # * :tolerance
605
+ # * :envelope
606
+ # * :only_edges
607
+ def voronoi_diagram(*args)
608
+ options = extract_options!(args)
609
+
610
+ tolerance = args.first || options[:tolerance] || 0.0
611
+
612
+ envelope_ptr = if options[:envelope]
613
+ check_geometry(options[:envelope])
614
+ options[:envelope].ptr
615
+ end
616
+
617
+ only_edges = bool_to_int(options[:only_edges])
618
+
619
+ cast_geometry_ptr(FFIGeos.GEOSVoronoiDiagram_r(Geos.current_handle, self.ptr, envelope_ptr, tolerance, only_edges))
571
620
  end
572
621
  end
573
622
 
@@ -35,7 +35,7 @@ module Geos
35
35
  FFIGeos.GEOS_interruptRegisterCallback(method_or_block)
36
36
  method_or_block
37
37
  elsif block_given?
38
- FFIGeos.GEOS_interruptRegisterCallback(&block)
38
+ FFIGeos.GEOS_interruptRegisterCallback(block)
39
39
  block
40
40
  end
41
41
 
@@ -2,5 +2,11 @@
2
2
 
3
3
  module Geos
4
4
  class MultiLineString < GeometryCollection
5
+ if FFIGeos.respond_to?(:GEOSisClosed_r) && Geos::GEOS_VERSION >= '3.5.0'
6
+ # Available in GEOS 3.5.0+.
7
+ def closed?
8
+ bool_result(FFIGeos.GEOSisClosed_r(Geos.current_handle, self.ptr))
9
+ end
10
+ end
5
11
  end
6
12
  end
@@ -105,6 +105,14 @@ module Geos
105
105
  end
106
106
  end
107
107
 
108
+ def bool_to_int(bool)
109
+ if bool
110
+ 1
111
+ else
112
+ 0
113
+ end
114
+ end
115
+
108
116
  def check_enum_value(enum, value)
109
117
  enum[value] or
110
118
  raise TypeError.new("Couldn't find valid #{enum.tag} value: #{value}")
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Geos
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
 
@@ -73,7 +73,7 @@ module Geos
73
73
 
74
74
  def include_srid=(val)
75
75
  FFIGeos.GEOSWKBWriter_setIncludeSRID_r(Geos.current_handle, self.ptr,
76
- val ? 1 : 0
76
+ Geos::Tools.bool_to_int(val)
77
77
  )
78
78
  end
79
79
 
@@ -60,7 +60,7 @@ module Geos
60
60
  def trim=(val)
61
61
  @trim = !!val
62
62
  FFIGeos.GEOSWKTWriter_setTrim_r(Geos.current_handle, self.ptr,
63
- @trim ? 1 : 0
63
+ Geos::Tools.bool_to_int(@trim)
64
64
  )
65
65
  end
66
66
  end
@@ -83,7 +83,7 @@ module Geos
83
83
  def old_3d=(val)
84
84
  @old_3d = !!val
85
85
  FFIGeos.GEOSWKTWriter_setOld3D_r(Geos.current_handle, self.ptr,
86
- @old_3d ? 1 : 0
86
+ Geos::Tools.bool_to_int(@old_3d)
87
87
  )
88
88
  end
89
89
  end
@@ -449,6 +449,50 @@ class GeometryTests < Minitest::Test
449
449
  end
450
450
  end
451
451
 
452
+ def test_clip_by_rect
453
+ skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:clip_by_rect)
454
+
455
+ %w{
456
+ clip_by_rect
457
+ clip_by_rectangle
458
+ }.each do |method|
459
+ simple_tester(
460
+ method,
461
+ 'POINT (0 0)',
462
+ 'POINT (0 0)',
463
+ -1, -1, 1, 1
464
+ )
465
+
466
+ simple_tester(
467
+ method,
468
+ 'GEOMETRYCOLLECTION EMPTY',
469
+ 'POINT (0 0)',
470
+ 0, 0, 2, 2
471
+ )
472
+
473
+ simple_tester(
474
+ method,
475
+ 'LINESTRING (1 0, 2 0)',
476
+ 'LINESTRING (0 0, 10 0)',
477
+ 1, -1, 2, 1
478
+ )
479
+
480
+ simple_tester(
481
+ method,
482
+ 'POLYGON ((1 1, 1 5, 5 5, 5 1, 1 1))',
483
+ 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))',
484
+ 1, 1, 5, 5
485
+ )
486
+
487
+ simple_tester(
488
+ method,
489
+ 'POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))',
490
+ 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))',
491
+ -1, -1, 5, 5
492
+ )
493
+ end
494
+ end
495
+
452
496
  def test_centroid_and_center
453
497
  %w{
454
498
  centroid
@@ -1559,5 +1603,36 @@ class GeometryTests < Minitest::Test
1559
1603
 
1560
1604
  # four points with a tolerance making one collapse
1561
1605
  tester['MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))', 'MULTIPOINT(0 0, 10 0, 10 10, 11 10)', 2.0, { :only_edges => true }]
1606
+
1607
+ # tolerance as an option
1608
+ tester['MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))', 'MULTIPOINT(0 0, 10 0, 10 10, 11 10)', { :tolerance => 2.0, :only_edges => true }]
1609
+ end
1610
+
1611
+ def test_voronoi_diagram
1612
+ skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:voronoi_diagram)
1613
+
1614
+ tester = lambda { |expected, geom, *args|
1615
+ geom = read(geom)
1616
+ voronoi_diagram = geom.voronoi_diagram(*args)
1617
+
1618
+ assert_equal(expected, write(voronoi_diagram))
1619
+ }
1620
+
1621
+ writer.trim = true
1622
+
1623
+ geom = 'MULTIPOINT(0 0, 100 0, 100 100, 0 100)'
1624
+
1625
+ tester['GEOMETRYCOLLECTION (POLYGON ((50 200, 200 200, 200 50, 50 50, 50 200)), POLYGON ((-100 50, -100 200, 50 200, 50 50, -100 50)), POLYGON ((50 -100, -100 -100, -100 50, 50 50, 50 -100)), POLYGON ((200 50, 200 -100, 50 -100, 50 50, 200 50)))', geom]
1626
+
1627
+ tester['MULTILINESTRING ((50 50, 50 200), (200 50, 50 50), (50 50, -100 50), (50 50, 50 -100))', geom, { :tolerance => 0, :only_edges => true }]
1628
+
1629
+ tester['MULTILINESTRING ((50 50, 50 1100), (1100 50, 50 50), (50 50, -1000 50), (50 50, 50 -1000))', geom, {
1630
+ :only_edges => true,
1631
+ :envelope => read(geom).buffer(1000)
1632
+ }]
1633
+
1634
+ # Allows a tolerance for the first argument
1635
+ @writer.rounding_precision = 3
1636
+ tester['GEOMETRYCOLLECTION (POLYGON ((290 252, 290 140, 185 140, 185 215, 188 235, 290 252)), POLYGON ((80 215, 80 340, 101 340, 188 235, 185 215, 80 215)), POLYGON ((185 140, 80 140, 80 215, 185 215, 185 140)), POLYGON ((101 340, 290 340, 290 252, 188 235, 101 340)))', "MULTIPOINT ((150 210), (210 270), (150 220), (220 210), (215 269))", 10]
1562
1637
  end
1563
1638
  end
@@ -41,6 +41,8 @@ class InterruptTests < Minitest::Test
41
41
  begin
42
42
  buffer = geom.buffer(1, 8)
43
43
  rescue => e
44
+ # no-op
45
+ ensure
44
46
  assert_match(/^InterruptedException/, e.message)
45
47
  assert_nil(buffer)
46
48
  assert_interrupt_called
@@ -62,6 +64,8 @@ class InterruptTests < Minitest::Test
62
64
  begin
63
65
  buffer = geom.buffer(1, 8)
64
66
  rescue => e
67
+ # no-op
68
+ ensure
65
69
  assert_match(/^InterruptedException/, e.message)
66
70
  assert_nil(buffer)
67
71
  assert_interrupt_called
@@ -85,6 +89,8 @@ class InterruptTests < Minitest::Test
85
89
  begin
86
90
  buffer = geom.buffer(1, 8)
87
91
  rescue => e
92
+ # no-op
93
+ ensure
88
94
  assert_match(/^InterruptedException/, e.message)
89
95
  assert_nil(buffer)
90
96
  assert_interrupt_called
@@ -118,6 +124,8 @@ class InterruptTests < Minitest::Test
118
124
  begin
119
125
  buffer = geom.buffer(1, 8)
120
126
  rescue => e
127
+ # no-op
128
+ ensure
121
129
  assert_match(/^InterruptedException/, e.message)
122
130
  assert_nil(buffer)
123
131
  assert_interrupt_called(1)
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+
3
+ $: << File.dirname(__FILE__)
4
+ require 'test_helper'
5
+
6
+ class MultiLineStringTests < Minitest::Test
7
+ include TestHelper
8
+
9
+ def setup
10
+ super
11
+ writer.trim = true
12
+ end
13
+
14
+ def test_closed
15
+ skip unless ENV['FORCE_TESTS'] || Geos::MultiLineString.method_defined?(:closed?)
16
+
17
+ simple_tester(:closed?, false, 'MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1))')
18
+ simple_tester(:closed?, true, 'MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1, 0 0))')
19
+ end
20
+ end
data/test/tools_tests.rb CHANGED
@@ -21,6 +21,15 @@ class ToolsTests < Minitest::Test
21
21
  end
22
22
  end
23
23
 
24
+ def test_bool_to_int
25
+ assert_equal(1, Geos::Tools.bool_to_int(1))
26
+ assert_equal(1, Geos::Tools.bool_to_int(true))
27
+ assert_equal(1, Geos::Tools.bool_to_int(""))
28
+ assert_equal(1, Geos::Tools.bool_to_int(0))
29
+ assert_equal(0, Geos::Tools.bool_to_int(false))
30
+ assert_equal(0, Geos::Tools.bool_to_int(nil))
31
+ end
32
+
24
33
  def test_pick_srid_from_geoms
25
34
  Geos.srid_copy_policy = :default
26
35
  assert_equal(0, Geos::Tools.pick_srid_from_geoms(4326, 4269))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-geos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -68,6 +68,7 @@ files:
68
68
  - test/line_string_tests.rb
69
69
  - test/linear_ring_tests.rb
70
70
  - test/misc_tests.rb
71
+ - test/multi_line_string_tests.rb
71
72
  - test/point_tests.rb
72
73
  - test/polygon_tests.rb
73
74
  - test/prepared_geometry_tests.rb
@@ -99,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  requirements: []
101
102
  rubyforge_project:
102
- rubygems_version: 2.2.2
103
+ rubygems_version: 2.2.5
103
104
  signing_key:
104
105
  specification_version: 4
105
106
  summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
@@ -111,6 +112,7 @@ test_files:
111
112
  - test/line_string_tests.rb
112
113
  - test/linear_ring_tests.rb
113
114
  - test/misc_tests.rb
115
+ - test/multi_line_string_tests.rb
114
116
  - test/point_tests.rb
115
117
  - test/polygon_tests.rb
116
118
  - test/prepared_geometry_tests.rb