rgeo 0.2.9 → 0.3.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 (67) hide show
  1. data/History.rdoc +11 -0
  2. data/README.rdoc +3 -3
  3. data/Spatial_Programming_With_RGeo.rdoc +19 -8
  4. data/Version +1 -1
  5. data/ext/geos_c_impl/factory.c +1 -0
  6. data/ext/geos_c_impl/factory.h +1 -0
  7. data/ext/geos_c_impl/geometry.c +4 -5
  8. data/ext/geos_c_impl/geometry_collection.c +15 -0
  9. data/ext/geos_c_impl/line_string.c +10 -0
  10. data/ext/geos_c_impl/point.c +2 -0
  11. data/ext/geos_c_impl/polygon.c +4 -0
  12. data/lib/rgeo/cartesian/feature_classes.rb +23 -17
  13. data/lib/rgeo/cartesian/feature_methods.rb +20 -1
  14. data/lib/rgeo/feature.rb +1 -0
  15. data/lib/rgeo/feature/curve.rb +1 -2
  16. data/lib/rgeo/feature/geometry_collection.rb +1 -1
  17. data/lib/rgeo/feature/line.rb +1 -1
  18. data/lib/rgeo/feature/line_string.rb +1 -2
  19. data/lib/rgeo/feature/linear_ring.rb +1 -2
  20. data/lib/rgeo/feature/mixins.rb +198 -0
  21. data/lib/rgeo/feature/multi_curve.rb +1 -2
  22. data/lib/rgeo/feature/multi_line_string.rb +1 -2
  23. data/lib/rgeo/feature/multi_point.rb +1 -2
  24. data/lib/rgeo/feature/multi_polygon.rb +1 -2
  25. data/lib/rgeo/feature/multi_surface.rb +1 -2
  26. data/lib/rgeo/feature/point.rb +1 -2
  27. data/lib/rgeo/feature/polygon.rb +1 -3
  28. data/lib/rgeo/feature/surface.rb +1 -2
  29. data/lib/rgeo/feature/types.rb +27 -0
  30. data/lib/rgeo/geographic/projected_feature_classes.rb +31 -4
  31. data/lib/rgeo/geographic/projected_feature_methods.rb +2 -1
  32. data/lib/rgeo/geographic/spherical_feature_classes.rb +30 -3
  33. data/lib/rgeo/geos.rb +22 -0
  34. data/lib/rgeo/geos/factory.rb +11 -5
  35. data/lib/rgeo/geos/ffi_classes.rb +655 -0
  36. data/lib/rgeo/geos/ffi_factory.rb +503 -0
  37. data/lib/rgeo/geos/impl_additions.rb +1 -1
  38. data/lib/rgeo/geos/interface.rb +63 -8
  39. data/lib/rgeo/geos/zm_factory.rb +10 -4
  40. data/test/common/geometry_collection_tests.rb +1 -3
  41. data/test/coord_sys/tc_ogc_cs.rb +13 -2
  42. data/test/coord_sys/tc_proj4_srs_data.rb +1 -1
  43. data/test/{geos → geos_capi}/tc_factory.rb +2 -2
  44. data/test/{geos → geos_capi}/tc_geometry_collection.rb +2 -2
  45. data/test/{geos → geos_capi}/tc_line_string.rb +2 -2
  46. data/test/{geos → geos_capi}/tc_misc.rb +6 -2
  47. data/test/{geos → geos_capi}/tc_multi_line_string.rb +2 -2
  48. data/test/{geos → geos_capi}/tc_multi_point.rb +2 -2
  49. data/test/{geos → geos_capi}/tc_multi_polygon.rb +2 -2
  50. data/test/{geos → geos_capi}/tc_parsing_unparsing.rb +2 -2
  51. data/test/{geos → geos_capi}/tc_point.rb +2 -2
  52. data/test/{geos → geos_capi}/tc_polygon.rb +2 -2
  53. data/test/{geos → geos_capi}/tc_zmfactory.rb +2 -2
  54. data/test/geos_ffi/tc_factory.rb +91 -0
  55. data/test/geos_ffi/tc_geometry_collection.rb +62 -0
  56. data/test/geos_ffi/tc_line_string.rb +62 -0
  57. data/test/geos_ffi/tc_misc.rb +69 -0
  58. data/test/geos_ffi/tc_multi_line_string.rb +62 -0
  59. data/test/geos_ffi/tc_multi_point.rb +62 -0
  60. data/test/geos_ffi/tc_multi_polygon.rb +64 -0
  61. data/test/geos_ffi/tc_parsing_unparsing.rb +81 -0
  62. data/test/geos_ffi/tc_point.rb +87 -0
  63. data/test/geos_ffi/tc_polygon.rb +86 -0
  64. data/test/geos_ffi/tc_zmfactory.rb +86 -0
  65. data/test/tc_mixins.rb +188 -0
  66. data/test/tc_types.rb +77 -0
  67. metadata +54 -25
