ffi-geos 0.0.1.beta1 → 0.0.1.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,23 +6,69 @@ if defined?(Geos::PreparedGeometry)
6
6
  class PreparedGeometryTests < Test::Unit::TestCase
7
7
  include TestHelper
8
8
 
9
- def test_contains_properly
10
- geom_a = read('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))').to_prepared
11
- geom_b = read('POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))')
9
+ POINT_A = 'POINT(0 0)'
10
+ POINT_B = 'POINT(5 0)'
11
+ POINT_C = 'POINT(15 15)'
12
+ LINESTRING_A = 'LINESTRING(0 0, 10 0)'
13
+ LINESTRING_B = 'LINESTRING(5 -5, 5 5)'
14
+ LINESTRING_C = 'LINESTRING(5 0, 15 0)'
15
+ LINESTRING_D = 'LINESTRING(0 0, 5 0, 10 0)'
16
+ POLYGON_A = 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'
17
+ POLYGON_B = 'POLYGON((5 -5, 5 5, 15 5, 15 -5, 5 -5))'
12
18
 
13
- assert(geom_a.contains_properly?(geom_b))
19
+ def relationship_tester(method, *expected)
20
+ [
21
+ [ POINT_A, POINT_A ],
22
+ [ POINT_A, LINESTRING_A ],
23
+ [ POINT_B, LINESTRING_A ],
24
+ [ LINESTRING_B, LINESTRING_A ],
25
+ [ LINESTRING_C, LINESTRING_A ],
26
+ [ LINESTRING_D, LINESTRING_A ],
27
+ [ POLYGON_A, POLYGON_B ],
28
+ [ POLYGON_A, POINT_C ],
29
+ ].each_with_index do |(geom_a, geom_b), i|
30
+ geom_a = read(geom_a).to_prepared
31
+ geom_b = read(geom_b)
14
32
 
15
- geom_a = read('POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))').to_prepared
16
- geom_b = read('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))')
33
+ value = geom_a.send(method, geom_b)
34
+ assert_equal(expected[i], value)
35
+ end
36
+ end
37
+
38
+ def test_disjoint
39
+ relationship_tester(:disjoint?, false, false, false, false, false, false, false, true)
40
+ end
17
41
 
18
- assert(!geom_a.contains_properly?(geom_b))
42
+ def test_touches
43
+ relationship_tester(:touches?, false, true, false, false, false, false, false, false)
19
44
  end
20
45
 
21
46
  def test_intersects
22
- geom_a = read('LINESTRING(0 0, 10 10)').to_prepared
23
- geom_b = read('LINESTRING(0 10, 10 0)')
47
+ relationship_tester(:intersects?, true, true, true, true, true, true, true, false)
48
+ end
49
+
50
+ def test_crosses
51
+ relationship_tester(:crosses?, false, false, false, true, false, false, false, false)
52
+ end
53
+
54
+ def test_within
55
+ relationship_tester(:within?, true, false, true, false, false, true, false, false)
56
+ end
57
+
58
+ def test_contains
59
+ relationship_tester(:contains?, true, false, false, false, false, true, false, false)
60
+ end
61
+
62
+ def test_overlaps
63
+ relationship_tester(:overlaps?, false, false, false, false, true, false, true, false)
64
+ end
65
+
66
+ def test_covers
67
+ relationship_tester(:covers?, true, false, false, false, false, true, false, false)
68
+ end
24
69
 
25
- assert(geom_a.intersects?(geom_b))
70
+ def test_covered_by
71
+ relationship_tester(:covered_by?, true, true, true, false, false, true, false, false)
26
72
  end
27
73
  end
28
74
  end
data/test/utils_tests.rb CHANGED
@@ -206,7 +206,7 @@ class UtilsTests < Test::Unit::TestCase
206
206
  assert_equal(1, geom.num_geometries)
207
207
  end
208
208
 
209
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_multi_point)
209
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_point)
210
210
  def test_create_multi_point
211
211
  @writer.rounding_precision = 0
212
212
  assert_equal('MULTIPOINT EMPTY', write(Geos.create_multi_point))
@@ -226,7 +226,7 @@ class UtilsTests < Test::Unit::TestCase
226
226
  end
227
227
  end
228
228
 
229
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_multi_line_string)
229
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_line_string)
230
230
  def test_create_multi_line_string
231
231
  @writer.rounding_precision = 0
