rgeo 0.5.3 → 0.6.0

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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/ext/geos_c_impl/extconf.rb +1 -0
  3. data/ext/geos_c_impl/factory.c +10 -1
  4. data/ext/geos_c_impl/geometry.c +25 -3
  5. data/ext/geos_c_impl/line_string.c +1 -12
  6. data/ext/geos_c_impl/polygon.c +0 -3
  7. data/ext/geos_c_impl/preface.h +3 -0
  8. data/lib/rgeo.rb +0 -1
  9. data/lib/rgeo/feature/geometry.rb +17 -0
  10. data/lib/rgeo/feature/types.rb +4 -4
  11. data/lib/rgeo/geographic/projected_feature_methods.rb +1 -22
  12. data/lib/rgeo/geos/ffi_feature_methods.rb +5 -0
  13. data/lib/rgeo/geos/utils.rb +2 -0
  14. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -0
  15. data/lib/rgeo/version.rb +1 -1
  16. metadata +11 -171
  17. data/lib/rgeo/yaml.rb +0 -23
  18. data/test/cartesian_analysis_test.rb +0 -65
  19. data/test/cartesian_bbox_test.rb +0 -123
  20. data/test/common/factory_tests.rb +0 -78
  21. data/test/common/geometry_collection_tests.rb +0 -237
  22. data/test/common/line_string_tests.rb +0 -330
  23. data/test/common/multi_line_string_tests.rb +0 -182
  24. data/test/common/multi_point_tests.rb +0 -200
  25. data/test/common/multi_polygon_tests.rb +0 -191
  26. data/test/common/point_tests.rb +0 -370
  27. data/test/common/polygon_tests.rb +0 -228
  28. data/test/coord_sys/ogc_cs_test.rb +0 -342
  29. data/test/coord_sys/proj4_srs_data_test.rb +0 -41
  30. data/test/coord_sys/proj4_test.rb +0 -150
  31. data/test/coord_sys/sr_org_test.rb +0 -32
  32. data/test/coord_sys/url_reader_test.rb +0 -42
  33. data/test/geos_capi/factory_test.rb +0 -31
  34. data/test/geos_capi/geometry_collection_test.rb +0 -24
  35. data/test/geos_capi/line_string_test.rb +0 -24
  36. data/test/geos_capi/misc_test.rb +0 -116
  37. data/test/geos_capi/multi_line_string_test.rb +0 -24
  38. data/test/geos_capi/multi_point_test.rb +0 -24
  39. data/test/geos_capi/multi_polygon_test.rb +0 -39
  40. data/test/geos_capi/parsing_unparsing_test.rb +0 -40
  41. data/test/geos_capi/point_test.rb +0 -72
  42. data/test/geos_capi/polygon_test.rb +0 -154
  43. data/test/geos_capi/zmfactory_test.rb +0 -57
  44. data/test/geos_ffi/factory_test.rb +0 -31
  45. data/test/geos_ffi/geometry_collection_test.rb +0 -24
  46. data/test/geos_ffi/line_string_test.rb +0 -24
  47. data/test/geos_ffi/misc_test.rb +0 -63
  48. data/test/geos_ffi/multi_line_string_test.rb +0 -24
  49. data/test/geos_ffi/multi_point_test.rb +0 -24
  50. data/test/geos_ffi/multi_polygon_test.rb +0 -33
  51. data/test/geos_ffi/parsing_unparsing_test.rb +0 -41
  52. data/test/geos_ffi/point_test.rb +0 -77
  53. data/test/geos_ffi/polygon_test.rb +0 -46
  54. data/test/geos_ffi/zmfactory_test.rb +0 -58
  55. data/test/mixins_test.rb +0 -141
  56. data/test/oneoff_test.rb +0 -26
  57. data/test/projected_geographic/factory_test.rb +0 -25
  58. data/test/projected_geographic/geometry_collection_test.rb +0 -24
  59. data/test/projected_geographic/line_string_test.rb +0 -24
  60. data/test/projected_geographic/multi_line_string_test.rb +0 -26
  61. data/test/projected_geographic/multi_point_test.rb +0 -30
  62. data/test/projected_geographic/multi_polygon_test.rb +0 -25
  63. data/test/projected_geographic/point_test.rb +0 -51
  64. data/test/projected_geographic/polygon_test.rb +0 -24
  65. data/test/simple_cartesian/calculations_test.rb +0 -99
  66. data/test/simple_cartesian/factory_test.rb +0 -27
  67. data/test/simple_cartesian/geometry_collection_test.rb +0 -30
  68. data/test/simple_cartesian/line_string_test.rb +0 -31
  69. data/test/simple_cartesian/multi_line_string_test.rb +0 -28
  70. data/test/simple_cartesian/multi_point_test.rb +0 -31
  71. data/test/simple_cartesian/multi_polygon_test.rb +0 -31
  72. data/test/simple_cartesian/point_test.rb +0 -50
  73. data/test/simple_cartesian/polygon_test.rb +0 -28
  74. data/test/simple_mercator/factory_test.rb +0 -25
  75. data/test/simple_mercator/geometry_collection_test.rb +0 -24
  76. data/test/simple_mercator/line_string_test.rb +0 -24
  77. data/test/simple_mercator/multi_line_string_test.rb +0 -26
  78. data/test/simple_mercator/multi_point_test.rb +0 -29
  79. data/test/simple_mercator/multi_polygon_test.rb +0 -25
  80. data/test/simple_mercator/point_test.rb +0 -55
  81. data/test/simple_mercator/polygon_test.rb +0 -24
  82. data/test/simple_mercator/window_test.rb +0 -173
  83. data/test/spherical_geographic/calculations_test.rb +0 -167
  84. data/test/spherical_geographic/factory_test.rb +0 -27
  85. data/test/spherical_geographic/geometry_collection_test.rb +0 -31
  86. data/test/spherical_geographic/line_string_test.rb +0 -31
  87. data/test/spherical_geographic/multi_line_string_test.rb +0 -29
  88. data/test/spherical_geographic/multi_point_test.rb +0 -31
  89. data/test/spherical_geographic/multi_polygon_test.rb +0 -31
  90. data/test/spherical_geographic/point_test.rb +0 -78
  91. data/test/spherical_geographic/polygon_test.rb +0 -28
  92. data/test/types_test.rb +0 -42
  93. data/test/wkrep/wkb_generator_test.rb +0 -185
  94. data/test/wkrep/wkb_parser_test.rb +0 -293
  95. data/test/wkrep/wkt_generator_test.rb +0 -294
  96. data/test/wkrep/wkt_parser_test.rb +0 -412
