rgeo 2.4.0 → 3.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/README.md +1 -0
- data/ext/geos_c_impl/analysis.c +4 -4
- data/ext/geos_c_impl/errors.c +8 -6
- data/ext/geos_c_impl/errors.h +7 -3
- data/ext/geos_c_impl/extconf.rb +2 -0
- data/ext/geos_c_impl/factory.c +80 -7
- data/ext/geos_c_impl/factory.h +28 -14
- data/ext/geos_c_impl/geometry.c +46 -14
- data/ext/geos_c_impl/geometry.h +7 -0
- data/ext/geos_c_impl/geometry_collection.c +2 -104
- data/ext/geos_c_impl/geometry_collection.h +0 -11
- data/ext/geos_c_impl/line_string.c +1 -1
- data/ext/geos_c_impl/point.c +1 -1
- data/ext/geos_c_impl/polygon.c +1 -37
- data/ext/geos_c_impl/preface.h +3 -0
- data/lib/rgeo/cartesian/calculations.rb +54 -17
- data/lib/rgeo/cartesian/factory.rb +0 -7
- data/lib/rgeo/cartesian/feature_classes.rb +66 -46
- data/lib/rgeo/cartesian/feature_methods.rb +51 -20
- data/lib/rgeo/cartesian/interface.rb +0 -6
- data/lib/rgeo/cartesian/planar_graph.rb +379 -0
- data/lib/rgeo/cartesian/sweepline_intersector.rb +149 -0
- data/lib/rgeo/cartesian/valid_op.rb +71 -0
- data/lib/rgeo/cartesian.rb +3 -0
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +6 -6
- data/lib/rgeo/error.rb +15 -0
- data/lib/rgeo/feature/geometry.rb +28 -28
- data/lib/rgeo/feature/geometry_collection.rb +13 -5
- data/lib/rgeo/feature/line_string.rb +3 -3
- data/lib/rgeo/feature/multi_surface.rb +3 -3
- data/lib/rgeo/feature/point.rb +4 -4
- data/lib/rgeo/feature/surface.rb +3 -3
- data/lib/rgeo/geographic/factory.rb +0 -7
- data/lib/rgeo/geographic/interface.rb +5 -20
- data/lib/rgeo/geographic/proj4_projector.rb +0 -2
- data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
- data/lib/rgeo/geographic/projected_feature_methods.rb +51 -28
- data/lib/rgeo/geographic/simple_mercator_projector.rb +0 -2
- data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
- data/lib/rgeo/geographic/spherical_feature_methods.rb +62 -1
- data/lib/rgeo/geos/capi_factory.rb +21 -31
- data/lib/rgeo/geos/capi_feature_classes.rb +35 -11
- data/lib/rgeo/geos/ffi_factory.rb +0 -28
- data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
- data/lib/rgeo/geos/ffi_feature_methods.rb +23 -5
- data/lib/rgeo/geos/interface.rb +0 -7
- data/lib/rgeo/geos/zm_factory.rb +0 -12
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +4 -4
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -1
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +15 -19
- data/lib/rgeo/impl_helper/basic_point_methods.rb +1 -1
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +1 -1
- data/lib/rgeo/impl_helper/valid_op.rb +354 -0
- data/lib/rgeo/impl_helper/validity_check.rb +138 -0
- data/lib/rgeo/impl_helper.rb +1 -0
- data/lib/rgeo/version.rb +1 -1
- metadata +31 -10
@@ -19,7 +19,7 @@ module RGeo
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def envelope
|
22
|
-
factory.unproject(projection.
|
22
|
+
factory.unproject(projection.unsafe_envelope)
|
23
23
|
end
|
24
24
|
|
25
25
|
def empty?
|
@@ -40,8 +40,21 @@ module RGeo
|
|
40
40
|
simple?
|
41
41
|
end
|
42
42
|
|
43
|
+
def valid?
|
44
|
+
projection.valid?
|
45
|
+
end
|
46
|
+
|
47
|
+
def invalid_reason
|
48
|
+
projection.invalid_reason
|
49
|
+
end
|
50
|
+
|
51
|
+
# (see RGeo::ImplHelper::ValidityCheck#make_valid)
|
52
|
+
def make_valid
|
53
|
+
factory.unproject projection.make_valid
|
54
|
+
end
|
55
|
+
|
43
56
|
def boundary
|
44
|
-
boundary = projection.
|
57
|
+
boundary = projection.unsafe_boundary
|
45
58
|
boundary ? factory.unproject(boundary) : nil
|
46
59
|
end
|
47
60
|
|
@@ -50,79 +63,79 @@ module RGeo
|
|
50
63
|
end
|
51
64
|
|
52
65
|
def disjoint?(rhs)
|
53
|
-
projection.
|
66
|
+
projection.unsafe_disjoint?(Feature.cast(rhs, factory).projection)
|
54
67
|
end
|
55
68
|
|
56
69
|
def intersects?(rhs)
|
57
|
-
projection.
|
70
|
+
projection.unsafe_intersects?(Feature.cast(rhs, factory).projection)
|
58
71
|
end
|
59
72
|
|
60
73
|
def touches?(rhs)
|
61
|
-
projection.
|
74
|
+
projection.unsafe_touches?(Feature.cast(rhs, factory).projection)
|
62
75
|
end
|
63
76
|
|
64
77
|
def crosses?(rhs)
|
65
|
-
projection.
|
78
|
+
projection.unsafe_crosses?(Feature.cast(rhs, factory).projection)
|
66
79
|
end
|
67
80
|
|
68
81
|
def within?(rhs)
|
69
|
-
projection.
|
82
|
+
projection.unsafe_within?(Feature.cast(rhs, factory).projection)
|
70
83
|
end
|
71
84
|
|
72
85
|
def contains?(rhs)
|
73
|
-
projection.
|
86
|
+
projection.unsafe_contains?(Feature.cast(rhs, factory).projection)
|
74
87
|
end
|
75
88
|
|
76
89
|
def overlaps?(rhs)
|
77
|
-
projection.
|
90
|
+
projection.unsafe_overlaps?(Feature.cast(rhs, factory).projection)
|
78
91
|
end
|
79
92
|
|
80
93
|
def relate(rhs, pattern_)
|
81
|
-
projection.
|
94
|
+
projection.unsafe_relate(Feature.cast(rhs, factory).projection, pattern_)
|
82
95
|
end
|
83
96
|
|
84
97
|
def distance(rhs)
|
85
|
-
projection.
|
98
|
+
projection.unsafe_distance(Feature.cast(rhs, factory).projection)
|
86
99
|
end
|
87
100
|
|
88
101
|
def buffer(distance)
|
89
|
-
factory.unproject(projection.
|
102
|
+
factory.unproject(projection.unsafe_buffer(distance))
|
90
103
|
end
|
91
104
|
|
92
105
|
def buffer_with_style(distance, end_cap_style, join_style, mitre_limit)
|
93
|
-
factory.unproject(projection.
|
106
|
+
factory.unproject(projection.unsafe_buffer_with_style(distance, end_cap_style, join_style, mitre_limit))
|
94
107
|
end
|
95
108
|
|
96
109
|
def simplify(tolerance)
|
97
|
-
factory.unproject(projection.
|
110
|
+
factory.unproject(projection.unsafe_simplify(tolerance))
|
98
111
|
end
|
99
112
|
|
100
113
|
def simplify_preserve_topology(tolerance)
|
101
|
-
factory.unproject(projection.
|
114
|
+
factory.unproject(projection.unsafe_simplify_preserve_topology(tolerance))
|
102
115
|
end
|
103
116
|
|
104
117
|
def convex_hull
|
105
|
-
factory.unproject(projection.
|
118
|
+
factory.unproject(projection.unsafe_convex_hull)
|
106
119
|
end
|
107
120
|
|
108
121
|
def intersection(rhs)
|
109
|
-
factory.unproject(projection.
|
122
|
+
factory.unproject(projection.unsafe_intersection(Feature.cast(rhs, factory).projection))
|
110
123
|
end
|
111
124
|
|
112
125
|
def union(rhs)
|
113
|
-
factory.unproject(projection.
|
126
|
+
factory.unproject(projection.unsafe_union(Feature.cast(rhs, factory).projection))
|
114
127
|
end
|
115
128
|
|
116
129
|
def difference(rhs)
|
117
|
-
factory.unproject(projection.
|
130
|
+
factory.unproject(projection.unsafe_difference(Feature.cast(rhs, factory).projection))
|
118
131
|
end
|
119
132
|
|
120
133
|
def sym_difference(rhs)
|
121
|
-
factory.unproject(projection.
|
134
|
+
factory.unproject(projection.unsafe_sym_difference(Feature.cast(rhs, factory).projection))
|
122
135
|
end
|
123
136
|
|
124
137
|
def point_on_surface
|
125
|
-
factory.unproject(projection.
|
138
|
+
factory.unproject(projection.unsafe_point_on_surface)
|
126
139
|
end
|
127
140
|
end
|
128
141
|
|
@@ -154,7 +167,8 @@ module RGeo
|
|
154
167
|
|
155
168
|
private
|
156
169
|
|
157
|
-
|
170
|
+
# Ensure coordinates fall within a valid range.
|
171
|
+
def init_geometry
|
158
172
|
@y = 85.0511287 if @y > 85.0511287
|
159
173
|
@y = -85.0511287 if @y < -85.0511287
|
160
174
|
super
|
@@ -163,33 +177,41 @@ module RGeo
|
|
163
177
|
|
164
178
|
module ProjectedNCurveMethods # :nodoc:
|
165
179
|
def length
|
166
|
-
projection.
|
180
|
+
projection.unsafe_length
|
167
181
|
end
|
168
182
|
end
|
169
183
|
|
170
184
|
module ProjectedLineStringMethods # :nodoc:
|
171
185
|
private
|
172
186
|
|
173
|
-
|
187
|
+
# Ensure coordinates fall within a valid range.
|
188
|
+
def init_geometry
|
174
189
|
@points = @points.map(&:canonical_point)
|
175
190
|
super
|
176
191
|
end
|
177
192
|
end
|
178
193
|
|
194
|
+
module ProjectedLinearRingMethods # :nodoc:
|
195
|
+
def simple?
|
196
|
+
projection.valid?
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
179
200
|
module ProjectedNSurfaceMethods # :nodoc:
|
180
201
|
def area
|
181
|
-
projection.
|
202
|
+
projection.unsafe_area
|
182
203
|
end
|
183
204
|
|
184
205
|
def centroid
|
185
|
-
factory.unproject(projection.
|
206
|
+
factory.unproject(projection.unsafe_centroid)
|
186
207
|
end
|
187
208
|
end
|
188
209
|
|
189
210
|
module ProjectedPolygonMethods # :nodoc:
|
190
211
|
private
|
191
212
|
|
192
|
-
|
213
|
+
# Ensure projection is available.
|
214
|
+
def init_geometry
|
193
215
|
super
|
194
216
|
unless projection
|
195
217
|
raise Error::InvalidGeometry, "Polygon failed assertions"
|
@@ -200,7 +222,8 @@ module RGeo
|
|
200
222
|
module ProjectedMultiPolygonMethods # :nodoc:
|
201
223
|
private
|
202
224
|
|
203
|
-
|
225
|
+
# Ensure projection is available.
|
226
|
+
def init_geometry
|
204
227
|
super
|
205
228
|
unless projection
|
206
229
|
raise Error::InvalidGeometry, "MultiPolygon failed assertions"
|
@@ -17,8 +17,6 @@ module RGeo
|
|
17
17
|
proj4: SimpleMercatorProjector._proj4_3857,
|
18
18
|
coord_sys: SimpleMercatorProjector._coordsys_3857,
|
19
19
|
buffer_resolution: opts[:buffer_resolution],
|
20
|
-
lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
|
21
|
-
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
22
20
|
has_z_coordinate: opts[:has_z_coordinate],
|
23
21
|
has_m_coordinate: opts[:has_m_coordinate])
|
24
22
|
end
|
@@ -8,78 +8,98 @@
|
|
8
8
|
|
9
9
|
module RGeo
|
10
10
|
module Geographic
|
11
|
-
class SphericalPointImpl
|
11
|
+
class SphericalPointImpl
|
12
12
|
include Feature::Point
|
13
|
+
include ImplHelper::ValidityCheck
|
13
14
|
include ImplHelper::BasicGeometryMethods
|
14
15
|
include ImplHelper::BasicPointMethods
|
16
|
+
include ImplHelper::ValidOp
|
15
17
|
include SphericalGeometryMethods
|
16
18
|
include SphericalPointMethods
|
17
19
|
end
|
18
20
|
|
19
|
-
class SphericalLineStringImpl
|
21
|
+
class SphericalLineStringImpl
|
20
22
|
include Feature::LineString
|
23
|
+
include ImplHelper::ValidityCheck
|
21
24
|
include ImplHelper::BasicGeometryMethods
|
22
25
|
include ImplHelper::BasicLineStringMethods
|
26
|
+
include ImplHelper::ValidOp
|
23
27
|
include SphericalGeometryMethods
|
24
28
|
include SphericalLineStringMethods
|
25
29
|
end
|
26
30
|
|
27
|
-
class SphericalLineImpl
|
31
|
+
class SphericalLineImpl
|
28
32
|
include Feature::Line
|
33
|
+
include ImplHelper::ValidityCheck
|
29
34
|
include ImplHelper::BasicGeometryMethods
|
30
35
|
include ImplHelper::BasicLineStringMethods
|
31
36
|
include ImplHelper::BasicLineMethods
|
37
|
+
include ImplHelper::ValidOp
|
32
38
|
include SphericalGeometryMethods
|
33
39
|
include SphericalLineStringMethods
|
34
40
|
end
|
35
41
|
|
36
|
-
class SphericalLinearRingImpl
|
42
|
+
class SphericalLinearRingImpl
|
37
43
|
include Feature::LinearRing
|
44
|
+
include ImplHelper::ValidityCheck
|
38
45
|
include ImplHelper::BasicGeometryMethods
|
39
46
|
include ImplHelper::BasicLineStringMethods
|
40
47
|
include ImplHelper::BasicLinearRingMethods
|
48
|
+
include ImplHelper::ValidOp
|
41
49
|
include SphericalGeometryMethods
|
42
50
|
include SphericalLineStringMethods
|
43
51
|
end
|
44
52
|
|
45
|
-
class SphericalPolygonImpl
|
53
|
+
class SphericalPolygonImpl
|
46
54
|
include Feature::Polygon
|
55
|
+
include ImplHelper::ValidityCheck
|
47
56
|
include ImplHelper::BasicGeometryMethods
|
48
57
|
include ImplHelper::BasicPolygonMethods
|
58
|
+
include ImplHelper::ValidOp
|
49
59
|
include SphericalGeometryMethods
|
50
60
|
include SphericalPolygonMethods
|
51
61
|
end
|
52
62
|
|
53
|
-
class SphericalGeometryCollectionImpl
|
63
|
+
class SphericalGeometryCollectionImpl
|
54
64
|
include Feature::GeometryCollection
|
65
|
+
include ImplHelper::ValidityCheck
|
55
66
|
include ImplHelper::BasicGeometryMethods
|
56
67
|
include ImplHelper::BasicGeometryCollectionMethods
|
68
|
+
include ImplHelper::ValidOp
|
57
69
|
include SphericalGeometryMethods
|
58
70
|
end
|
59
71
|
|
60
|
-
class SphericalMultiPointImpl
|
72
|
+
class SphericalMultiPointImpl
|
61
73
|
include Feature::MultiPoint
|
74
|
+
include ImplHelper::ValidityCheck
|
62
75
|
include ImplHelper::BasicGeometryMethods
|
63
76
|
include ImplHelper::BasicGeometryCollectionMethods
|
64
77
|
include ImplHelper::BasicMultiPointMethods
|
78
|
+
include ImplHelper::ValidOp
|
65
79
|
include SphericalGeometryMethods
|
66
80
|
end
|
67
81
|
|
68
|
-
class SphericalMultiLineStringImpl
|
82
|
+
class SphericalMultiLineStringImpl
|
69
83
|
include Feature::MultiLineString
|
84
|
+
include ImplHelper::ValidityCheck
|
70
85
|
include ImplHelper::BasicGeometryMethods
|
71
86
|
include ImplHelper::BasicGeometryCollectionMethods
|
72
87
|
include ImplHelper::BasicMultiLineStringMethods
|
88
|
+
include ImplHelper::ValidOp
|
73
89
|
include SphericalGeometryMethods
|
74
90
|
include SphericalMultiLineStringMethods
|
75
91
|
end
|
76
92
|
|
77
|
-
class SphericalMultiPolygonImpl
|
93
|
+
class SphericalMultiPolygonImpl
|
78
94
|
include Feature::MultiPolygon
|
95
|
+
include ImplHelper::ValidityCheck
|
79
96
|
include ImplHelper::BasicGeometryMethods
|
80
97
|
include ImplHelper::BasicGeometryCollectionMethods
|
81
98
|
include ImplHelper::BasicMultiPolygonMethods
|
99
|
+
include ImplHelper::ValidOp
|
82
100
|
include SphericalGeometryMethods
|
83
101
|
end
|
102
|
+
|
103
|
+
ImplHelper::ValidityCheck.override_classes
|
84
104
|
end
|
85
105
|
end
|
@@ -79,7 +79,8 @@ module RGeo
|
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
|
-
|
82
|
+
# Ensure coordinates fall within a valid range.
|
83
|
+
def init_geometry
|
83
84
|
if @x < -180.0 || @x > 180.0
|
84
85
|
@x = @x % 360.0
|
85
86
|
@x -= 360.0 if @x > 180.0
|
@@ -128,6 +129,66 @@ module RGeo
|
|
128
129
|
def length
|
129
130
|
arcs.inject(0.0) { |sum, arc| sum + arc.length } * SphericalMath::RADIUS
|
130
131
|
end
|
132
|
+
|
133
|
+
def intersects?(rhs)
|
134
|
+
case rhs
|
135
|
+
when Feature::LineString
|
136
|
+
intersects_line_string?(rhs)
|
137
|
+
else
|
138
|
+
super
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def crosses?(rhs)
|
143
|
+
case rhs
|
144
|
+
when Feature::LineString
|
145
|
+
crosses_line_string?(rhs)
|
146
|
+
else
|
147
|
+
super
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
# TODO: replace with better algorithm (https://github.com/rgeo/rgeo/issues/274)
|
154
|
+
# Very simple algorithm to determine if 2 LineStrings intersect.
|
155
|
+
# Uses a nested for loop to look at each arc in the LineStrings and
|
156
|
+
# check if each arc intersects.
|
157
|
+
#
|
158
|
+
# @param [RGeo::Geographic::SphericalLineStringImpl] rhs
|
159
|
+
#
|
160
|
+
# @return [Boolean]
|
161
|
+
def intersects_line_string?(rhs)
|
162
|
+
arcs.each do |arc|
|
163
|
+
rhs.arcs.each do |rhs_arc|
|
164
|
+
return true if arc.intersects_arc?(rhs_arc)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
false
|
169
|
+
end
|
170
|
+
|
171
|
+
# TODO: replace with better algorithm (https://github.com/rgeo/rgeo/issues/274)
|
172
|
+
# Very simple algorithm to determine if 2 LineStrings cross.
|
173
|
+
# Uses a nested for loop to look at each arc in the LineStrings and
|
174
|
+
# check if each arc crosses.
|
175
|
+
#
|
176
|
+
# @param [RGeo::Geographic::SphericalLineStringImpl] rhs
|
177
|
+
#
|
178
|
+
# @return [Boolean]
|
179
|
+
def crosses_line_string?(rhs)
|
180
|
+
arcs.each do |arc|
|
181
|
+
rhs.arcs.each do |rhs_arc|
|
182
|
+
next unless arc.intersects_arc?(rhs_arc)
|
183
|
+
|
184
|
+
# check that endpoints aren't the intersection point
|
185
|
+
is_endpoint = arc.contains_point?(rhs_arc.s) || arc.contains_point?(rhs_arc.e) || rhs_arc.contains_point?(arc.s) || rhs_arc.contains_point?(arc.e)
|
186
|
+
return true unless is_endpoint
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
false
|
191
|
+
end
|
131
192
|
end
|
132
193
|
|
133
194
|
module SphericalMultiLineStringMethods # :nodoc:
|
@@ -26,7 +26,6 @@ module RGeo
|
|
26
26
|
|
27
27
|
# Get flags to pass to the C extension
|
28
28
|
flags = 0
|
29
|
-
flags |= 1 if opts_[:uses_lenient_assertions] || opts_[:lenient_multi_polygon_assertions] || opts_[:uses_lenient_multi_polygon_assertions]
|
30
29
|
flags |= 2 if opts_[:has_z_coordinate]
|
31
30
|
flags |= 4 if opts_[:has_m_coordinate]
|
32
31
|
if flags & 6 == 6
|
@@ -137,16 +136,15 @@ module RGeo
|
|
137
136
|
|
138
137
|
def marshal_dump # :nodoc:
|
139
138
|
hash_ = {
|
140
|
-
"hasz" =>
|
141
|
-
"hasm" =>
|
139
|
+
"hasz" => supports_z?,
|
140
|
+
"hasm" => supports_m?,
|
142
141
|
"srid" => _srid,
|
143
142
|
"bufr" => _buffer_resolution,
|
144
143
|
"wktg" => _wkt_generator ? _wkt_generator.properties : {},
|
145
144
|
"wkbg" => _wkb_generator ? _wkb_generator.properties : {},
|
146
145
|
"wktp" => _wkt_parser ? _wkt_parser.properties : {},
|
147
146
|
"wkbp" => _wkb_parser ? _wkb_parser.properties : {},
|
148
|
-
"
|
149
|
-
"apre" => ((_flags & 0x8) >> 3)
|
147
|
+
"apre" => auto_prepare
|
150
148
|
}
|
151
149
|
if (proj4_ = _proj4)
|
152
150
|
hash_["proj4"] = proj4_.marshal_dump
|
@@ -179,8 +177,7 @@ module RGeo
|
|
179
177
|
wkb_generator: symbolize_hash(data_["wkbg"]),
|
180
178
|
wkt_parser: symbolize_hash(data_["wktp"]),
|
181
179
|
wkb_parser: symbolize_hash(data_["wkbp"]),
|
182
|
-
|
183
|
-
auto_prepare: (data_["apre"] == 0 ? :disabled : :simple),
|
180
|
+
auto_prepare: data_["apre"],
|
184
181
|
proj4: proj4_,
|
185
182
|
coord_sys: coord_sys_
|
186
183
|
)
|
@@ -190,16 +187,15 @@ module RGeo
|
|
190
187
|
# Psych support
|
191
188
|
|
192
189
|
def encode_with(coder_) # :nodoc:
|
193
|
-
coder_["has_z_coordinate"] =
|
194
|
-
coder_["has_m_coordinate"] =
|
190
|
+
coder_["has_z_coordinate"] = supports_z?
|
191
|
+
coder_["has_m_coordinate"] = supports_m?
|
195
192
|
coder_["srid"] = _srid
|
196
193
|
coder_["buffer_resolution"] = _buffer_resolution
|
197
|
-
coder_["lenient_multi_polygon_assertions"] = (_flags & 0x1 != 0)
|
198
194
|
coder_["wkt_generator"] = _wkt_generator ? _wkt_generator.properties : {}
|
199
195
|
coder_["wkb_generator"] = _wkb_generator ? _wkb_generator.properties : {}
|
200
196
|
coder_["wkt_parser"] = _wkt_parser ? _wkt_parser.properties : {}
|
201
197
|
coder_["wkb_parser"] = _wkb_parser ? _wkb_parser.properties : {}
|
202
|
-
coder_["auto_prepare"] =
|
198
|
+
coder_["auto_prepare"] = auto_prepare
|
203
199
|
if (proj4_ = _proj4)
|
204
200
|
str_ = proj4_.original_str || proj4_.canonical_str
|
205
201
|
coder_["proj4"] = proj4_.radians? ? { "proj4" => str_, "radians" => true } : str_
|
@@ -236,7 +232,6 @@ module RGeo
|
|
236
232
|
wkt_parser: symbolize_hash(coder_["wkt_parser"]),
|
237
233
|
wkb_parser: symbolize_hash(coder_["wkb_parser"]),
|
238
234
|
auto_prepare: coder_["auto_prepare"] == "disabled" ? :disabled : :simple,
|
239
|
-
uses_lenient_multi_polygon_assertions: coder_["lenient_multi_polygon_assertions"],
|
240
235
|
proj4: proj4_,
|
241
236
|
coord_sys: coord_sys_
|
242
237
|
)
|
@@ -256,28 +251,19 @@ module RGeo
|
|
256
251
|
_buffer_resolution
|
257
252
|
end
|
258
253
|
|
259
|
-
# Returns true if this factory is lenient with MultiPolygon assertions
|
260
|
-
|
261
|
-
def lenient_multi_polygon_assertions?
|
262
|
-
_flags & 0x1 != 0
|
263
|
-
end
|
264
|
-
|
265
254
|
# See RGeo::Feature::Factory#property
|
266
|
-
|
267
255
|
def property(name_)
|
268
256
|
case name_
|
269
257
|
when :has_z_coordinate
|
270
|
-
|
258
|
+
supports_z?
|
271
259
|
when :has_m_coordinate
|
272
|
-
|
260
|
+
supports_m?
|
273
261
|
when :is_cartesian
|
274
262
|
true
|
275
|
-
when :uses_lenient_multi_polygon_assertions
|
276
|
-
_flags & 0x1 != 0
|
277
263
|
when :buffer_resolution
|
278
264
|
_buffer_resolution
|
279
265
|
when :auto_prepare
|
280
|
-
|
266
|
+
prepare_heuristic? ? :simple : :disabled
|
281
267
|
end
|
282
268
|
end
|
283
269
|
|
@@ -307,11 +293,11 @@ module RGeo
|
|
307
293
|
|
308
294
|
# See RGeo::Feature::Factory#point
|
309
295
|
|
310
|
-
def point(
|
311
|
-
if
|
296
|
+
def point(x, y, *extra)
|
297
|
+
if extra.length > (supports_z_or_m? ? 1 : 0)
|
312
298
|
raise(RGeo::Error::InvalidGeometry, "Parse error")
|
313
299
|
else
|
314
|
-
CAPIPointImpl.create(self,
|
300
|
+
CAPIPointImpl.create(self, x, y, extra[0].to_f)
|
315
301
|
end
|
316
302
|
end
|
317
303
|
|
@@ -398,7 +384,7 @@ module RGeo
|
|
398
384
|
# Optimization if we're just changing factories, but the
|
399
385
|
# factories are zm-compatible and proj4-compatible.
|
400
386
|
if original.factory != self && ntype == type &&
|
401
|
-
original.factory._flags &
|
387
|
+
original.factory._flags & FLAG_SUPPORTS_Z_OR_M == _flags & FLAG_SUPPORTS_Z_OR_M &&
|
402
388
|
(!project || original.factory.proj4 == _proj4)
|
403
389
|
result = original.dup
|
404
390
|
result.factory = self
|
@@ -406,7 +392,7 @@ module RGeo
|
|
406
392
|
end
|
407
393
|
# LineString conversion optimization.
|
408
394
|
if (original.factory != self || ntype != type) &&
|
409
|
-
original.factory._flags &
|
395
|
+
original.factory._flags & FLAG_SUPPORTS_Z_OR_M == _flags & FLAG_SUPPORTS_Z_OR_M &&
|
410
396
|
(!project || original.factory.proj4 == _proj4) &&
|
411
397
|
type.subtype_of?(Feature::LineString) && ntype.subtype_of?(Feature::LineString)
|
412
398
|
return IMPL_CLASSES[ntype]._copy_from(self, original)
|
@@ -414,15 +400,19 @@ module RGeo
|
|
414
400
|
when ZMGeometryMethods
|
415
401
|
# Optimization for just removing a coordinate from an otherwise
|
416
402
|
# compatible factory
|
417
|
-
if
|
403
|
+
if supports_z? && !supports_m? && self == original.factory.z_factory
|
418
404
|
return Feature.cast(original.z_geometry, ntype, flags)
|
419
|
-
elsif
|
405
|
+
elsif supports_m? && !supports_z? && self == original.factory.m_factory
|
420
406
|
return Feature.cast(original.m_geometry, ntype, flags)
|
421
407
|
end
|
422
408
|
end
|
423
409
|
false
|
424
410
|
end
|
425
411
|
|
412
|
+
def auto_prepare # :nodoc:
|
413
|
+
prepare_heuristic? ? :simple : :disabled
|
414
|
+
end
|
415
|
+
|
426
416
|
# :stopdoc:
|
427
417
|
|
428
418
|
IMPL_CLASSES = {
|
@@ -6,9 +6,11 @@
|
|
6
6
|
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
9
|
+
require_relative "../impl_helper/validity_check"
|
10
|
+
|
9
11
|
module RGeo
|
10
12
|
module Geos
|
11
|
-
module CAPIGeometryMethods
|
13
|
+
module CAPIGeometryMethods
|
12
14
|
include Feature::Instance
|
13
15
|
|
14
16
|
def is_empty? # rubocop:disable Naming/PredicateName
|
@@ -83,21 +85,29 @@ module RGeo
|
|
83
85
|
include Enumerable
|
84
86
|
end
|
85
87
|
|
86
|
-
class CAPIGeometryImpl
|
88
|
+
class CAPIGeometryImpl
|
89
|
+
include Feature::Geometry
|
90
|
+
include ImplHelper::ValidityCheck
|
87
91
|
include CAPIGeometryMethods
|
88
92
|
end
|
89
93
|
|
90
|
-
class CAPIPointImpl
|
94
|
+
class CAPIPointImpl
|
95
|
+
include Feature::Point
|
96
|
+
include ImplHelper::ValidityCheck
|
91
97
|
include CAPIGeometryMethods
|
92
98
|
include CAPIPointMethods
|
93
99
|
end
|
94
100
|
|
95
|
-
class CAPILineStringImpl
|
101
|
+
class CAPILineStringImpl
|
102
|
+
include Feature::LineString
|
103
|
+
include ImplHelper::ValidityCheck
|
96
104
|
include CAPIGeometryMethods
|
97
105
|
include CAPILineStringMethods
|
98
106
|
end
|
99
107
|
|
100
|
-
class CAPILinearRingImpl
|
108
|
+
class CAPILinearRingImpl
|
109
|
+
include Feature::LinearRing
|
110
|
+
include ImplHelper::ValidityCheck
|
101
111
|
include CAPIGeometryMethods
|
102
112
|
include CAPILineStringMethods
|
103
113
|
include CAPILinearRingMethods
|
@@ -107,38 +117,52 @@ module RGeo
|
|
107
117
|
end
|
108
118
|
end
|
109
119
|
|
110
|
-
class CAPILineImpl
|
120
|
+
class CAPILineImpl
|
121
|
+
include Feature::Line
|
122
|
+
include ImplHelper::ValidityCheck
|
111
123
|
include CAPIGeometryMethods
|
112
124
|
include CAPILineStringMethods
|
113
125
|
include CAPILineMethods
|
114
126
|
end
|
115
127
|
|
116
|
-
class CAPIPolygonImpl
|
128
|
+
class CAPIPolygonImpl
|
129
|
+
include Feature::Polygon
|
130
|
+
include ImplHelper::ValidityCheck
|
117
131
|
include CAPIGeometryMethods
|
118
132
|
include CAPIPolygonMethods
|
119
133
|
end
|
120
134
|
|
121
|
-
class CAPIGeometryCollectionImpl
|
135
|
+
class CAPIGeometryCollectionImpl
|
136
|
+
include Feature::GeometryCollection
|
137
|
+
include ImplHelper::ValidityCheck
|
122
138
|
include CAPIGeometryMethods
|
123
139
|
include CAPIGeometryCollectionMethods
|
124
140
|
end
|
125
141
|
|
126
|
-
class CAPIMultiPointImpl
|
142
|
+
class CAPIMultiPointImpl
|
143
|
+
include Feature::MultiPoint
|
144
|
+
include ImplHelper::ValidityCheck
|
127
145
|
include CAPIGeometryMethods
|
128
146
|
include CAPIGeometryCollectionMethods
|
129
147
|
include CAPIMultiPointMethods
|
130
148
|
end
|
131
149
|
|
132
|
-
class CAPIMultiLineStringImpl
|
150
|
+
class CAPIMultiLineStringImpl
|
151
|
+
include Feature::MultiLineString
|
152
|
+
include ImplHelper::ValidityCheck
|
133
153
|
include CAPIGeometryMethods
|
134
154
|
include CAPIGeometryCollectionMethods
|
135
155
|
include CAPIMultiLineStringMethods
|
136
156
|
end
|
137
157
|
|
138
|
-
class CAPIMultiPolygonImpl
|
158
|
+
class CAPIMultiPolygonImpl
|
159
|
+
include Feature::MultiPolygon
|
160
|
+
include ImplHelper::ValidityCheck
|
139
161
|
include CAPIGeometryMethods
|
140
162
|
include CAPIGeometryCollectionMethods
|
141
163
|
include CAPIMultiPolygonMethods
|
142
164
|
end
|
165
|
+
|
166
|
+
ImplHelper::ValidityCheck.override_classes
|
143
167
|
end
|
144
168
|
end
|