232
232
  assert_equal('MULTILINESTRING EMPTY', write(Geos.create_multi_line_string))
@@ -246,7 +246,7 @@ class UtilsTests < Test::Unit::TestCase
246
246
  end
247
247
  end
248
248
 
249
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_multi_polygon)
249
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_polygon)
250
250
  def test_create_multi_polygon
251
251
  @writer.rounding_precision = 0
252
252
  assert_equal('MULTIPOLYGON EMPTY', write(Geos.create_multi_polygon))
@@ -266,7 +266,7 @@ class UtilsTests < Test::Unit::TestCase
266
266
  end
267
267
  end
268
268
 
269
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_geometry_collection)
269
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_geometry_collection)
270
270
  def test_create_geometry_collection
271
271
  @writer.rounding_precision = 0
272
272
  assert_equal('GEOMETRYCOLLECTION EMPTY', write(Geos.create_geometry_collection))
@@ -278,6 +278,11 @@ class UtilsTests < Test::Unit::TestCase
278
278
  )
279
279
  end
280
280
 
281
+ def test_create_geometry_collection_with_constants_and_symbols
282
+ assert_kind_of(Geos::MultiLineString, Geos.create_collection(Geos::GeomTypes::GEOS_MULTILINESTRING))
283
+ assert_kind_of(Geos::MultiLineString, Geos.create_collection(:multi_line_string))
284
+ end
285
+
281
286
  def test_create_bad_geometry_collection
282
287
  assert_raise(TypeError) do
283
288
  Geos.create_geometry_collection(
@@ -289,43 +294,43 @@ class UtilsTests < Test::Unit::TestCase
289
294
  end
290
295
  end
291
296
 
292
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_point)
297
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_point)
293
298
  def test_create_empty_point
294
299
  assert_equal('POINT EMPTY', write(Geos.create_empty_point))
295
300
  end
296
301
  end
297
302
 
298
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_line_string)
303
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_line_string)
299
304
  def test_create_empty_line_string
300
305
  assert_equal('LINESTRING EMPTY', write(Geos.create_empty_line_string))
301
306
  end
302
307
  end
303
308
 
304
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_polygon)
309
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_polygon)
305
310
  def test_create_empty_polygon
306
311
  assert_equal('POLYGON EMPTY', write(Geos.create_empty_polygon))
307
312
  end
308
313
  end
309
314
 
310
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_multi_point)
315
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_multi_point)
311
316
  def test_create_empty_multi_point
312
317
  assert_equal('MULTIPOINT EMPTY', write(Geos.create_empty_multi_point))
313
318
  end
314
319
  end
315
320
 
316
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_multi_line_string)
321
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_multi_line_string)
317
322
  def test_create_empty_multi_line_string
318
323
  assert_equal('MULTILINESTRING EMPTY', write(Geos.create_empty_multi_line_string))
319
324
  end
320
325
  end
321
326
 
322
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_multi_polygon)
327
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_multi_polygon)
323
328
  def test_create_empty_multi_polygon
324
329
  assert_equal('MULTIPOLYGON EMPTY', write(Geos.create_empty_multi_polygon))
325
330
  end
326
331
  end
327
332
 
328
- if ENV['FORCE_TESTS'] || Geos.method_defined?(:create_empty_geometry_collection)
333
+ if ENV['FORCE_TESTS'] || Geos.respond_to?(:create_empty_geometry_collection)
329
334
  def test_create_empty_geometry_collection
330
335
  assert_equal('GEOMETRYCOLLECTION EMPTY', write(Geos.create_empty_geometry_collection))
331
336
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-geos
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196393
4
+ hash: 62196399
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 1
10
10
  - beta
11
- - 1
12
- version: 0.0.1.beta1
11
+ - 2
12
+ version: 0.0.1.beta2
13
13
  platform: ruby
14
14
  authors:
15
15
  - J Smith
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-04-14 00:00:00 Z
20
+ date: 2011-05-11 00:00:00 Z
21
21
  dependencies: []
22
22
 
23
23
  description: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
@@ -33,6 +33,8 @@ files:
33
33
  - README.rdoc
34
34
  - Rakefile
35
35
  - VERSION
36
+ - ffi-geos.gemspec
37
+ - lib/buffer_params.rb
36
38
  - lib/coordinate_sequence.rb
37
39
  - lib/ffi-geos.rb
38
40
  - lib/geometry.rb