rgeo 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -0
- data/README.rdoc +23 -7
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +1 -1
- data/{lib/rgeo/geography/simple_mercator.rb → ext/proj4_c_impl/extconf.rb} +35 -30
- data/ext/proj4_c_impl/main.c +256 -0
- data/lib/rgeo.rb +54 -42
- data/lib/rgeo/active_record/arel_modifications.rb +2 -2
- data/lib/rgeo/active_record/base_modifications.rb +1 -1
- data/lib/rgeo/active_record/mysql_common.rb +12 -12
- data/lib/rgeo/all.rb +5 -4
- data/lib/rgeo/cartesian.rb +3 -2
- data/lib/rgeo/cartesian/bounding_box.rb +9 -9
- data/lib/rgeo/cartesian/factory.rb +30 -13
- data/lib/rgeo/cartesian/feature_classes.rb +33 -33
- data/lib/rgeo/cartesian/interface.rb +2 -2
- data/lib/rgeo/{geography/all.rb → coord_sys.rb} +22 -4
- data/lib/rgeo/coord_sys/proj4.rb +275 -0
- data/lib/rgeo/{errors.rb → error.rb} +5 -6
- data/lib/rgeo/{features.rb → feature.rb} +22 -20
- data/lib/rgeo/{features → feature}/curve.rb +6 -6
- data/lib/rgeo/{features → feature}/factory.rb +19 -3
- data/lib/rgeo/{features → feature}/factory_generator.rb +1 -1
- data/lib/rgeo/{features → feature}/geometry.rb +34 -34
- data/lib/rgeo/{features → feature}/geometry_collection.rb +4 -4
- data/lib/rgeo/{features → feature}/line.rb +1 -1
- data/lib/rgeo/{features → feature}/line_string.rb +4 -4
- data/lib/rgeo/{features → feature}/linear_ring.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_curve.rb +3 -3
- data/lib/rgeo/{features → feature}/multi_line_string.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_point.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_polygon.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_surface.rb +4 -4
- data/lib/rgeo/{features → feature}/point.rb +5 -5
- data/lib/rgeo/{features → feature}/polygon.rb +5 -5
- data/lib/rgeo/{features → feature}/surface.rb +4 -4
- data/lib/rgeo/feature/types.rb +301 -0
- data/lib/rgeo/geo_json.rb +1 -1
- data/lib/rgeo/geo_json/coder.rb +13 -13
- data/lib/rgeo/geo_json/interface.rb +2 -2
- data/lib/rgeo/geography.rb +33 -6
- data/lib/rgeo/geography/factory.rb +82 -39
- data/lib/rgeo/geography/interface.rb +135 -89
- data/lib/rgeo/geography/proj4_projector.rb +98 -0
- data/lib/rgeo/geography/projected_feature_classes.rb +213 -0
- data/lib/rgeo/geography/projected_feature_methods.rb +228 -0
- data/lib/rgeo/geography/projected_window.rb +7 -7
- data/lib/rgeo/geography/simple_mercator_projector.rb +133 -0
- data/lib/rgeo/geography/spherical_feature_classes.rb +212 -0
- data/lib/rgeo/geography/{simple_spherical/feature_methods.rb → spherical_feature_methods.rb} +39 -43
- data/lib/rgeo/geography/{simple_spherical/calculations.rb → spherical_math.rb} +7 -7
- data/lib/rgeo/geos.rb +1 -1
- data/lib/rgeo/geos/factory.rb +37 -19
- data/lib/rgeo/geos/impl_additions.rb +10 -11
- data/lib/rgeo/geos/interface.rb +1 -1
- data/lib/rgeo/geos/zm_factory.rb +15 -15
- data/lib/rgeo/geos/zm_impl.rb +10 -10
- data/lib/rgeo/{impl_helpers.rb → impl_helper.rb} +8 -8
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_collection_methods.rb +13 -13
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_methods.rb +2 -2
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_line_string_methods.rb +13 -13
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_point_methods.rb +5 -5
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_polygon_methods.rb +6 -6
- data/lib/rgeo/{impl_helpers → impl_helper}/math.rb +1 -1
- data/lib/rgeo/shapefile.rb +1 -1
- data/lib/rgeo/shapefile/reader.rb +3 -3
- data/lib/rgeo/wkrep.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +17 -17
- data/lib/rgeo/wkrep/wkb_parser.rb +12 -12
- data/lib/rgeo/wkrep/wkt_generator.rb +8 -8
- data/lib/rgeo/wkrep/wkt_parser.rb +10 -10
- data/{tests → test}/active_record/readme.txt +0 -0
- data/{tests → test}/active_record/tc_mysqlspatial.rb +2 -2
- data/{tests → test}/common/geometry_collection_tests.rb +22 -22
- data/{tests → test}/common/line_string_tests.rb +20 -20
- data/{tests → test}/common/multi_line_string_tests.rb +19 -19
- data/{tests → test}/common/multi_point_tests.rb +17 -17
- data/{tests → test}/common/multi_polygon_tests.rb +16 -16
- data/{tests → test}/common/point_tests.rb +9 -9
- data/{tests → test}/common/polygon_tests.rb +9 -9
- data/test/coord_sys/tc_proj4.rb +111 -0
- data/{tests → test}/geos/tc_factory.rb +1 -1
- data/{tests → test}/geos/tc_geometry_collection.rb +1 -1
- data/{tests → test}/geos/tc_line_string.rb +0 -0
- data/{tests → test}/geos/tc_misc.rb +1 -1
- data/{tests → test}/geos/tc_multi_line_string.rb +1 -1
- data/{tests → test}/geos/tc_multi_point.rb +1 -1
- data/{tests → test}/geos/tc_multi_polygon.rb +1 -1
- data/{tests → test}/geos/tc_point.rb +1 -1
- data/{tests → test}/geos/tc_polygon.rb +0 -0
- data/{tests → test}/geos/tc_zmfactory.rb +2 -2
- data/test/projected_geography/tc_geometry_collection.rb +62 -0
- data/test/projected_geography/tc_line_string.rb +62 -0
- data/test/projected_geography/tc_multi_line_string.rb +62 -0
- data/test/projected_geography/tc_multi_point.rb +62 -0
- data/test/projected_geography/tc_multi_polygon.rb +63 -0
- data/test/projected_geography/tc_point.rb +93 -0
- data/test/projected_geography/tc_polygon.rb +62 -0
- data/{tests → test}/shapefile/shapelib_testcases/readme.txt +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test.dbf +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test0.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test0.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test1.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test1.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test10.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test10.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test11.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test11.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test12.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test12.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test13.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test13.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test2.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test2.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test3.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test3.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test4.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test4.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test5.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test5.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test6.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test6.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test7.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test7.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test8.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test8.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test9.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test9.shx +0 -0
- data/{tests → test}/shapefile/tc_shapelib_tests.rb +17 -17
- data/{tests → test}/simple_cartesian/tc_calculations.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_geometry_collection.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_line_string.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_multi_line_string.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_multi_point.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_multi_polygon.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_point.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_polygon.rb +0 -0
- data/{tests → test}/simple_mercator/tc_geometry_collection.rb +1 -1
- data/{tests → test}/simple_mercator/tc_line_string.rb +0 -0
- data/{tests → test}/simple_mercator/tc_multi_line_string.rb +1 -1
- data/{tests → test}/simple_mercator/tc_multi_point.rb +1 -1
- data/{tests → test}/simple_mercator/tc_multi_polygon.rb +1 -1
- data/{tests → test}/simple_mercator/tc_point.rb +2 -2
- data/{tests → test}/simple_mercator/tc_polygon.rb +0 -0
- data/{tests → test}/simple_mercator/tc_window.rb +1 -1
- data/test/spherical_geography/tc_calculations.rb +203 -0
- data/{tests/simple_spherical → test/spherical_geography}/tc_geometry_collection.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_line_string.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_multi_line_string.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_multi_point.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_multi_polygon.rb +3 -3
- data/{tests/simple_spherical → test/spherical_geography}/tc_point.rb +7 -7
- data/{tests/simple_spherical → test/spherical_geography}/tc_polygon.rb +2 -2
- data/{tests → test}/tc_cartesian_analysis.rb +0 -0
- data/{tests → test}/tc_geojson.rb +0 -0
- data/{tests → test}/tc_oneoff.rb +2 -1
- data/{tests → test}/wkrep/tc_wkb_generator.rb +0 -0
- data/{tests → test}/wkrep/tc_wkb_parser.rb +32 -32
- data/{tests → test}/wkrep/tc_wkt_generator.rb +0 -0
- data/{tests → test}/wkrep/tc_wkt_parser.rb +46 -46
- metadata +183 -164
- data/lib/rgeo/features/types.rb +0 -272
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +0 -279
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +0 -278
- data/lib/rgeo/geography/simple_mercator/projector.rb +0 -112
- data/lib/rgeo/geography/simple_spherical.rb +0 -68
- data/lib/rgeo/geography/simple_spherical/feature_classes.rb +0 -216
- data/tests/simple_spherical/tc_calculations.rb +0 -203
@@ -38,15 +38,15 @@ module RGeo
|
|
38
38
|
|
39
39
|
module Geography
|
40
40
|
|
41
|
-
module
|
41
|
+
module SphericalMath # :nodoc:
|
42
42
|
|
43
43
|
|
44
|
-
RADIUS =
|
44
|
+
RADIUS = 6378137.0
|
45
45
|
|
46
46
|
|
47
|
-
# Represents a point on the sphere in (x,y,z) coordinates
|
48
|
-
# of lat-lon. This form is often faster, more convenient,
|
49
|
-
# numerically stable for certain computations.
|
47
|
+
# Represents a point on the unit sphere in (x,y,z) coordinates
|
48
|
+
# instead of lat-lon. This form is often faster, more convenient,
|
49
|
+
# and more numerically stable for certain computations.
|
50
50
|
#
|
51
51
|
# The coordinate system is a right-handed system where the z-axis
|
52
52
|
# goes through the north pole, the x-axis goes through the prime
|
@@ -85,7 +85,7 @@ module RGeo
|
|
85
85
|
def latlon
|
86
86
|
lat_rad_ = ::Math.asin(@z)
|
87
87
|
lon_rad_ = ::Math.atan2(@y, @x) rescue 0.0
|
88
|
-
rpd_ = ::
|
88
|
+
rpd_ = ImplHelper::Math::RADIANS_PER_DEGREE
|
89
89
|
[lat_rad_ / rpd_, lon_rad_ / rpd_]
|
90
90
|
end
|
91
91
|
|
@@ -120,7 +120,7 @@ module RGeo
|
|
120
120
|
|
121
121
|
|
122
122
|
def self.from_latlon(lat_, lon_)
|
123
|
-
rpd_ = ::
|
123
|
+
rpd_ = ImplHelper::Math::RADIANS_PER_DEGREE
|
124
124
|
lat_rad_ = rpd_ * lat_
|
125
125
|
lon_rad_ = rpd_ * lon_
|
126
126
|
z_ = ::Math.sin(lat_rad_)
|
data/lib/rgeo/geos.rb
CHANGED
data/lib/rgeo/geos/factory.rb
CHANGED
@@ -39,12 +39,12 @@ module RGeo
|
|
39
39
|
module Geos
|
40
40
|
|
41
41
|
|
42
|
-
# This the GEOS implementation of ::RGeo::
|
42
|
+
# This the GEOS implementation of ::RGeo::Feature::Factory.
|
43
43
|
|
44
44
|
class Factory
|
45
45
|
|
46
46
|
|
47
|
-
include
|
47
|
+
include Feature::Factory::Instance
|
48
48
|
|
49
49
|
|
50
50
|
class << self
|
@@ -62,11 +62,20 @@ module RGeo
|
|
62
62
|
flags_ |= 2 if opts_[:support_z_coordinate]
|
63
63
|
flags_ |= 4 if opts_[:support_m_coordinate]
|
64
64
|
if flags_ & 6 == 6
|
65
|
-
raise
|
65
|
+
raise Error::UnsupportedCapability, "GEOS cannot support both Z and M coordinates at the same time."
|
66
66
|
end
|
67
67
|
buffer_resolution_ = opts_[:buffer_resolution].to_i
|
68
68
|
buffer_resolution_ = 1 if buffer_resolution_ < 1
|
69
|
+
proj4_ = opts_[:proj4]
|
70
|
+
if CoordSys::Proj4.supported?
|
71
|
+
if proj4_.kind_of?(::String) || proj4_.kind_of?(::Hash)
|
72
|
+
proj4_ = CoordSys::Proj4.create(proj4_)
|
73
|
+
end
|
74
|
+
else
|
75
|
+
proj4_ = nil
|
76
|
+
end
|
69
77
|
result_ = _create(flags_, opts_[:srid].to_i, buffer_resolution_)
|
78
|
+
result_.instance_variable_set(:@proj4, proj4_)
|
70
79
|
result_
|
71
80
|
end
|
72
81
|
alias_method :new, :create
|
@@ -110,7 +119,7 @@ module RGeo
|
|
110
119
|
end
|
111
120
|
|
112
121
|
|
113
|
-
# See ::RGeo::
|
122
|
+
# See ::RGeo::Feature::Factory#has_capability?
|
114
123
|
|
115
124
|
def has_capability?(name_)
|
116
125
|
case name_
|
@@ -118,27 +127,29 @@ module RGeo
|
|
118
127
|
_flags & 0x2 != 0
|
119
128
|
when :m_coordinate
|
120
129
|
_flags & 0x4 != 0
|
130
|
+
when :proj4
|
131
|
+
!@proj4.nil?
|
121
132
|
else
|
122
133
|
nil
|
123
134
|
end
|
124
135
|
end
|
125
136
|
|
126
137
|
|
127
|
-
# See ::RGeo::
|
138
|
+
# See ::RGeo::Feature::Factory#parse_wkt
|
128
139
|
|
129
140
|
def parse_wkt(str_)
|
130
141
|
_parse_wkt_impl(str_)
|
131
142
|
end
|
132
143
|
|
133
144
|
|
134
|
-
# See ::RGeo::
|
145
|
+
# See ::RGeo::Feature::Factory#parse_wkb
|
135
146
|
|
136
147
|
def parse_wkb(str_)
|
137
148
|
_parse_wkb_impl(str_)
|
138
149
|
end
|
139
150
|
|
140
151
|
|
141
|
-
# See ::RGeo::
|
152
|
+
# See ::RGeo::Feature::Factory#point
|
142
153
|
|
143
154
|
def point(x_, y_, *extra_)
|
144
155
|
if extra_.length > (_flags & 6 == 0 ? 0 : 1)
|
@@ -149,7 +160,7 @@ module RGeo
|
|
149
160
|
end
|
150
161
|
|
151
162
|
|
152
|
-
# See ::RGeo::
|
163
|
+
# See ::RGeo::Feature::Factory#line_string
|
153
164
|
|
154
165
|
def line_string(points_)
|
155
166
|
points_ = points_.to_a unless points_.kind_of?(::Array)
|
@@ -157,14 +168,14 @@ module RGeo
|
|
157
168
|
end
|
158
169
|
|
159
170
|
|
160
|
-
# See ::RGeo::
|
171
|
+
# See ::RGeo::Feature::Factory#line
|
161
172
|
|
162
173
|
def line(start_, end_)
|
163
174
|
LineImpl.create(self, start_, end_) rescue nil
|
164
175
|
end
|
165
176
|
|
166
177
|
|
167
|
-
# See ::RGeo::
|
178
|
+
# See ::RGeo::Feature::Factory#linear_ring
|
168
179
|
|
169
180
|
def linear_ring(points_)
|
170
181
|
points_ = points_.to_a unless points_.kind_of?(::Array)
|
@@ -172,7 +183,7 @@ module RGeo
|
|
172
183
|
end
|
173
184
|
|
174
185
|
|
175
|
-
# See ::RGeo::
|
186
|
+
# See ::RGeo::Feature::Factory#polygon
|
176
187
|
|
177
188
|
def polygon(outer_ring_, inner_rings_=nil)
|
178
189
|
inner_rings_ = inner_rings_.to_a unless inner_rings_.kind_of?(::Array)
|
@@ -180,7 +191,7 @@ module RGeo
|
|
180
191
|
end
|
181
192
|
|
182
193
|
|
183
|
-
# See ::RGeo::
|
194
|
+
# See ::RGeo::Feature::Factory#collection
|
184
195
|
|
185
196
|
def collection(elems_)
|
186
197
|
elems_ = elems_.to_a unless elems_.kind_of?(::Array)
|
@@ -188,7 +199,7 @@ module RGeo
|
|
188
199
|
end
|
189
200
|
|
190
201
|
|
191
|
-
# See ::RGeo::
|
202
|
+
# See ::RGeo::Feature::Factory#multi_point
|
192
203
|
|
193
204
|
def multi_point(elems_)
|
194
205
|
elems_ = elems_.to_a unless elems_.kind_of?(::Array)
|
@@ -196,7 +207,7 @@ module RGeo
|
|
196
207
|
end
|
197
208
|
|
198
209
|
|
199
|
-
# See ::RGeo::
|
210
|
+
# See ::RGeo::Feature::Factory#multi_line_string
|
200
211
|
|
201
212
|
def multi_line_string(elems_)
|
202
213
|
elems_ = elems_.to_a unless elems_.kind_of?(::Array)
|
@@ -204,7 +215,7 @@ module RGeo
|
|
204
215
|
end
|
205
216
|
|
206
217
|
|
207
|
-
# See ::RGeo::
|
218
|
+
# See ::RGeo::Feature::Factory#multi_polygon
|
208
219
|
|
209
220
|
def multi_polygon(elems_)
|
210
221
|
elems_ = elems_.to_a unless elems_.kind_of?(::Array)
|
@@ -212,7 +223,7 @@ module RGeo
|
|
212
223
|
end
|
213
224
|
|
214
225
|
|
215
|
-
# See ::RGeo::
|
226
|
+
# See ::RGeo::Feature::Factory#override_cast
|
216
227
|
|
217
228
|
def override_cast(original_, ntype_, flags_)
|
218
229
|
return nil unless Geos.supported?
|
@@ -234,7 +245,7 @@ module RGeo
|
|
234
245
|
# LineString conversion optimization.
|
235
246
|
if (original_.factory != self || ntype_ != type_) &&
|
236
247
|
original_.factory._flags & 0x6 == _flags & 0x6 &&
|
237
|
-
type_.subtype_of?(
|
248
|
+
type_.subtype_of?(Feature::LineString) && ntype_.subtype_of?(Feature::LineString)
|
238
249
|
then
|
239
250
|
return IMPL_CLASSES[ntype_]._copy_from(self, original_)
|
240
251
|
end
|
@@ -242,15 +253,22 @@ module RGeo
|
|
242
253
|
# Optimization for just removing a coordinate from an otherwise
|
243
254
|
# compatible factory
|
244
255
|
if _flags & 0x6 == 0x2 && self == original_.factory.z_factory
|
245
|
-
return
|
256
|
+
return Feature.cast(original_.z_geometry, ntype_, flags_)
|
246
257
|
elsif _flags & 0x6 == 0x4 && self == original_.factory.m_factory
|
247
|
-
return
|
258
|
+
return Feature.cast(original_.m_geometry, ntype_, flags_)
|
248
259
|
end
|
249
260
|
end
|
250
261
|
false
|
251
262
|
end
|
252
263
|
|
253
264
|
|
265
|
+
# See ::RGeo::Feature::Factory#proj4
|
266
|
+
|
267
|
+
def proj4
|
268
|
+
@proj4
|
269
|
+
end
|
270
|
+
|
271
|
+
|
254
272
|
end
|
255
273
|
|
256
274
|
|
@@ -23,8 +23,7 @@
|
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
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
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
27
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
28
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
29
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
@@ -41,7 +40,7 @@ module RGeo
|
|
41
40
|
|
42
41
|
class GeometryImpl # :nodoc:
|
43
42
|
|
44
|
-
include ::RGeo::
|
43
|
+
include ::RGeo::Feature::Type::Instance
|
45
44
|
|
46
45
|
def inspect
|
47
46
|
"#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>"
|
@@ -55,14 +54,14 @@ module RGeo
|
|
55
54
|
|
56
55
|
# :stopdoc:
|
57
56
|
IMPL_CLASSES = {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
57
|
+
Feature::Point => PointImpl,
|
58
|
+
Feature::LineString => LineStringImpl,
|
59
|
+
Feature::LinearRing => LinearRingImpl,
|
60
|
+
Feature::Line => LineImpl,
|
61
|
+
Feature::GeometryCollection => GeometryCollectionImpl,
|
62
|
+
Feature::MultiPoint => MultiPointImpl,
|
63
|
+
Feature::MultiLineString => MultiLineStringImpl,
|
64
|
+
Feature::MultiPolygon => MultiPolygonImpl,
|
66
65
|
}
|
67
66
|
# :startdoc:
|
68
67
|
|
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -75,7 +75,7 @@ module RGeo
|
|
75
75
|
# If set to true, assertion checking on MultiPolygon is disabled.
|
76
76
|
# This may speed up creation of MultiPolygon objects, at the
|
77
77
|
# expense of not doing the proper checking for OGC MultiPolygon
|
78
|
-
# compliance. See RGeo::
|
78
|
+
# compliance. See RGeo::Feature::MultiPolygon for details on
|
79
79
|
# the MultiPolygon assertions. Default is false.
|
80
80
|
# <tt>:buffer_resolution</tt>::
|
81
81
|
# The resolution of buffers around geometries created by this
|
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -43,7 +43,7 @@ module RGeo
|
|
43
43
|
|
44
44
|
class ZMFactory
|
45
45
|
|
46
|
-
include
|
46
|
+
include Feature::Factory::Instance
|
47
47
|
|
48
48
|
|
49
49
|
class << self
|
@@ -111,7 +111,7 @@ module RGeo
|
|
111
111
|
alias_method :==, :eql?
|
112
112
|
|
113
113
|
|
114
|
-
# See ::RGeo::
|
114
|
+
# See ::RGeo::Feature::Factory#has_capability?
|
115
115
|
|
116
116
|
def has_capability?(name_)
|
117
117
|
case name_
|
@@ -123,84 +123,84 @@ module RGeo
|
|
123
123
|
end
|
124
124
|
|
125
125
|
|
126
|
-
# See ::RGeo::
|
126
|
+
# See ::RGeo::Feature::Factory#parse_wkt
|
127
127
|
|
128
128
|
def parse_wkt(str_)
|
129
129
|
WKRep::WKTParser.new(:default_factory => self).parse(str_)
|
130
130
|
end
|
131
131
|
|
132
132
|
|
133
|
-
# See ::RGeo::
|
133
|
+
# See ::RGeo::Feature::Factory#parse_wkb
|
134
134
|
|
135
135
|
def parse_wkb(str_)
|
136
136
|
WKRep::WKBParser.new(:default_factory => self).parse(str_)
|
137
137
|
end
|
138
138
|
|
139
139
|
|
140
|
-
# See ::RGeo::
|
140
|
+
# See ::RGeo::Feature::Factory#point
|
141
141
|
|
142
142
|
def point(x_, y_, z_=0, m_=0)
|
143
143
|
ZMPointImpl.create(self, @zfactory.point(x_, y_, z_), @mfactory.point(x_, y_, m_))
|
144
144
|
end
|
145
145
|
|
146
146
|
|
147
|
-
# See ::RGeo::
|
147
|
+
# See ::RGeo::Feature::Factory#line_string
|
148
148
|
|
149
149
|
def line_string(points_)
|
150
150
|
ZMLineStringImpl.create(self, @zfactory.line_string(points_), @mfactory.line_string(points_))
|
151
151
|
end
|
152
152
|
|
153
153
|
|
154
|
-
# See ::RGeo::
|
154
|
+
# See ::RGeo::Feature::Factory#line
|
155
155
|
|
156
156
|
def line(start_, end_)
|
157
157
|
ZMLineStringImpl.create(self, @zfactory.line(start_, end_), @mfactory.line(start_, end_))
|
158
158
|
end
|
159
159
|
|
160
160
|
|
161
|
-
# See ::RGeo::
|
161
|
+
# See ::RGeo::Feature::Factory#linear_ring
|
162
162
|
|
163
163
|
def linear_ring(points_)
|
164
164
|
ZMLineStringImpl.create(self, @zfactory.linear_ring(points_), @mfactory.linear_ring(points_))
|
165
165
|
end
|
166
166
|
|
167
167
|
|
168
|
-
# See ::RGeo::
|
168
|
+
# See ::RGeo::Feature::Factory#polygon
|
169
169
|
|
170
170
|
def polygon(outer_ring_, inner_rings_=nil)
|
171
171
|
ZMPolygonImpl.create(self, @zfactory.polygon(outer_ring_, inner_rings_), @mfactory.polygon(outer_ring_, inner_rings_))
|
172
172
|
end
|
173
173
|
|
174
174
|
|
175
|
-
# See ::RGeo::
|
175
|
+
# See ::RGeo::Feature::Factory#collection
|
176
176
|
|
177
177
|
def collection(elems_)
|
178
178
|
ZMGeometryCollectionImpl.create(self, @zfactory.collection(elems_), @mfactory.collection(elems_))
|
179
179
|
end
|
180
180
|
|
181
181
|
|
182
|
-
# See ::RGeo::
|
182
|
+
# See ::RGeo::Feature::Factory#multi_point
|
183
183
|
|
184
184
|
def multi_point(elems_)
|
185
185
|
ZMGeometryCollectionImpl.create(self, @zfactory.multi_point(elems_), @mfactory.multi_point(elems_))
|
186
186
|
end
|
187
187
|
|
188
188
|
|
189
|
-
# See ::RGeo::
|
189
|
+
# See ::RGeo::Feature::Factory#multi_line_string
|
190
190
|
|
191
191
|
def multi_line_string(elems_)
|
192
192
|
ZMMultiLineStringImpl.create(self, @zfactory.multi_line_string(elems_), @mfactory.multi_line_string(elems_))
|
193
193
|
end
|
194
194
|
|
195
195
|
|
196
|
-
# See ::RGeo::
|
196
|
+
# See ::RGeo::Feature::Factory#multi_polygon
|
197
197
|
|
198
198
|
def multi_polygon(elems_)
|
199
199
|
ZMMultiPolygonImpl.create(self, @zfactory.multi_polygon(elems_), @mfactory.multi_polygon(elems_))
|
200
200
|
end
|
201
201
|
|
202
202
|
|
203
|
-
# See ::RGeo::
|
203
|
+
# See ::RGeo::Feature::Factory#override_cast
|
204
204
|
|
205
205
|
def override_cast(original_, ntype_, flags_)
|
206
206
|
return nil unless Geos.supported?
|
@@ -221,7 +221,7 @@ module RGeo
|
|
221
221
|
end
|
222
222
|
# LineString conversion optimization.
|
223
223
|
if (original_.factory != self || ntype_ != type_) &&
|
224
|
-
type_.subtype_of?(
|
224
|
+
type_.subtype_of?(Feature::LineString) && ntype_.subtype_of?(Feature::LineString)
|
225
225
|
then
|
226
226
|
klass_ = Factory::IMPL_CLASSES[ntype_]
|
227
227
|
zresult_ = klass_._copy_from(@zfactory, original_.z_geometry)
|
data/lib/rgeo/geos/zm_impl.rb
CHANGED
@@ -41,7 +41,7 @@ module RGeo
|
|
41
41
|
|
42
42
|
class ZMGeometryImpl # :nodoc:
|
43
43
|
|
44
|
-
include
|
44
|
+
include Feature::Type::Instance
|
45
45
|
|
46
46
|
|
47
47
|
def initialize(factory_, zgeometry_, mgeometry_)
|
@@ -406,15 +406,15 @@ module RGeo
|
|
406
406
|
class ZMGeometryImpl # :nodoc:
|
407
407
|
|
408
408
|
TYPE_KLASSES = {
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
409
|
+
Feature::Point => ZMPointImpl,
|
410
|
+
Feature::LineString => ZMLineStringImpl,
|
411
|
+
Feature::Line => ZMLineStringImpl,
|
412
|
+
Feature::LinearRing => ZMLineStringImpl,
|
413
|
+
Feature::Polygon => ZMPolygonImpl,
|
414
|
+
Feature::GeometryCollection => ZMGeometryCollectionImpl,
|
415
|
+
Feature::MultiPoint => ZMGeometryCollectionImpl,
|
416
|
+
Feature::MultiLineString => ZMMultiLineStringImpl,
|
417
|
+
Feature::MultiPolygon => ZMMultiPolygonImpl,
|
418
418
|
}
|
419
419
|
|
420
420
|
|
@@ -41,7 +41,7 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
|
43
43
|
|
44
|
-
module
|
44
|
+
module ImplHelper # :nodoc:
|
45
45
|
end
|
46
46
|
|
47
47
|
|
@@ -49,12 +49,12 @@ end
|
|
49
49
|
|
50
50
|
|
51
51
|
# Dependency files
|
52
|
-
require 'rgeo/
|
52
|
+
require 'rgeo/feature'
|
53
53
|
|
54
54
|
# Implementation files
|
55
|
-
require 'rgeo/
|
56
|
-
require 'rgeo/
|
57
|
-
require 'rgeo/
|
58
|
-
require 'rgeo/
|
59
|
-
require 'rgeo/
|
60
|
-
require 'rgeo/
|
55
|
+
require 'rgeo/impl_helper/math'
|
56
|
+
require 'rgeo/impl_helper/basic_geometry_methods'
|
57
|
+
require 'rgeo/impl_helper/basic_geometry_collection_methods'
|
58
|
+
require 'rgeo/impl_helper/basic_point_methods'
|
59
|
+
require 'rgeo/impl_helper/basic_line_string_methods'
|
60
|
+
require 'rgeo/impl_helper/basic_polygon_methods'
|