@@ -0,0 +1,87 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the GEOS point implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+ require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module GeosFFI # :nodoc:
46
+
47
+ class TestPoint < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def setup
51
+ @factory = ::RGeo::Geos.factory(:native_interface => :ffi)
52
+ @zfactory = ::RGeo::Geos.factory(:has_z_coordinate => true, :native_interface => :ffi)
53
+ @mfactory = ::RGeo::Geos.factory(:has_m_coordinate => true, :native_interface => :ffi)
54
+ @zmfactory = ::RGeo::Geos.factory(:has_z_coordinate => true, :has_m_coordinate => true,
55
+ :native_interface => :ffi)
56
+ end
57
+
58
+
59
+ include ::RGeo::Tests::Common::PointTests
60
+
61
+
62
+ def test_has_no_projection
63
+ point_ = @factory.point(21, -22)
64
+ assert(!point_.respond_to?(:projection))
65
+ end
66
+
67
+
68
+ def test_srid
69
+ point_ = @factory.point(11, 12)
70
+ assert_equal(0, point_.srid)
71
+ end
72
+
73
+
74
+ def test_distance
75
+ point1_ = @factory.point(11, 12)
76
+ point2_ = @factory.point(11, 12)
77
+ point3_ = @factory.point(13, 12)
78
+ assert_equal(0, point1_.distance(point2_))
79
+ assert_equal(2, point1_.distance(point3_))
80
+ end
81
+
82
+
83
+ end
84
+
85
+ end
86
+ end
87
+ end if ::RGeo::Geos.ffi_supported?
@@ -0,0 +1,86 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the GEOS polygon implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+ require ::File.expand_path('../common/polygon_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module GeosFFI # :nodoc:
46
+
47
+ class TestPolygon < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def setup
51
+ @factory = ::RGeo::Geos.factory(:native_interface => :ffi)
52
+ end
53
+
54
+
55
+ include ::RGeo::Tests::Common::PolygonTests
56
+
57
+
58
+ def test_intersection
59
+ point1_ = @factory.point(0, 0)
60
+ point2_ = @factory.point(0, 2)
61
+ point3_ = @factory.point(2, 2)
62
+ point4_ = @factory.point(2, 0)
63
+ poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
64
+ poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
65
+ poly3_ = poly1_.intersection(poly2_)
66
+ assert_equal(poly2_, poly3_)
67
+ end
68
+
69
+
70
+ def test_union
71
+ point1_ = @factory.point(0, 0)
72
+ point2_ = @factory.point(0, 2)
73
+ point3_ = @factory.point(2, 2)
74
+ point4_ = @factory.point(2, 0)
75
+ poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
76
+ poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
77
+ poly3_ = poly1_.union(poly2_)
78
+ assert_equal(poly1_, poly3_)
79
+ end
80
+
81
+
82
+ end
83
+
84
+ end
85
+ end
86
+ end if ::RGeo::Geos.ffi_supported?
@@ -0,0 +1,86 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the GEOS point implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module GeosFFI # :nodoc:
44
+
45
+ class TestZMFactory < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def setup
49
+ @factory = ::RGeo::Geos.factory(:has_z_coordinate => true, :has_m_coordinate => true,
50
+ :srid => 1000, :buffer_resolution => 2, :native_interface => :ffi)
51
+ end
52
+
53
+
54
+ def test_factory_parts
55
+ assert_equal(1000, @factory.srid)
56
+ assert_equal(1000, @factory.z_factory.srid)
57
+ assert_equal(1000, @factory.m_factory.srid)
58
+ assert_equal(2, @factory.buffer_resolution)
59
+ assert_equal(2, @factory.z_factory.buffer_resolution)
60
+ assert_equal(2, @factory.m_factory.buffer_resolution)
61
+ assert(@factory.property(:has_z_coordinate))
62
+ assert(@factory.property(:has_m_coordinate))
63
+ assert(@factory.z_factory.property(:has_z_coordinate))
64
+ assert(!@factory.z_factory.property(:has_m_coordinate))
65
+ assert(!@factory.m_factory.property(:has_z_coordinate))
66
+ assert(@factory.m_factory.property(:has_m_coordinate))
67
+ end
68
+
69
+
70
+ def test_4d_point
71
+ point_ = @factory.point(1, 2, 3, 4)
72
+ assert_equal(Feature::Point, point_.geometry_type)
73
+ assert_equal(3, point_.z)
74
+ assert_equal(4, point_.m)
75
+ assert_equal(3, point_.z_geometry.z)
76
+ assert_nil(point_.z_geometry.m)
77
+ assert_nil(point_.m_geometry.z)
78
+ assert_equal(4, point_.m_geometry.m)
79
+ end
80
+
81
+
82
+ end
83
+
84
+ end
85
+ end
86
+ end if ::RGeo::Geos.ffi_supported?
data/test/tc_mixins.rb ADDED
@@ -0,0 +1,188 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for mixin system
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+
44
+ class TestMixins < ::Test::Unit::TestCase # :nodoc:
45
+
46
+
47
+ module Mixin1 # :nodoc:
48
+ def mixin1_method
49
+ end
50
+ end
51
+
52
+ module Mixin2 # :nodoc:
53
+ def mixin2_method
54
+ end
55
+ end
56
+
57
+ ::RGeo::Feature::MixinCollection::GLOBAL.for_type(::RGeo::Feature::Point).add(Mixin1)
58
+ ::RGeo::Feature::MixinCollection::GLOBAL.for_type(::RGeo::Feature::GeometryCollection).add(Mixin1)
59
+ ::RGeo::Feature::MixinCollection::GLOBAL.for_type(::RGeo::Feature::MultiCurve).add(Mixin2)
60
+
61
+
62
+ def test_basic_mixin_cartesian
63
+ factory_ = ::RGeo::Cartesian.simple_factory
64
+ assert_equal(::RGeo::Cartesian::PointImpl, factory_.point(1, 1).class)
65
+ assert(factory_.point(1, 1).class.include?(Mixin1))
66
+ assert(!factory_.point(1, 1).class.include?(Mixin2))
67
+ assert(factory_.point(1, 1).respond_to?(:mixin1_method))
68
+ assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
69
+ end
70
+
71
+
72
+ def test_inherited_mixin_cartesian
73
+ factory_ = ::RGeo::Cartesian.simple_factory
74
+ assert(factory_.collection([]).class.include?(Mixin1))
75
+ assert(!factory_.collection([]).class.include?(Mixin2))
76
+ assert(factory_.collection([]).respond_to?(:mixin1_method))
77
+ assert(!factory_.collection([]).respond_to?(:mixin2_method))
78
+ assert(factory_.multi_line_string([]).class.include?(Mixin1))
79
+ assert(factory_.multi_line_string([]).class.include?(Mixin2))
80
+ assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
81
+ assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
82
+ end
83
+
84
+
85
+ if ::RGeo::Geos.capi_supported?
86
+
87
+ def test_basic_mixin_geos_capi
88
+ factory_ = ::RGeo::Geos.factory(:native_interface => :capi)
89
+ assert_equal(::RGeo::Geos::PointImpl, factory_.point(1, 1).class)
90
+ assert(factory_.point(1, 1).class.include?(Mixin1))
91
+ assert(!factory_.point(1, 1).class.include?(Mixin2))
92
+ assert(factory_.point(1, 1).respond_to?(:mixin1_method))
93
+ assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
94
+ end
95
+
96
+
97
+ def test_inherited_mixin_geos_capi
98
+ factory_ = ::RGeo::Geos.factory(:native_interface => :capi)
99
+ assert(factory_.collection([]).class.include?(Mixin1))
100
+ assert(!factory_.collection([]).class.include?(Mixin2))
101
+ assert(factory_.collection([]).respond_to?(:mixin1_method))
102
+ assert(!factory_.collection([]).respond_to?(:mixin2_method))
103
+ assert(factory_.multi_line_string([]).class.include?(Mixin1))
104
+ assert(factory_.multi_line_string([]).class.include?(Mixin2))
105
+ assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
106
+ assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
107
+ end
108
+
109
+ end
110
+
111
+
112
+ if ::RGeo::Geos.ffi_supported?
113
+
114
+ def test_basic_mixin_geos_ffi
115
+ factory_ = ::RGeo::Geos.factory(:native_interface => :ffi)
116
+ assert_equal(::RGeo::Geos::FFIPointImpl, factory_.point(1, 1).class)
117
+ assert(factory_.point(1, 1).class.include?(Mixin1))
118
+ assert(!factory_.point(1, 1).class.include?(Mixin2))
119
+ assert(factory_.point(1, 1).respond_to?(:mixin1_method))
120
+ assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
121
+ end
122
+
123
+
124
+ def test_inherited_mixin_geos_ffi
125
+ factory_ = ::RGeo::Geos.factory(:native_interface => :ffi)
126
+ assert(factory_.collection([]).class.include?(Mixin1))
127
+ assert(!factory_.collection([]).class.include?(Mixin2))
128
+ assert(factory_.collection([]).respond_to?(:mixin1_method))
129
+ assert(!factory_.collection([]).respond_to?(:mixin2_method))
130
+ assert(factory_.multi_line_string([]).class.include?(Mixin1))
131
+ assert(factory_.multi_line_string([]).class.include?(Mixin2))
132
+ assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
133
+ assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
134
+ end
135
+
136
+ end
137
+
138
+
139
+ def test_basic_mixin_spherical
140
+ factory_ = ::RGeo::Geographic.spherical_factory
141
+ assert_equal(::RGeo::Geographic::SphericalPointImpl, factory_.point(1, 1).class)
142
+ assert(factory_.point(1, 1).class.include?(Mixin1))
143
+ assert(!factory_.point(1, 1).class.include?(Mixin2))
144
+ assert(factory_.point(1, 1).respond_to?(:mixin1_method))
145
+ assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
146
+ end
147
+
148
+
149
+ def test_inherited_mixin_spherical
150
+ factory_ = ::RGeo::Geographic.spherical_factory
151
+ assert(factory_.collection([]).class.include?(Mixin1))
152
+ assert(!factory_.collection([]).class.include?(Mixin2))
153
+ assert(factory_.collection([]).respond_to?(:mixin1_method))
154
+ assert(!factory_.collection([]).respond_to?(:mixin2_method))
155
+ assert(factory_.multi_line_string([]).class.include?(Mixin1))
156
+ assert(factory_.multi_line_string([]).class.include?(Mixin2))
157
+ assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
158
+ assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
159
+ end
160
+
161
+
162
+ def test_basic_mixin_simple_mercator
163
+ factory_ = ::RGeo::Geographic.simple_mercator_factory
164
+ assert_equal(::RGeo::Geographic::ProjectedPointImpl, factory_.point(1, 1).class)
165
+ assert(factory_.point(1, 1).class.include?(Mixin1))
166
+ assert(!factory_.point(1, 1).class.include?(Mixin2))
167
+ assert(factory_.point(1, 1).respond_to?(:mixin1_method))
168
+ assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
169
+ end
170
+
171
+
172
+ def test_inherited_mixin_simple_mercator
173
+ factory_ = ::RGeo::Geographic.simple_mercator_factory
174
+ assert(factory_.collection([]).class.include?(Mixin1))
175
+ assert(!factory_.collection([]).class.include?(Mixin2))
176
+ assert(factory_.collection([]).respond_to?(:mixin1_method))
177
+ assert(!factory_.collection([]).respond_to?(:mixin2_method))
178
+ assert(factory_.multi_line_string([]).class.include?(Mixin1))
179
+ assert(factory_.multi_line_string([]).class.include?(Mixin2))
180
+ assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
181
+ assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
182
+ end
183
+
184
+
185
+ end
186
+
187
+ end
188
+ end