data/lib/rgeo/yaml.rb DELETED
@@ -1,23 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # RGeo yaml support
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- begin
8
- require "psych"
9
- rescue ::LoadError
10
- end
11
-
12
- module RGeo
13
- # :stopdoc:
14
- PSYCH_AVAILABLE = defined?(::Psych)
15
- # :startdoc:
16
-
17
- # Returns true if YAML serialization and deserialization is supported.
18
- # YAML support requires the Psych library/gem.
19
-
20
- def self.yaml_supported?
21
- PSYCH_AVAILABLE
22
- end
23
- end
@@ -1,65 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Tests for basic GeoJSON usage
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "test/unit"
8
- require "rgeo"
9
-
10
- module RGeo
11
- module Tests # :nodoc:
12
- class TestCartesianAnalysis < ::Test::Unit::TestCase # :nodoc:
13
- def setup
14
- @factory = ::RGeo::Cartesian.simple_factory
15
- end
16
-
17
- def test_ring_direction_clockwise_triangle
18
- p1_ = @factory.point(1, 1)
19
- p2_ = @factory.point(2, 4)
20
- p3_ = @factory.point(5, 2)
21
- ring_ = @factory.line_string([p1_, p2_, p3_, p1_])
22
- assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
23
- end
24
-
25
- def test_ring_direction_counterclockwise_triangle
26
- p1_ = @factory.point(1, 1)
27
- p2_ = @factory.point(2, 4)
28
- p3_ = @factory.point(5, 2)
29
- ring_ = @factory.line_string([p1_, p3_, p2_, p1_])
30
- assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
31
- end
32
-
33
- def test_ring_direction_clockwise_puckered_quad
34
- p1_ = @factory.point(1, 1)
35
- p2_ = @factory.point(2, 6)
36
- p3_ = @factory.point(3, 3)
37
- p4_ = @factory.point(5, 2)
38
- ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
39
- assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
40
- end
41
-
42
- def test_ring_direction_counterclockwise_puckered_quad
43
- p1_ = @factory.point(1, 1)
44
- p2_ = @factory.point(2, 6)
45
- p3_ = @factory.point(3, 3)
46
- p4_ = @factory.point(5, 2)
47
- ring_ = @factory.line_string([p1_, p4_, p3_, p2_, p1_])
48
- assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
49
- end
50
-
51
- def test_ring_direction_counterclockwise_near_circle
52
- p1_ = @factory.point(0, -3)
53
- p2_ = @factory.point(2, -2)
54
- p3_ = @factory.point(3, 0)
55
- p4_ = @factory.point(2, 2)
56
- p5_ = @factory.point(0, 3)
57
- p6_ = @factory.point(-2, 2)
58
- p7_ = @factory.point(-3, 0)
59
- p8_ = @factory.point(-2, -2)
60
- ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p1_])
61
- assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
62
- end
63
- end
64
- end
65
- end
@@ -1,123 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Tests for basic GeoJSON usage
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "test/unit"
8
- require "rgeo"
9
-
10
- module RGeo
11
- module Tests # :nodoc:
12
- class TestCartesianBBox < ::Test::Unit::TestCase # :nodoc:
13
- def setup
14
- @factory = ::RGeo::Cartesian.factory
15
- end
16
-
17
- def test_empty_bbox
18
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
19
- assert_equal(true, bbox_.empty?)
20
- assert_equal(false, bbox_.has_z)
21
- assert_nil(bbox_.min_x)
22
- assert_equal(@factory, bbox_.factory)
23
- assert_nil(bbox_.min_point)
24
- assert_equal(true, bbox_.to_geometry.is_empty?)
25
- assert_equal(true, bbox_.contains?(bbox_))
26
- assert_equal(false, bbox_.contains?(@factory.point(1, 1)))
27
- assert_nil(bbox_.center_x)
28
- assert_equal(0, bbox_.x_span)
29
- assert_equal(0, bbox_.subdivide.size)
30
- end
31
-
32
- def test_point_bbox
33
- empty_bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
34
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
35
- bbox_.add(@factory.point(1, 2))
36
- assert_equal(false, bbox_.empty?)
37
- assert_equal(false, bbox_.has_z)
38
- assert_equal(1.0, bbox_.min_x)
39
- assert_equal(2.0, bbox_.min_y)
40
- assert_equal(1.0, bbox_.max_x)
41
- assert_equal(2.0, bbox_.max_y)
42
- assert_equal(@factory, bbox_.factory)
43
- assert_equal(@factory.point(1, 2), bbox_.min_point)
44
- assert_equal(@factory.point(1, 2), bbox_.max_point)
45
- assert_equal(@factory.point(1, 2), bbox_.to_geometry)
46
- assert_equal(true, bbox_.contains?(empty_bbox_))
47
- assert_equal(false, empty_bbox_.contains?(bbox_))
48
- assert_equal(true, bbox_.contains?(@factory.point(1, 2)))
49
- assert_equal(false, bbox_.contains?(@factory.point(2, 1)))
50
- assert_equal(1, bbox_.center_x)
51
- assert_equal(0, bbox_.x_span)
52
- assert_equal(2, bbox_.center_y)
53
- assert_equal(0, bbox_.y_span)
54
- assert_equal([bbox_], bbox_.subdivide)
55
- end
56
-
57
- def test_rect_bbox
58
- empty_bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
59
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
60
- bbox_.add(@factory.point(1, 4))
61
- bbox_.add(@factory.point(2, 3))
62
- assert_equal(false, bbox_.empty?)
63
- assert_equal(false, bbox_.has_z)
64
- assert_equal(1.0, bbox_.min_x)
65
- assert_equal(3.0, bbox_.min_y)
66
- assert_equal(2.0, bbox_.max_x)
67
- assert_equal(4.0, bbox_.max_y)
68
- assert_equal(@factory, bbox_.factory)
69
- assert_equal(@factory.point(1, 3), bbox_.min_point)
70
- assert_equal(@factory.point(2, 4), bbox_.max_point)
71
- assert_equal(1.0, bbox_.to_geometry.area)
72
- assert_equal(true, bbox_.contains?(empty_bbox_))
73
- assert_equal(false, empty_bbox_.contains?(bbox_))
74
- assert_equal(true, bbox_.contains?(@factory.point(1, 3)))
75
- assert_equal(false, bbox_.contains?(@factory.point(2, 1)))
76
- assert_equal(1.5, bbox_.center_x)
77
- assert_equal(1, bbox_.x_span)
78
- assert_equal(3.5, bbox_.center_y)
79
- assert_equal(1, bbox_.y_span)
80
- end
81
-
82
- def test_bbox_from_points
83
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
84
- bbox_.add(@factory.point(1, 4))
85
- bbox_.add(@factory.point(2, 3))
86
- bbox2_ = ::RGeo::Cartesian::BoundingBox.create_from_points(
87
- @factory.point(2, 3), @factory.point(1, 4))
88
- assert_equal(bbox_, bbox2_)
89
- end
90
-
91
- def test_basic_rect_subdivide
92
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
93
- bbox_.add(@factory.point(1, 2))
94
- bbox_.add(@factory.point(5, 4))
95
- quads_ = bbox_.subdivide
96
- quads_.each { |q_| assert_equal(2.0, q_.to_geometry.area) }
97
- quadsum_ = quads_[0].to_geometry + quads_[1].to_geometry +
98
- quads_[2].to_geometry + quads_[3].to_geometry
99
- assert_equal(bbox_.to_geometry, quadsum_)
100
- end
101
-
102
- def test_horiz_line_subdivide
103
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
104
- bbox_.add(@factory.point(1, 2))
105
- bbox_.add(@factory.point(5, 2))
106
- lines_ = bbox_.subdivide
107
- lines_.each { |line_| assert_equal(2.0, line_.to_geometry.length) }
108
- linesum_ = lines_[0].to_geometry + lines_[1].to_geometry
109
- assert_equal(bbox_.to_geometry, linesum_)
110
- end
111
-
112
- def test_vert_line_subdivide
113
- bbox_ = ::RGeo::Cartesian::BoundingBox.new(@factory)
114
- bbox_.add(@factory.point(1, 2))
115
- bbox_.add(@factory.point(1, 6))
116
- lines_ = bbox_.subdivide
117
- lines_.each { |line_| assert_equal(2.0, line_.to_geometry.length) }
118
- linesum_ = lines_[0].to_geometry + lines_[1].to_geometry
119
- assert_equal(bbox_.to_geometry, linesum_)
120
- end
121
- end
122
- end
123
- end
@@ -1,78 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Common tests for geometry collection implementations
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "rgeo"
8
-
9
- module RGeo
10
- module Tests # :nodoc:
11
- module Common # :nodoc:
12
- module FactoryTests # :nodoc:
13
- def _srid
14
- defined?(@srid) ? @srid : 0
15
- end
16
-
17
- def test_srid_preserved_through_factory
18
- geom_ = @factory.point(-10, 20)
19
- assert_equal(_srid, geom_.srid)
20
- factory_ = geom_.factory
21
- assert_equal(_srid, factory_.srid)
22
- geom2_ = factory_.point(-20, 25)
23
- assert_equal(_srid, geom2_.srid)
24
- end
25
-
26
- def test_srid_preserved_through_geom_operations
27
- geom1_ = @factory.point(-10, 20)
28
- geom2_ = @factory.point(-20, 25)
29
- geom3_ = geom1_.union(geom2_)
30
- assert_equal(_srid, geom3_.srid)
31
- assert_equal(_srid, geom3_.geometry_n(0).srid)
32
- assert_equal(_srid, geom3_.geometry_n(1).srid)
33
- end
34
-
35
- def test_srid_preserved_through_geom_functions
36
- geom1_ = @factory.point(-10, 20)
37
- geom2_ = geom1_.boundary
38
- assert_equal(_srid, geom2_.srid)
39
- end
40
-
41
- def test_srid_preserved_through_geometry_dup
42
- geom1_ = @factory.point(-10, 20)
43
- geom2_ = geom1_.clone
44
- assert_equal(_srid, geom2_.srid)
45
- end
46
-
47
- def test_dup_factory_results_in_equal_factories
48
- dup_factory_ = @factory.dup
49
- assert_equal(@factory, dup_factory_)
50
- assert_equal(_srid, dup_factory_.srid)
51
- end
52
-
53
- def test_dup_factory_results_in_equal_hashes
54
- dup_factory_ = @factory.dup
55
- assert_equal(@factory.hash, dup_factory_.hash)
56
- end
57
-
58
- def test_marshal_dump_load_factory
59
- data_ = ::Marshal.dump(@factory)
60
- factory2_ = ::Marshal.load(data_)
61
- assert_equal(@factory, factory2_)
62
- assert_equal(_srid, factory2_.srid)
63
- end
64
-
65
- if ::RGeo.yaml_supported?
66
-
67
- def test_psych_dump_load_factory
68
- data_ = ::Psych.dump(@factory)
69
- factory2_ = ::Psych.load(data_)
70
- assert_equal(@factory, factory2_)
71
- assert_equal(_srid, factory2_.srid)
72
- end
73
-
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,237 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Common tests for geometry collection implementations
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "rgeo"
8
-
9
- module RGeo
10
- module Tests # :nodoc:
11
- module Common # :nodoc:
12
- module GeometryCollectionTests # :nodoc:
13
- def setup
14
- @factory = create_factory
15
- @point1 = @factory.point(0, 0)
16
- @point2 = @factory.point(1, 0)
17
- @point3 = @factory.point(-4, 2)
18
- @point4 = @factory.point(-5, 3)
19
- @line1 = @factory.line_string([@point3, @point4])
20
- @line2 = @factory.line_string([@point3, @point4, @point1])
21
- @line3 = @factory.line(@point3, @point4)
22
- end
23
-
24
- def test_creation_simple
25
- geom_ = @factory.collection([@point1, @line1])
26
- assert_not_nil(geom_)
27
- assert(::RGeo::Feature::GeometryCollection === geom_)
28
- assert_equal(::RGeo::Feature::GeometryCollection, geom_.geometry_type)
29
- assert_equal(2, geom_.num_geometries)
30
- assert(@point1.eql?(geom_[0]))
31
- assert(@line1.eql?(geom_[1]))
32
- end
33
-
34
- def test_creation_empty
35
- geom_ = @factory.collection([])
36
- assert_not_nil(geom_)
37
- assert(::RGeo::Feature::GeometryCollection === geom_)
38
- assert_equal(::RGeo::Feature::GeometryCollection, geom_.geometry_type)
39
- assert_equal(0, geom_.num_geometries)
40
- assert_equal([], geom_.to_a)
41
- end
42
-
43
- def test_bounds_check
44
- geom_ = @factory.collection([@point1, @line1])
45
- assert_nil(geom_.geometry_n(200))
46
- assert_nil(geom_.geometry_n(-1))
47
- assert(@line1.eql?(geom_[-1]))
48
- end
49
-
50
- def test_creation_save_klass
51
- geom_ = @factory.collection([@point1, @line3])
52
- assert_not_nil(geom_)
53
- assert(::RGeo::Feature::GeometryCollection === geom_)
54
- assert_equal(::RGeo::Feature::GeometryCollection, geom_.geometry_type)
55
- assert_equal(2, geom_.num_geometries)
56
- assert(geom_[1].eql?(@line3))
57
- end
58
-
59
- def test_creation_compound
60
- geom1_ = @factory.collection([@point1, @line1])
61
- geom2_ = @factory.collection([@point2, geom1_])
62
- assert_not_nil(geom2_)
63
- assert(::RGeo::Feature::GeometryCollection === geom2_)
64
- assert_equal(::RGeo::Feature::GeometryCollection, geom2_.geometry_type)
65
- assert_equal(2, geom2_.num_geometries)
66
- assert(geom2_[1].eql?(geom1_))
67
- end
68
-
69
- def test_creation_compound_save_klass
70
- geom1_ = @factory.collection([@point1, @line3])
71
- geom2_ = @factory.collection([@point2, geom1_])
72
- ::GC.start
73
- assert_not_nil(geom2_)
74
- assert(::RGeo::Feature::GeometryCollection === geom2_)
75
- assert_equal(::RGeo::Feature::GeometryCollection, geom2_.geometry_type)
76
- assert_equal(2, geom2_.num_geometries)
77
- assert_equal(::RGeo::Feature::Line, geom2_[1][1].geometry_type)
78
- end
79
-
80
- def test_required_equivalences
81
- geom1_ = @factory.collection([@point1, @line1])
82
- geom2_ = @factory.collection([@point1, @line1])
83
- assert(geom1_.eql?(geom2_))
84
- assert(geom1_ == geom2_)
85
- end
86
-
87
- def test_fully_equal
88
- geom1_ = @factory.collection([@point1, @line1])
89
- geom2_ = @factory.collection([@point1, @line1])
90
- assert(geom1_.rep_equals?(geom2_))
91
- assert(geom1_.equals?(geom2_))
92
- end
93
-
94
- def test_geometrically_equal
95
- geom1_ = @factory.collection([@point2, @line2])
96
- geom2_ = @factory.collection([@point2, @line1, @line2])
97
- assert(!geom1_.rep_equals?(geom2_))
98
- assert(geom1_.equals?(geom2_))
99
- end
100
-
101
- def test_empty_equal
102
- geom1_ = @factory.collection([])
103
- geom2_ = @factory.collection([])
104
- assert(geom1_.rep_equals?(geom2_))
105
- assert(geom1_.equals?(geom2_))
106
- end
107
-
108
- def test_not_equal
109
- geom1_ = @factory.collection([@point1, @line1])
110
- geom2_ = @factory.collection([@point2, @line1])
111
- assert(!geom1_.rep_equals?(geom2_))
112
- assert(!geom1_.equals?(geom2_))
113
- end
114
-
115
- def test_hashes_equal_for_representationally_equivalent_objects
116
- geom1_ = @factory.collection([@point1, @line1])
117
- geom2_ = @factory.collection([@point1, @line1])
118
- assert_equal(geom1_.hash, geom2_.hash)
119
- end
120
-
121
- def test_nested_equality
122
- geom1_ = @factory.collection([@line1, @factory.collection([@point1, @point2])])
123
- geom2_ = @factory.collection([@line1, @factory.collection([@point1, @point2])])
124
- assert(geom1_.rep_equals?(geom2_))
125
- assert_equal(geom1_.hash, geom2_.hash)
126
- end
127
-
128
- def test_out_of_order_is_not_equal
129
- geom1_ = @factory.collection([@line1, @point2])
130
- geom2_ = @factory.collection([@point2, @line1])
131
- assert(!geom1_.rep_equals?(geom2_))
132
- assert_not_equal(geom1_.hash, geom2_.hash)
133
- end
134
-
135
- def test_wkt_creation_simple
136
- parsed_geom_ = @factory.parse_wkt("GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-4 2, -5 3))")
137
- built_geom_ = @factory.collection([@point1, @line1])
138
- assert(built_geom_.eql?(parsed_geom_))
139
- end
140
-
141
- def test_wkt_creation_empty
142
- parsed_geom_ = @factory.parse_wkt("GEOMETRYCOLLECTION EMPTY")
143
- assert_equal(0, parsed_geom_.num_geometries)
144
- assert_equal([], parsed_geom_.to_a)
145
- end
146
-
147
- def test_clone
148
- geom1_ = @factory.collection([@point1, @line1])
149
- geom2_ = geom1_.clone
150
- assert(geom1_.eql?(geom2_))
151
- assert_equal(::RGeo::Feature::GeometryCollection, geom2_.geometry_type)
152
- assert_equal(2, geom2_.num_geometries)
153
- assert(@point1.eql?(geom2_[0]))
154
- assert(@line1.eql?(geom2_[1]))
155
- end
156
-
157
- def test_type_check
158
- geom1_ = @factory.collection([@point1, @line1])
159
- assert(::RGeo::Feature::Geometry.check_type(geom1_))
160
- assert(!::RGeo::Feature::Point.check_type(geom1_))
161
- assert(::RGeo::Feature::GeometryCollection.check_type(geom1_))
162
- assert(!::RGeo::Feature::MultiPoint.check_type(geom1_))
163
- geom2_ = @factory.collection([@point1, @point2])
164
- assert(::RGeo::Feature::Geometry.check_type(geom2_))
165
- assert(!::RGeo::Feature::Point.check_type(geom2_))
166
- assert(::RGeo::Feature::GeometryCollection.check_type(geom2_))
167
- assert(!::RGeo::Feature::MultiPoint.check_type(geom2_))
168
- end
169
-
170
- def test_as_text_wkt_round_trip
171
- geom1_ = @factory.collection([@point1, @line1])
172
- text_ = geom1_.as_text
173
- geom2_ = @factory.parse_wkt(text_)
174
- assert(geom1_.eql?(geom2_))
175
- end
176
-
177
- def test_as_binary_wkb_round_trip
178
- geom1_ = @factory.collection([@point1, @line1])
179
- binary_ = geom1_.as_binary
180
- geom2_ = @factory.parse_wkb(binary_)
181
- assert(geom1_.eql?(geom2_))
182
- end
183
-
184
- def test_dimension
185
- geom1_ = @factory.collection([@point1, @line1])
186
- assert_equal(1, geom1_.dimension)
187
- geom2_ = @factory.collection([@point1, @point2])
188
- assert_equal(0, geom2_.dimension)
189
- geom3_ = @factory.collection([])
190
- assert_equal(-1, geom3_.dimension)
191
- end
192
-
193
- def test_is_empty
194
- geom1_ = @factory.collection([@point1, @line1])
195
- assert(!geom1_.is_empty?)
196
- geom2_ = @factory.collection([])
197
- assert(geom2_.is_empty?)
198
- end
199
-
200
- def test_empty_collection_envelope
201
- empty_ = @factory.collection([])
202
- envelope_ = empty_.envelope
203
- assert_equal(Feature::GeometryCollection, envelope_.geometry_type)
204
- assert_equal(0, envelope_.num_geometries)
205
- end
206
-
207
- def test_empty_collection_boundary
208
- empty_ = @factory.collection([])
209
- assert_nil(empty_.boundary)
210
- end
211
-
212
- def test_each_block
213
- geom1_ = @factory.collection([@point1, @line1])
214
- i_ = 0
215
- geom1_.each do |g_|
216
- if i_ == 0
217
- assert_equal(@point1, g_)
218
- else
219
- assert_equal(@line1, g_)
220
- end
221
- i_ += 1
222
- end
223
- end
224
-
225
- def test_each_enumerator
226
- geom1_ = @factory.collection([@point1, @line1])
227
- enum_ = geom1_.each
228
- assert_equal(@point1, enum_.next)
229
- assert_equal(@line1, enum_.next)
230
- assert_raise(::StopIteration) do
231
- enum_.next
232
- end
233
- end
234
- end
235
- end
236
- end
237
- end