rgeo 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +8 -0
- data/README.rdoc +4 -4
- data/Version +1 -1
- data/ext/geos_c_impl/extconf.rb +1 -0
- data/ext/geos_c_impl/factory.c +118 -5
- data/ext/geos_c_impl/factory.h +24 -1
- data/ext/geos_c_impl/geometry.c +42 -53
- data/ext/geos_c_impl/geometry_collection.c +137 -54
- data/ext/geos_c_impl/geometry_collection.h +9 -0
- data/ext/geos_c_impl/line_string.c +88 -45
- data/ext/geos_c_impl/point.c +31 -17
- data/ext/geos_c_impl/polygon.c +50 -22
- data/ext/geos_c_impl/polygon.h +9 -0
- data/ext/geos_c_impl/preface.h +10 -0
- data/lib/rgeo/cartesian/factory.rb +9 -1
- data/lib/rgeo/coord_sys/cs/entities.rb +10 -1
- data/lib/rgeo/coord_sys/proj4.rb +1 -1
- data/lib/rgeo/feature/types.rb +29 -5
- data/lib/rgeo/geographic/factory.rb +5 -0
- data/lib/rgeo/geographic/projected_feature_classes.rb +3 -47
- data/lib/rgeo/geographic/projected_feature_methods.rb +69 -0
- data/lib/rgeo/geographic/spherical_feature_classes.rb +1 -74
- data/lib/rgeo/geographic/spherical_feature_methods.rb +84 -0
- data/lib/rgeo/geographic/spherical_math.rb +3 -3
- data/lib/rgeo/geos.rb +17 -9
- data/lib/rgeo/geos/{factory.rb → capi_factory.rb} +36 -15
- data/lib/rgeo/geos/{impl_additions.rb → capi_feature_classes.rb} +127 -16
- data/lib/rgeo/geos/ffi_factory.rb +55 -41
- data/lib/rgeo/geos/ffi_feature_classes.rb +168 -0
- data/lib/rgeo/geos/{ffi_classes.rb → ffi_feature_methods.rb} +56 -57
- data/lib/rgeo/geos/interface.rb +5 -5
- data/lib/rgeo/geos/utils.rb +7 -0
- data/lib/rgeo/geos/zm_factory.rb +40 -12
- data/lib/rgeo/geos/zm_feature_classes.rb +165 -0
- data/lib/rgeo/geos/{zm_impl.rb → zm_feature_methods.rb} +33 -52
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +8 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +8 -0
- data/lib/rgeo/impl_helper/basic_point_methods.rb +5 -0
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +8 -0
- data/test/common/factory_tests.rb +8 -2
- data/test/common/geometry_collection_tests.rb +23 -0
- data/test/common/line_string_tests.rb +25 -0
- data/test/common/multi_line_string_tests.rb +7 -0
- data/test/common/multi_point_tests.rb +7 -0
- data/test/common/multi_polygon_tests.rb +7 -0
- data/test/common/point_tests.rb +21 -0
- data/test/common/polygon_tests.rb +15 -0
- data/test/coord_sys/tc_proj4.rb +8 -1
- data/test/geos_capi/tc_misc.rb +1 -1
- data/test/tc_mixins.rb +1 -1
- metadata +9 -7
@@ -113,6 +113,14 @@ module RGeo
|
|
113
113
|
end
|
114
114
|
|
115
115
|
|
116
|
+
def hash
|
117
|
+
@hash ||= begin
|
118
|
+
hash_ = [geometry_type, @exterior_ring].hash
|
119
|
+
@interior_rings.inject(hash_){ |h_, r_| (1664525 * h_ + r_.hash).hash }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
116
124
|
def _copy_state_from(obj_) # :nodoc:
|
117
125
|
super
|
118
126
|
@exterior_ring = obj_.exterior_ring
|
@@ -76,20 +76,26 @@ module RGeo
|
|
76
76
|
end
|
77
77
|
|
78
78
|
|
79
|
-
def
|
79
|
+
def test_srid_preserved_through_geometry_dup
|
80
80
|
geom1_ = @factory.point(-10, 20)
|
81
81
|
geom2_ = geom1_.clone
|
82
82
|
assert_equal(_srid, geom2_.srid)
|
83
83
|
end
|
84
84
|
|
85
85
|
|
86
|
-
def
|
86
|
+
def test_dup_factory_results_in_equal_factories
|
87
87
|
dup_factory_ = @factory.dup
|
88
88
|
assert_equal(@factory, dup_factory_)
|
89
89
|
assert_equal(_srid, dup_factory_.srid)
|
90
90
|
end
|
91
91
|
|
92
92
|
|
93
|
+
def test_dup_factory_results_in_equal_hashes
|
94
|
+
dup_factory_ = @factory.dup
|
95
|
+
assert_equal(@factory.hash, dup_factory_.hash)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
93
99
|
def test_marshal_dump_load_factory
|
94
100
|
data_ = ::Marshal.dump(@factory)
|
95
101
|
factory2_ = ::Marshal.load(data_)
|
@@ -158,6 +158,29 @@ module RGeo
|
|
158
158
|
end
|
159
159
|
|
160
160
|
|
161
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
162
|
+
geom1_ = @factory.collection([@point1, @line1])
|
163
|
+
geom2_ = @factory.collection([@point1, @line1])
|
164
|
+
assert_equal(geom1_.hash, geom2_.hash)
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
def test_nested_equality
|
169
|
+
geom1_ = @factory.collection([@line1, @factory.collection([@point1, @point2])])
|
170
|
+
geom2_ = @factory.collection([@line1, @factory.collection([@point1, @point2])])
|
171
|
+
assert(geom1_.rep_equals?(geom2_))
|
172
|
+
assert_equal(geom1_.hash, geom2_.hash)
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def test_out_of_order_is_not_equal
|
177
|
+
geom1_ = @factory.collection([@line1, @point2])
|
178
|
+
geom2_ = @factory.collection([@point2, @line1])
|
179
|
+
assert(!geom1_.rep_equals?(geom2_))
|
180
|
+
assert_not_equal(geom1_.hash, geom2_.hash)
|
181
|
+
end
|
182
|
+
|
183
|
+
|
161
184
|
def test_wkt_creation_simple
|
162
185
|
parsed_geom_ = @factory.parse_wkt('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-4 2, -5 3))')
|
163
186
|
built_geom_ = @factory.collection([@point1, @line1])
|
@@ -240,6 +240,31 @@ module RGeo
|
|
240
240
|
end
|
241
241
|
|
242
242
|
|
243
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
244
|
+
point1_ = @factory.point(0, 0)
|
245
|
+
point2_ = @factory.point(0, 1)
|
246
|
+
point3_ = @factory.point(1, 0)
|
247
|
+
line1_ = @factory.line_string([point1_, point2_, point3_])
|
248
|
+
point4_ = @factory.point(0, 0)
|
249
|
+
point5_ = @factory.point(0, 1)
|
250
|
+
point6_ = @factory.point(1, 0)
|
251
|
+
line2_ = @factory.line_string([point4_, point5_, point6_])
|
252
|
+
assert_equal(line1_.hash, line2_.hash)
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
def test_out_of_order_is_not_equal
|
257
|
+
point1_ = @factory.point(0, 0)
|
258
|
+
point2_ = @factory.point(0, 1)
|
259
|
+
line1_ = @factory.line_string([point1_, point2_])
|
260
|
+
point4_ = @factory.point(0, 1)
|
261
|
+
point5_ = @factory.point(0, 0)
|
262
|
+
line2_ = @factory.line_string([point4_, point5_])
|
263
|
+
assert(!line1_.rep_equals?(line2_))
|
264
|
+
assert_not_equal(line1_.hash, line2_.hash)
|
265
|
+
end
|
266
|
+
|
267
|
+
|
243
268
|
def test_wkt_creation
|
244
269
|
line1_ = @factory.parse_wkt('LINESTRING(21 22, 11 12)')
|
245
270
|
assert_equal(@factory.point(21, 22), line1_.point_n(0))
|
@@ -136,6 +136,13 @@ module RGeo
|
|
136
136
|
end
|
137
137
|
|
138
138
|
|
139
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
140
|
+
geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
|
141
|
+
geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
|
142
|
+
assert_equal(geom1_.hash, geom2_.hash)
|
143
|
+
end
|
144
|
+
|
145
|
+
|
139
146
|
def test_wkt_creation_simple
|
140
147
|
parsed_geom_ = @factory.parse_wkt('MULTILINESTRING((0 0, 1 0), (-4 2, -7 6, 5 11))')
|
141
148
|
built_geom_ = @factory.multi_line_string([@linestring1, @linestring2])
|
@@ -128,6 +128,13 @@ module RGeo
|
|
128
128
|
end
|
129
129
|
|
130
130
|
|
131
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
132
|
+
geom1_ = @factory.multi_point([@point1, @point2])
|
133
|
+
geom2_ = @factory.multi_point([@point1, @point2])
|
134
|
+
assert_equal(geom1_.hash, geom2_.hash)
|
135
|
+
end
|
136
|
+
|
137
|
+
|
131
138
|
def test_wkt_creation_simple
|
132
139
|
parsed_geom_ = @factory.parse_wkt('MULTIPOINT((0 0), (-4 2), (-5 3))')
|
133
140
|
built_geom_ = @factory.multi_point([@point1, @point3, @point4])
|
@@ -135,6 +135,13 @@ module RGeo
|
|
135
135
|
end
|
136
136
|
|
137
137
|
|
138
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
139
|
+
geom1_ = @factory.multi_polygon([@poly1, @poly2])
|
140
|
+
geom2_ = @factory.multi_polygon([@poly1, @poly2])
|
141
|
+
assert_equal(geom1_.hash, geom2_.hash)
|
142
|
+
end
|
143
|
+
|
144
|
+
|
138
145
|
def test_wkt_creation_simple
|
139
146
|
parsed_geom_ = @factory.parse_wkt('MULTIPOLYGON(((0 0, 0 -10, -10 0, 0 0)), ((0 0, 0 10, 10 10, 10 0, 0 0), (4 4, 5 6, 6 4, 4 4)))')
|
140
147
|
built_geom_ = @factory.multi_polygon([@poly1, @poly2])
|
data/test/common/point_tests.rb
CHANGED
@@ -164,6 +164,27 @@ module RGeo
|
|
164
164
|
end
|
165
165
|
|
166
166
|
|
167
|
+
def test_out_of_order_is_not_equal
|
168
|
+
point1_ = @factory.point(11, 12)
|
169
|
+
point2_ = @factory.point(12, 11)
|
170
|
+
assert_not_equal(point1_, point2_)
|
171
|
+
assert_not_equal(point1_.hash, point2_.hash)
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
176
|
+
point1_ = @factory.point(11, 12)
|
177
|
+
point2_ = @factory.point(11, 12)
|
178
|
+
assert_equal(point1_.hash, point2_.hash)
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
def test_point_as_hash_key
|
183
|
+
hash_ = {@factory.point(11, 12) => :hello}
|
184
|
+
assert_equal(:hello, hash_[@factory.point(11, 12)])
|
185
|
+
end
|
186
|
+
|
187
|
+
|
167
188
|
def test_disjoint
|
168
189
|
point1_ = @factory.point(11, 12)
|
169
190
|
point2_ = @factory.point(11, 12)
|
@@ -140,6 +140,21 @@ module RGeo
|
|
140
140
|
end
|
141
141
|
|
142
142
|
|
143
|
+
def test_hashes_equal_for_representationally_equivalent_objects
|
144
|
+
point1_ = @factory.point(0, 0)
|
145
|
+
point2_ = @factory.point(0, 1)
|
146
|
+
point3_ = @factory.point(1, 0)
|
147
|
+
exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
|
148
|
+
poly1_ = @factory.polygon(exterior1_)
|
149
|
+
point4_ = @factory.point(0, 0)
|
150
|
+
point5_ = @factory.point(0, 1)
|
151
|
+
point6_ = @factory.point(1, 0)
|
152
|
+
exterior2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
|
153
|
+
poly2_ = @factory.polygon(exterior2_)
|
154
|
+
assert_equal(poly1_.hash, poly2_.hash)
|
155
|
+
end
|
156
|
+
|
157
|
+
|
143
158
|
def test_wkt_creation_simple
|
144
159
|
parsed_poly_ = @factory.parse_wkt('POLYGON((0 0, 0 1, 1 0, 0 0))')
|
145
160
|
point1_ = @factory.point(0, 0)
|
data/test/coord_sys/tc_proj4.rb
CHANGED
@@ -108,11 +108,18 @@ module RGeo
|
|
108
108
|
|
109
109
|
def test_equivalence
|
110
110
|
proj1_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
111
|
-
proj2_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
111
|
+
proj2_ = ::RGeo::CoordSys::Proj4.create(' +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
112
112
|
assert_equal(proj1_, proj2_)
|
113
113
|
end
|
114
114
|
|
115
115
|
|
116
|
+
def test_hashes_equal_for_equivalent_objects
|
117
|
+
proj1_ = ::RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
118
|
+
proj2_ = ::RGeo::CoordSys::Proj4.create(' +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
119
|
+
assert_equal(proj1_.hash, proj2_.hash)
|
120
|
+
end
|
121
|
+
|
122
|
+
|
116
123
|
def test_point_projection_cast
|
117
124
|
geography_ = ::RGeo::Geos.factory(:proj4 => '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', :srid =>4326)
|
118
125
|
projection_ = ::RGeo::Geos.factory(:proj4 => '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs', :srid => 27700)
|
data/test/geos_capi/tc_misc.rb
CHANGED
data/test/tc_mixins.rb
CHANGED
@@ -86,7 +86,7 @@ module RGeo
|
|
86
86
|
|
87
87
|
def test_basic_mixin_geos_capi
|
88
88
|
factory_ = ::RGeo::Geos.factory(:native_interface => :capi)
|
89
|
-
assert_equal(::RGeo::Geos::
|
89
|
+
assert_equal(::RGeo::Geos::CAPIPointImpl, factory_.point(1, 1).class)
|
90
90
|
assert(factory_.point(1, 1).class.include?(Mixin1))
|
91
91
|
assert(!factory_.point(1, 1).class.include?(Mixin2))
|
92
92
|
assert(factory_.point(1, 1).respond_to?(:mixin1_method))
|
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: 0.3.
|
4
|
+
version: 0.3.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: RGeo is a geospatial data library for Ruby. It provides an implementation
|
15
15
|
of the Open Geospatial Consortium's Simple Features Specification, used by most
|
@@ -75,14 +75,16 @@ files:
|
|
75
75
|
- lib/rgeo/geographic/spherical_feature_methods.rb
|
76
76
|
- lib/rgeo/geographic/spherical_math.rb
|
77
77
|
- lib/rgeo/geographic.rb
|
78
|
-
- lib/rgeo/geos/
|
79
|
-
- lib/rgeo/geos/
|
78
|
+
- lib/rgeo/geos/capi_factory.rb
|
79
|
+
- lib/rgeo/geos/capi_feature_classes.rb
|
80
80
|
- lib/rgeo/geos/ffi_factory.rb
|
81
|
-
- lib/rgeo/geos/
|
81
|
+
- lib/rgeo/geos/ffi_feature_classes.rb
|
82
|
+
- lib/rgeo/geos/ffi_feature_methods.rb
|
82
83
|
- lib/rgeo/geos/interface.rb
|
83
84
|
- lib/rgeo/geos/utils.rb
|
84
85
|
- lib/rgeo/geos/zm_factory.rb
|
85
|
-
- lib/rgeo/geos/
|
86
|
+
- lib/rgeo/geos/zm_feature_classes.rb
|
87
|
+
- lib/rgeo/geos/zm_feature_methods.rb
|
86
88
|
- lib/rgeo/geos.rb
|
87
89
|
- lib/rgeo/impl_helper/basic_geometry_collection_methods.rb
|
88
90
|
- lib/rgeo/impl_helper/basic_geometry_methods.rb
|
@@ -201,7 +203,7 @@ files:
|
|
201
203
|
- README.rdoc
|
202
204
|
- Spatial_Programming_With_RGeo.rdoc
|
203
205
|
- Version
|
204
|
-
homepage: http://
|
206
|
+
homepage: http://dazuma.github.com/rgeo
|
205
207
|
licenses: []
|
206
208
|
post_install_message:
|
207
209
|
rdoc_options: []
|