rgeo 0.1.12 → 0.1.13
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.
- data/History.rdoc +9 -7
- data/README.rdoc +7 -5
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +12 -19
- data/ext/geos_c_impl/factory.h +15 -21
- data/ext/geos_c_impl/geometry.c +19 -36
- data/ext/geos_c_impl/geometry.h +2 -12
- data/ext/geos_c_impl/geometry_collection.c +38 -157
- data/ext/geos_c_impl/geometry_collection.h +2 -12
- data/ext/geos_c_impl/line_string.c +83 -80
- data/ext/geos_c_impl/line_string.h +2 -12
- data/ext/geos_c_impl/main.c +5 -0
- data/ext/geos_c_impl/point.c +2 -12
- data/ext/geos_c_impl/point.h +2 -12
- data/ext/geos_c_impl/polygon.c +5 -14
- data/ext/geos_c_impl/polygon.h +2 -12
- data/ext/geos_c_impl/preface.h +8 -0
- data/lib/rgeo.rb +34 -16
- data/lib/rgeo/{geography/simple_spherical/geometry_collection_impl.rb → cartesian.rb} +19 -26
- data/lib/rgeo/cartesian/calculations.rb +129 -0
- data/lib/rgeo/cartesian/interface.rb +85 -0
- data/lib/rgeo/cartesian/simple_factory.rb +159 -0
- data/lib/rgeo/cartesian/simple_feature_classes.rb +187 -0
- data/lib/rgeo/cartesian/simple_feature_methods.rb +97 -0
- data/lib/rgeo/features.rb +1 -0
- data/lib/rgeo/features/curve.rb +3 -2
- data/lib/rgeo/features/factory.rb +62 -37
- data/lib/rgeo/features/geometry.rb +10 -32
- data/lib/rgeo/features/geometry_collection.rb +3 -2
- data/lib/rgeo/features/line.rb +3 -2
- data/lib/rgeo/features/line_string.rb +3 -2
- data/lib/rgeo/features/linear_ring.rb +3 -2
- data/lib/rgeo/features/multi_curve.rb +3 -2
- data/lib/rgeo/features/multi_line_string.rb +3 -2
- data/lib/rgeo/features/multi_point.rb +3 -2
- data/lib/rgeo/features/multi_polygon.rb +3 -2
- data/lib/rgeo/features/multi_surface.rb +3 -2
- data/lib/rgeo/features/point.rb +3 -2
- data/lib/rgeo/features/polygon.rb +3 -2
- data/lib/rgeo/features/surface.rb +3 -2
- data/lib/rgeo/features/types.rb +198 -0
- data/lib/rgeo/geography.rb +4 -14
- data/lib/rgeo/geography/factory.rb +7 -64
- data/lib/rgeo/geography/{simple_spherical/geometry_methods.rb → helper.rb} +4 -13
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +35 -89
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +22 -31
- data/lib/rgeo/geography/simple_mercator/projector.rb +4 -8
- data/lib/rgeo/geography/simple_spherical/calculations.rb +11 -9
- data/lib/rgeo/geography/simple_spherical/feature_classes.rb +189 -0
- data/lib/rgeo/geography/simple_spherical/{line_string_impl.rb → feature_methods.rb} +16 -64
- data/lib/rgeo/geos/factory.rb +26 -40
- data/lib/rgeo/geos/impl_additions.rb +3 -5
- data/lib/rgeo/{geography/simple_spherical/polygon_impl.rb → impl_helpers.rb} +16 -26
- data/lib/rgeo/impl_helpers/basic_geometry_collection_methods.rb +186 -0
- data/lib/rgeo/impl_helpers/basic_geometry_methods.rb +90 -0
- data/lib/rgeo/impl_helpers/basic_line_string_methods.rb +188 -0
- data/lib/rgeo/impl_helpers/basic_point_methods.rb +149 -0
- data/lib/rgeo/{geography/common/helper.rb → impl_helpers/basic_polygon_methods.rb} +62 -53
- data/lib/rgeo/{geography/common/polygon_methods.rb → impl_helpers/serialization.rb} +50 -42
- data/tests/common/geometry_collection_tests.rb +9 -7
- data/tests/common/multi_line_string_tests.rb +16 -13
- data/tests/common/multi_point_tests.rb +16 -13
- data/tests/common/multi_polygon_tests.rb +8 -6
- data/tests/common/point_tests.rb +1 -2
- data/tests/common/polygon_tests.rb +9 -9
- data/tests/geos/tc_multi_line_string.rb +2 -2
- data/tests/simple_cartesian/tc_calculations.rb +138 -0
- data/tests/simple_cartesian/tc_geometry_collection.rb +68 -0
- data/tests/simple_cartesian/tc_line_string.rb +70 -0
- data/{lib/rgeo/geography/simple_spherical/multi_line_string_impl.rb → tests/simple_cartesian/tc_multi_line_string.rb} +19 -19
- data/{lib/rgeo/geography/simple_spherical/multi_polygon_impl.rb → tests/simple_cartesian/tc_multi_point.rb} +19 -19
- data/{lib/rgeo/geography/common/geometry_methods.rb → tests/simple_cartesian/tc_multi_polygon.rb} +19 -41
- data/{lib/rgeo/geography/simple_spherical/point_impl.rb → tests/simple_cartesian/tc_point.rb} +33 -35
- data/tests/simple_cartesian/tc_polygon.rb +67 -0
- data/tests/simple_spherical/tc_geometry_collection.rb +68 -0
- data/tests/simple_spherical/tc_line_string.rb +10 -171
- data/tests/simple_spherical/tc_multi_line_string.rb +67 -0
- data/{lib/rgeo/geography/simple_spherical/multi_point_impl.rb → tests/simple_spherical/tc_multi_point.rb} +19 -19
- data/tests/simple_spherical/tc_multi_polygon.rb +70 -0
- data/tests/simple_spherical/tc_point.rb +17 -115
- data/tests/simple_spherical/tc_polygon.rb +67 -0
- metadata +46 -18
- data/ext/geos_c_impl/globals.h +0 -58
- data/lib/rgeo/geography/common/geometry_collection_methods.rb +0 -217
- data/lib/rgeo/geography/common/line_string_methods.rb +0 -201
- data/lib/rgeo/geography/common/point_methods.rb +0 -153
@@ -0,0 +1,187 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Spherical geography feature classes
|
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
|
+
module RGeo
|
38
|
+
|
39
|
+
module Cartesian
|
40
|
+
|
41
|
+
|
42
|
+
class SimplePointImpl # :nodoc:
|
43
|
+
|
44
|
+
|
45
|
+
include Features::Point
|
46
|
+
include ImplHelpers::BasicGeometryMethods
|
47
|
+
include Cartesian::SimpleGeometryMethods
|
48
|
+
include ImplHelpers::BasicPointMethods
|
49
|
+
|
50
|
+
|
51
|
+
def _validate_geometry
|
52
|
+
@x = @x % 360.0
|
53
|
+
@x -= 360.0 if @x >= 180.0
|
54
|
+
@y = 90.0 if @y > 90.0
|
55
|
+
@y = -90.0 if @y < -90.0
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def _xyz
|
61
|
+
@xyz ||= PointXYZ.from_latlon(@y, @x)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def distance(rhs_)
|
66
|
+
rhs_ = Features.cast(rhs_, @factory)
|
67
|
+
case rhs_
|
68
|
+
when SimplePointImpl
|
69
|
+
dx_ = @x - rhs_.x
|
70
|
+
dy_ = @y - rhs_.y
|
71
|
+
::Math.sqrt(dx_ * dx_ + dy_ * dy_)
|
72
|
+
else
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
class SimpleLineStringImpl # :nodoc:
|
82
|
+
|
83
|
+
|
84
|
+
include Features::LineString
|
85
|
+
include ImplHelpers::BasicGeometryMethods
|
86
|
+
include Cartesian::SimpleGeometryMethods
|
87
|
+
include ImplHelpers::BasicLineStringMethods
|
88
|
+
include Cartesian::SimpleLineStringMethods
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
class SimpleLineImpl # :nodoc:
|
95
|
+
|
96
|
+
|
97
|
+
include Features::Line
|
98
|
+
include ImplHelpers::BasicGeometryMethods
|
99
|
+
include Cartesian::SimpleGeometryMethods
|
100
|
+
include ImplHelpers::BasicLineStringMethods
|
101
|
+
include Cartesian::SimpleLineStringMethods
|
102
|
+
include ImplHelpers::BasicLineMethods
|
103
|
+
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
class SimpleLinearRingImpl # :nodoc:
|
109
|
+
|
110
|
+
|
111
|
+
include Features::Line
|
112
|
+
include ImplHelpers::BasicGeometryMethods
|
113
|
+
include Cartesian::SimpleGeometryMethods
|
114
|
+
include ImplHelpers::BasicLineStringMethods
|
115
|
+
include Cartesian::SimpleLineStringMethods
|
116
|
+
include ImplHelpers::BasicLinearRingMethods
|
117
|
+
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
class SimplePolygonImpl # :nodoc:
|
123
|
+
|
124
|
+
|
125
|
+
include Features::Polygon
|
126
|
+
include ImplHelpers::BasicGeometryMethods
|
127
|
+
include Cartesian::SimpleGeometryMethods
|
128
|
+
include ImplHelpers::BasicPolygonMethods
|
129
|
+
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
class SimpleGeometryCollectionImpl # :nodoc:
|
135
|
+
|
136
|
+
|
137
|
+
include Features::GeometryCollection
|
138
|
+
include ImplHelpers::BasicGeometryMethods
|
139
|
+
include Cartesian::SimpleGeometryMethods
|
140
|
+
include ImplHelpers::BasicGeometryCollectionMethods
|
141
|
+
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
class SimpleMultiPointImpl # :nodoc:
|
147
|
+
|
148
|
+
|
149
|
+
include Features::GeometryCollection
|
150
|
+
include ImplHelpers::BasicGeometryMethods
|
151
|
+
include Cartesian::SimpleGeometryMethods
|
152
|
+
include ImplHelpers::BasicGeometryCollectionMethods
|
153
|
+
include ImplHelpers::BasicMultiPointMethods
|
154
|
+
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
class SimpleMultiLineStringImpl # :nodoc:
|
160
|
+
|
161
|
+
|
162
|
+
include Features::GeometryCollection
|
163
|
+
include ImplHelpers::BasicGeometryMethods
|
164
|
+
include Cartesian::SimpleGeometryMethods
|
165
|
+
include ImplHelpers::BasicGeometryCollectionMethods
|
166
|
+
include ImplHelpers::BasicMultiLineStringMethods
|
167
|
+
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
class SimpleMultiPolygonImpl # :nodoc:
|
173
|
+
|
174
|
+
|
175
|
+
include Features::GeometryCollection
|
176
|
+
include ImplHelpers::BasicGeometryMethods
|
177
|
+
include Cartesian::SimpleGeometryMethods
|
178
|
+
include ImplHelpers::BasicGeometryCollectionMethods
|
179
|
+
include ImplHelpers::BasicMultiPolygonMethods
|
180
|
+
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Spherical geometry common methods
|
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
|
+
module RGeo
|
38
|
+
|
39
|
+
module Cartesian
|
40
|
+
|
41
|
+
|
42
|
+
module SimpleGeometryMethods # :nodoc:
|
43
|
+
|
44
|
+
|
45
|
+
def srid
|
46
|
+
factory.srid
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
module SimpleLineStringMethods # :nodoc:
|
54
|
+
|
55
|
+
|
56
|
+
def _segments
|
57
|
+
unless @segments
|
58
|
+
@segments = (0..num_points-2).map do |i_|
|
59
|
+
Segment.new(point_n(i_), point_n(i_+1))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
@segments
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def is_simple?
|
67
|
+
segs_ = _segments
|
68
|
+
len_ = segs_.length
|
69
|
+
return false if segs_.any?{ |a_| a_.degenerate? }
|
70
|
+
return true if len_ == 1
|
71
|
+
return segs_[0].s != segs_[1].e if len_ == 2
|
72
|
+
segs_.each_with_index do |seg_, index_|
|
73
|
+
nindex_ = index_ + 1
|
74
|
+
nindex_ = nil if nindex_ == len_
|
75
|
+
return false if nindex_ && seg_.contains_point?(segs_[nindex_].e)
|
76
|
+
pindex_ = index_ - 1
|
77
|
+
pindex_ = nil if pindex_ < 0
|
78
|
+
return false if pindex_ && seg_.contains_point?(segs_[pindex_].s)
|
79
|
+
if nindex_
|
80
|
+
oindex_ = nindex_ + 1
|
81
|
+
while oindex_ < len_
|
82
|
+
oseg_ = segs_[oindex_]
|
83
|
+
return false if !(index_ == 0 && oindex_ == len_-1 && seg_.s == oseg_.e) && seg_.intersects_segment?(oseg_)
|
84
|
+
oindex_ += 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
data/lib/rgeo/features.rb
CHANGED
data/lib/rgeo/features/curve.rb
CHANGED
@@ -68,13 +68,14 @@ module RGeo
|
|
68
68
|
# for the sake of documentation. Implementations need not necessarily
|
69
69
|
# include this module itself. Therefore, you should not depend on the
|
70
70
|
# kind_of? method to check type. Instead, use the provided check_type
|
71
|
-
# class method
|
72
|
-
# to support case-when constructs.
|
71
|
+
# class method (or === operator) defined in the Type module.
|
73
72
|
#
|
74
73
|
# Some implementations may support higher dimensional points.
|
75
74
|
|
76
75
|
module Curve
|
77
76
|
|
77
|
+
extend Type
|
78
|
+
|
78
79
|
include Geometry
|
79
80
|
|
80
81
|
|
@@ -52,13 +52,25 @@ module RGeo
|
|
52
52
|
# coordinates or additional subclasses not explicitly required by the
|
53
53
|
# Simple Features Specification.
|
54
54
|
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
55
|
+
# Factory is defined as a module and is provided primarily for the
|
56
|
+
# sake of documentation. Implementations need not necessarily include
|
57
|
+
# this module itself. Therefore, you should not depend on the
|
58
|
+
# kind_of? method to check type. However, to support testing for
|
59
|
+
# factory-ness, the Factory::Instance submodule is provided. All
|
60
|
+
# factory implementation classes MUST include Factory::Instance, and
|
61
|
+
# you may use it in kind_of?, ===, and case-when constructs.
|
58
62
|
|
59
63
|
module Factory
|
60
64
|
|
61
65
|
|
66
|
+
# All factory implementations MUST include this submodule.
|
67
|
+
# This serves as a marker that may be used to test an object for
|
68
|
+
# factory-ness.
|
69
|
+
|
70
|
+
module Instance
|
71
|
+
end
|
72
|
+
|
73
|
+
|
62
74
|
# Parse the given string in well-known-text format and return the
|
63
75
|
# resulting feature. Returns nil if the string couldn't be parsed.
|
64
76
|
|
@@ -84,7 +96,8 @@ module RGeo
|
|
84
96
|
|
85
97
|
|
86
98
|
# Create a feature of type LineString.
|
87
|
-
# The given points argument should be an Enumerable of Point
|
99
|
+
# The given points argument should be an Enumerable of Point
|
100
|
+
# objects, or objects that can be casted to Point.
|
88
101
|
|
89
102
|
def line_string(points_)
|
90
103
|
nil
|
@@ -92,7 +105,8 @@ module RGeo
|
|
92
105
|
|
93
106
|
|
94
107
|
# Create a feature of type Line.
|
95
|
-
# The given point arguments should be Point objects
|
108
|
+
# The given point arguments should be Point objects, or objects
|
109
|
+
# that can be casted to Point.
|
96
110
|
|
97
111
|
def line(start_, end_)
|
98
112
|
nil
|
@@ -100,7 +114,8 @@ module RGeo
|
|
100
114
|
|
101
115
|
|
102
116
|
# Create a feature of type LinearRing.
|
103
|
-
# The given points argument should be an Enumerable of Point
|
117
|
+
# The given points argument should be an Enumerable of Point
|
118
|
+
# objects, or objects that can be casted to Point.
|
104
119
|
# If the first and last points are not equal, the ring is
|
105
120
|
# automatically closed by appending the first point to the end of the
|
106
121
|
# string.
|
@@ -111,9 +126,11 @@ module RGeo
|
|
111
126
|
|
112
127
|
|
113
128
|
# Create a feature of type Polygon.
|
114
|
-
# The outer_ring should be a LinearRing
|
129
|
+
# The outer_ring should be a LinearRing, or an object that can be
|
130
|
+
# casted to LinearRing.
|
115
131
|
# The inner_rings should be a possibly empty Enumerable of
|
116
|
-
# LinearRing
|
132
|
+
# LinearRing (or objects that can be casted to LinearRing).
|
133
|
+
# You may also pass nil to indicate no inner rings.
|
117
134
|
|
118
135
|
def polygon(outer_ring_, inner_rings_=nil)
|
119
136
|
nil
|
@@ -122,8 +139,6 @@ module RGeo
|
|
122
139
|
|
123
140
|
# Create a feature of type GeometryCollection.
|
124
141
|
# The elems should be an Enumerable of Geometry objects.
|
125
|
-
# This method does not "flatten" collection hierarchies in the way
|
126
|
-
# that multi_point, multi_line_string, and multi_polygon do.
|
127
142
|
|
128
143
|
def collection(elems_)
|
129
144
|
nil
|
@@ -131,12 +146,10 @@ module RGeo
|
|
131
146
|
|
132
147
|
|
133
148
|
# Create a feature of type MultiPoint.
|
134
|
-
# The elems should be an Enumerable of Point objects, or
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
# Returns nil if any of the leaf geometries is not a Point, which
|
139
|
-
# would break the MultiPoint contract.
|
149
|
+
# The elems should be an Enumerable of Point objects, or objects
|
150
|
+
# that can be casted to Point.
|
151
|
+
# Returns nil if any of the contained geometries is not a Point,
|
152
|
+
# which would break the MultiPoint contract.
|
140
153
|
|
141
154
|
def multi_point(elems_)
|
142
155
|
nil
|
@@ -144,14 +157,10 @@ module RGeo
|
|
144
157
|
|
145
158
|
|
146
159
|
# Create a feature of type MultiLineString.
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
# The resultant MultiLineString will thus be "flattened" so that its
|
152
|
-
# elements include only those leaf LineStrings.
|
153
|
-
# Returns nil if any of the leaf geometries is not a LineString,
|
154
|
-
# which would break the MultiLineString contract.
|
160
|
+
# The elems should be an Enumerable of objects that are or can be
|
161
|
+
# casted to LineString or any of its subclasses.
|
162
|
+
# Returns nil if any of the contained geometries is not a
|
163
|
+
# LineString, which would break the MultiLineString contract.
|
155
164
|
|
156
165
|
def multi_line_string(elems_)
|
157
166
|
nil
|
@@ -159,12 +168,9 @@ module RGeo
|
|
159
168
|
|
160
169
|
|
161
170
|
# Create a feature of type MultiPolygon.
|
162
|
-
# The elems should be an Enumerable of
|
163
|
-
#
|
164
|
-
#
|
165
|
-
# The resultant MultiPolygon will thus be "flattened" so that its
|
166
|
-
# elements include only those leaf Polygons.
|
167
|
-
# Returns nil if any of the leaf geometries is not a Polygon,
|
171
|
+
# The elems should be an Enumerable of objects that are or can be
|
172
|
+
# casted to Polygon or any of its subclasses.
|
173
|
+
# Returns nil if any of the contained geometries is not a Polygon,
|
168
174
|
# which would break the MultiPolygon contract.
|
169
175
|
# Also returns nil if any of the other assertions for MultiPolygon
|
170
176
|
# are not met-- e.g. if any of the polygons overlap.
|
@@ -174,13 +180,32 @@ module RGeo
|
|
174
180
|
end
|
175
181
|
|
176
182
|
|
177
|
-
#
|
178
|
-
# this
|
179
|
-
#
|
180
|
-
#
|
181
|
-
|
182
|
-
|
183
|
-
|
183
|
+
# This is an optional method that may be implemented to customize
|
184
|
+
# casting for this factory. Basically, RGeo defines standard ways
|
185
|
+
# to cast certain types of objects from one factory to another and
|
186
|
+
# one SFS type to another. However, a factory may choose to
|
187
|
+
# override how things are casted TO its implementation using this
|
188
|
+
# method. It can do this to optimize certain casting cases, or
|
189
|
+
# implement special cases particular to this factory.
|
190
|
+
#
|
191
|
+
# This method will be called (if defined) on the destination
|
192
|
+
# factory, and will be passed the original object (which may or may
|
193
|
+
# not already be created by this factory), the SFS feature type
|
194
|
+
# (which again may or may not already be the type of the original
|
195
|
+
# object), a flag indicating whether to keep the subtype if casting
|
196
|
+
# to a supertype of the current type, and a flag indicating whether
|
197
|
+
# to force the creation of a new object even if the original is
|
198
|
+
# already of the desired factory and type.
|
199
|
+
#
|
200
|
+
# It should return either a casted result object, false, or nil.
|
201
|
+
# A nil return value indicates that casting should be forced to
|
202
|
+
# fail (and ::RGeo::Features::cast will return nil).
|
203
|
+
# A false return value indicates that this method declines to
|
204
|
+
# override the casting algorithm, and RGeo should use its default
|
205
|
+
# algorithm to cast the object.
|
206
|
+
|
207
|
+
def override_cast(original_, type_, keep_subtype_, force_new_)
|
208
|
+
false
|
184
209
|
end
|
185
210
|
|
186
211
|
|