rgeo 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +29 -0
- data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
- data/ext/geos_c_impl/coordinates.c +65 -0
- data/ext/geos_c_impl/coordinates.h +2 -0
- data/ext/geos_c_impl/extconf.rb +19 -43
- data/ext/geos_c_impl/geometry.c +24 -0
- data/ext/geos_c_impl/geometry_collection.c +99 -1
- data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
- data/ext/geos_c_impl/line_string.c +38 -0
- data/ext/geos_c_impl/mkmf.log +123 -0
- data/ext/geos_c_impl/point.c +27 -0
- data/ext/geos_c_impl/polygon.c +26 -0
- data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
- data/ext/proj4_c_impl/extconf.rb +32 -32
- data/ext/proj4_c_impl/mkmf.log +47 -0
- data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
- data/lib/rgeo.rb +10 -11
- data/lib/rgeo/cartesian.rb +7 -12
- data/lib/rgeo/cartesian/analysis.rb +13 -26
- data/lib/rgeo/cartesian/bounding_box.rb +45 -114
- data/lib/rgeo/cartesian/calculations.rb +3 -21
- data/lib/rgeo/cartesian/factory.rb +101 -122
- data/lib/rgeo/cartesian/feature_classes.rb +9 -59
- data/lib/rgeo/cartesian/feature_methods.rb +15 -45
- data/lib/rgeo/cartesian/interface.rb +6 -17
- data/lib/rgeo/coord_sys.rb +9 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
- data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
- data/lib/rgeo/coord_sys/proj4.rb +28 -67
- data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
- data/lib/rgeo/error.rb +0 -6
- data/lib/rgeo/feature.rb +18 -23
- data/lib/rgeo/feature/curve.rb +0 -14
- data/lib/rgeo/feature/factory.rb +13 -38
- data/lib/rgeo/feature/factory_generator.rb +4 -16
- data/lib/rgeo/feature/geometry.rb +18 -60
- data/lib/rgeo/feature/geometry_collection.rb +3 -17
- data/lib/rgeo/feature/line.rb +0 -10
- data/lib/rgeo/feature/line_string.rb +1 -13
- data/lib/rgeo/feature/linear_ring.rb +0 -9
- data/lib/rgeo/feature/mixins.rb +11 -36
- data/lib/rgeo/feature/multi_curve.rb +0 -11
- data/lib/rgeo/feature/multi_line_string.rb +0 -9
- data/lib/rgeo/feature/multi_point.rb +0 -9
- data/lib/rgeo/feature/multi_polygon.rb +0 -9
- data/lib/rgeo/feature/multi_surface.rb +0 -12
- data/lib/rgeo/feature/point.rb +0 -13
- data/lib/rgeo/feature/polygon.rb +1 -14
- data/lib/rgeo/feature/surface.rb +0 -12
- data/lib/rgeo/feature/types.rb +19 -61
- data/lib/rgeo/geographic.rb +10 -15
- data/lib/rgeo/geographic/factory.rb +126 -147
- data/lib/rgeo/geographic/interface.rb +67 -81
- data/lib/rgeo/geographic/proj4_projector.rb +13 -37
- data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
- data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
- data/lib/rgeo/geographic/projected_window.rb +15 -67
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
- data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
- data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
- data/lib/rgeo/geographic/spherical_math.rb +26 -51
- data/lib/rgeo/geos.rb +23 -20
- data/lib/rgeo/geos/capi_factory.rb +125 -131
- data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
- data/lib/rgeo/geos/ffi_factory.rb +90 -143
- data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
- data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
- data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
- data/lib/rgeo/geos/interface.rb +4 -23
- data/lib/rgeo/geos/utils.rb +4 -19
- data/lib/rgeo/geos/zm_factory.rb +82 -131
- data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
- data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
- data/lib/rgeo/impl_helper.rb +8 -13
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
- data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
- data/lib/rgeo/impl_helper/math.rb +4 -10
- data/lib/rgeo/impl_helper/utils.rb +2 -10
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep.rb +4 -9
- data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
- data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
- data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
- data/lib/rgeo/yaml.rb +1 -7
- data/test/common/factory_tests.rb +4 -19
- data/test/common/geometry_collection_tests.rb +6 -39
- data/test/common/line_string_tests.rb +10 -39
- data/test/common/multi_line_string_tests.rb +10 -30
- data/test/common/multi_point_tests.rb +15 -34
- data/test/common/multi_polygon_tests.rb +26 -28
- data/test/common/point_tests.rb +37 -59
- data/test/common/polygon_tests.rb +16 -25
- data/test/coord_sys/tc_ogc_cs.rb +151 -186
- data/test/coord_sys/tc_proj4.rb +35 -60
- data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
- data/test/coord_sys/tc_sr_org.rb +11 -19
- data/test/coord_sys/tc_url_reader.rb +13 -23
- data/test/geos_capi/tc_factory.rb +7 -16
- data/test/geos_capi/tc_geometry_collection.rb +6 -14
- data/test/geos_capi/tc_line_string.rb +7 -15
- data/test/geos_capi/tc_misc.rb +26 -41
- data/test/geos_capi/tc_multi_line_string.rb +6 -14
- data/test/geos_capi/tc_multi_point.rb +7 -15
- data/test/geos_capi/tc_multi_polygon.rb +8 -18
- data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
- data/test/geos_capi/tc_point.rb +12 -26
- data/test/geos_capi/tc_polygon.rb +52 -17
- data/test/geos_capi/tc_zmfactory.rb +7 -18
- data/test/geos_ffi/tc_factory.rb +7 -16
- data/test/geos_ffi/tc_geometry_collection.rb +7 -15
- data/test/geos_ffi/tc_line_string.rb +7 -15
- data/test/geos_ffi/tc_misc.rb +8 -18
- data/test/geos_ffi/tc_multi_line_string.rb +7 -15
- data/test/geos_ffi/tc_multi_point.rb +8 -16
- data/test/geos_ffi/tc_multi_polygon.rb +9 -18
- data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
- data/test/geos_ffi/tc_point.rb +13 -28
- data/test/geos_ffi/tc_polygon.rb +7 -17
- data/test/geos_ffi/tc_zmfactory.rb +8 -19
- data/test/projected_geographic/tc_factory.rb +7 -15
- data/test/projected_geographic/tc_geometry_collection.rb +7 -15
- data/test/projected_geographic/tc_line_string.rb +7 -15
- data/test/projected_geographic/tc_multi_line_string.rb +7 -16
- data/test/projected_geographic/tc_multi_point.rb +8 -17
- data/test/projected_geographic/tc_multi_polygon.rb +8 -16
- data/test/projected_geographic/tc_point.rb +11 -23
- data/test/projected_geographic/tc_polygon.rb +7 -15
- data/test/simple_cartesian/tc_calculations.rb +6 -22
- data/test/simple_cartesian/tc_factory.rb +7 -16
- data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
- data/test/simple_cartesian/tc_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_point.rb +7 -16
- data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
- data/test/simple_cartesian/tc_point.rb +10 -21
- data/test/simple_cartesian/tc_polygon.rb +6 -15
- data/test/simple_mercator/tc_factory.rb +6 -14
- data/test/simple_mercator/tc_geometry_collection.rb +6 -14
- data/test/simple_mercator/tc_line_string.rb +6 -14
- data/test/simple_mercator/tc_multi_line_string.rb +6 -15
- data/test/simple_mercator/tc_multi_point.rb +7 -16
- data/test/simple_mercator/tc_multi_polygon.rb +7 -15
- data/test/simple_mercator/tc_point.rb +11 -24
- data/test/simple_mercator/tc_polygon.rb +6 -14
- data/test/simple_mercator/tc_window.rb +10 -34
- data/test/spherical_geographic/tc_calculations.rb +5 -32
- data/test/spherical_geographic/tc_factory.rb +6 -15
- data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
- data/test/spherical_geographic/tc_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_point.rb +7 -16
- data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
- data/test/spherical_geographic/tc_point.rb +10 -22
- data/test/spherical_geographic/tc_polygon.rb +6 -15
- data/test/tc_cartesian_analysis.rb +4 -16
- data/test/tc_cartesian_bbox.rb +7 -21
- data/test/tc_mixins.rb +8 -25
- data/test/tc_oneoff.rb +5 -13
- data/test/tc_types.rb +7 -16
- data/test/wkrep/tc_wkb_generator.rb +63 -97
- data/test/wkrep/tc_wkb_parser.rb +63 -100
- data/test/wkrep/tc_wkt_generator.rb +54 -92
- data/test/wkrep/tc_wkt_parser.rb +84 -133
- metadata +39 -9
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
- data/test/coord_sys/tc_active_record_table.rb +0 -79
@@ -5,192 +5,125 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geos
|
10
|
-
|
11
|
-
|
12
|
-
module CAPIGeometryMethods # :nodoc:
|
13
|
-
|
14
|
-
|
9
|
+
module CAPIGeometryMethods # :nodoc:
|
15
10
|
include Feature::Instance
|
16
11
|
|
17
|
-
|
18
12
|
def inspect
|
19
13
|
"#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>"
|
20
14
|
end
|
21
15
|
|
22
|
-
|
23
16
|
# Marshal support
|
24
17
|
|
25
|
-
def marshal_dump
|
26
|
-
factory_ =
|
18
|
+
def marshal_dump # :nodoc:
|
19
|
+
factory_ = factory
|
27
20
|
[factory_, factory_._write_for_marshal(self)]
|
28
21
|
end
|
29
22
|
|
30
|
-
def marshal_load(data_)
|
23
|
+
def marshal_load(data_) # :nodoc:
|
31
24
|
obj_ = data_[0]._read_for_marshal(data_[1])
|
32
25
|
_steal(obj_)
|
33
26
|
end
|
34
27
|
|
35
|
-
|
36
28
|
# Psych support
|
37
29
|
|
38
|
-
def encode_with(coder_)
|
39
|
-
factory_ =
|
40
|
-
coder_[
|
30
|
+
def encode_with(coder_) # :nodoc:
|
31
|
+
factory_ = factory
|
32
|
+
coder_["factory"] = factory_
|
41
33
|
str_ = factory_._write_for_psych(self)
|
42
|
-
str_ = str_.encode(
|
43
|
-
coder_[
|
34
|
+
str_ = str_.encode("US-ASCII") if str_.respond_to?(:encode)
|
35
|
+
coder_["wkt"] = str_
|
44
36
|
end
|
45
37
|
|
46
|
-
def init_with(coder_)
|
47
|
-
obj_ = coder_[
|
38
|
+
def init_with(coder_) # :nodoc:
|
39
|
+
obj_ = coder_["factory"]._read_for_psych(coder_["wkt"])
|
48
40
|
_steal(obj_)
|
49
41
|
end
|
50
42
|
|
51
|
-
|
52
43
|
def as_text
|
53
44
|
str_ = _as_text
|
54
|
-
str_.force_encoding(
|
45
|
+
str_.force_encoding("US-ASCII") if str_.respond_to?(:force_encoding)
|
55
46
|
str_
|
56
47
|
end
|
57
48
|
alias_method :to_s, :as_text
|
58
|
-
|
59
|
-
|
60
49
|
end
|
61
50
|
|
62
|
-
|
63
|
-
module CAPIGeometryCollectionMethods # :nodoc:
|
64
|
-
|
51
|
+
module CAPIGeometryCollectionMethods # :nodoc:
|
65
52
|
include ::Enumerable
|
66
|
-
|
67
53
|
end
|
68
54
|
|
69
|
-
|
70
|
-
class CAPIGeometryImpl # :nodoc:
|
71
|
-
|
72
|
-
|
55
|
+
class CAPIGeometryImpl # :nodoc:
|
73
56
|
include CAPIGeometryMethods
|
74
57
|
|
75
58
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Geometry).include_in_class(self, true)
|
76
|
-
|
77
|
-
|
78
59
|
end
|
79
60
|
|
80
|
-
|
81
|
-
class CAPIPointImpl # :nodoc:
|
82
|
-
|
83
|
-
|
61
|
+
class CAPIPointImpl # :nodoc:
|
84
62
|
include CAPIGeometryMethods
|
85
63
|
include CAPIPointMethods
|
86
64
|
|
87
65
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self, true)
|
88
|
-
|
89
|
-
|
90
66
|
end
|
91
67
|
|
92
|
-
|
93
68
|
class CAPILineStringImpl # :nodoc:
|
94
|
-
|
95
|
-
|
96
69
|
include CAPIGeometryMethods
|
97
70
|
include CAPILineStringMethods
|
98
71
|
|
99
72
|
Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self, true)
|
100
|
-
|
101
|
-
|
102
73
|
end
|
103
74
|
|
104
|
-
|
105
75
|
class CAPILinearRingImpl # :nodoc:
|
106
|
-
|
107
|
-
|
108
76
|
include CAPIGeometryMethods
|
109
77
|
include CAPILineStringMethods
|
110
78
|
include CAPILinearRingMethods
|
111
79
|
|
112
80
|
Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self, true)
|
113
|
-
|
114
|
-
|
115
81
|
end
|
116
82
|
|
117
|
-
|
118
|
-
class CAPILineImpl # :nodoc:
|
119
|
-
|
120
|
-
|
83
|
+
class CAPILineImpl # :nodoc:
|
121
84
|
include CAPIGeometryMethods
|
122
85
|
include CAPILineStringMethods
|
123
86
|
include CAPILineMethods
|
124
87
|
|
125
88
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self, true)
|
126
|
-
|
127
|
-
|
128
89
|
end
|
129
90
|
|
130
|
-
|
131
|
-
class CAPIPolygonImpl # :nodoc:
|
132
|
-
|
133
|
-
|
91
|
+
class CAPIPolygonImpl # :nodoc:
|
134
92
|
include CAPIGeometryMethods
|
135
93
|
include CAPIPolygonMethods
|
136
94
|
|
137
95
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self, true)
|
138
|
-
|
139
|
-
|
140
96
|
end
|
141
97
|
|
142
|
-
|
143
|
-
class CAPIGeometryCollectionImpl # :nodoc:
|
144
|
-
|
145
|
-
|
98
|
+
class CAPIGeometryCollectionImpl # :nodoc:
|
146
99
|
include CAPIGeometryMethods
|
147
100
|
include CAPIGeometryCollectionMethods
|
148
101
|
|
149
102
|
Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self, true)
|
150
|
-
|
151
|
-
|
152
103
|
end
|
153
104
|
|
154
|
-
|
155
|
-
class CAPIMultiPointImpl # :nodoc:
|
156
|
-
|
157
|
-
|
105
|
+
class CAPIMultiPointImpl # :nodoc:
|
158
106
|
include CAPIGeometryMethods
|
159
107
|
include CAPIGeometryCollectionMethods
|
160
108
|
include CAPIMultiPointMethods
|
161
109
|
|
162
110
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self, true)
|
163
|
-
|
164
|
-
|
165
111
|
end
|
166
112
|
|
167
|
-
|
168
|
-
class CAPIMultiLineStringImpl # :nodoc:
|
169
|
-
|
170
|
-
|
113
|
+
class CAPIMultiLineStringImpl # :nodoc:
|
171
114
|
include CAPIGeometryMethods
|
172
115
|
include CAPIGeometryCollectionMethods
|
173
116
|
include CAPIMultiLineStringMethods
|
174
117
|
|
175
118
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self, true)
|
176
|
-
|
177
|
-
|
178
119
|
end
|
179
120
|
|
180
|
-
|
181
|
-
class CAPIMultiPolygonImpl # :nodoc:
|
182
|
-
|
183
|
-
|
121
|
+
class CAPIMultiPolygonImpl # :nodoc:
|
184
122
|
include CAPIGeometryMethods
|
185
123
|
include CAPIGeometryCollectionMethods
|
186
124
|
include CAPIMultiPolygonMethods
|
187
125
|
|
188
126
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self, true)
|
189
|
-
|
190
|
-
|
191
127
|
end
|
192
|
-
|
193
|
-
|
194
128
|
end
|
195
|
-
|
196
129
|
end
|
@@ -5,24 +5,18 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geos
|
10
|
-
|
11
|
-
|
12
9
|
# This the FFI-GEOS implementation of ::RGeo::Feature::Factory.
|
13
10
|
|
14
11
|
class FFIFactory
|
15
|
-
|
16
|
-
|
17
12
|
include Feature::Factory::Instance
|
18
13
|
|
19
|
-
|
20
14
|
# Create a new factory. Returns nil if the FFI-GEOS implementation
|
21
15
|
# is not supported.
|
22
16
|
#
|
23
17
|
# See ::RGeo::Geos.factory for a list of supported options.
|
24
18
|
|
25
|
-
def initialize(opts_={})
|
19
|
+
def initialize(opts_ = {})
|
26
20
|
# Main flags
|
27
21
|
@uses_lenient_multi_polygon_assertions = opts_[:uses_lenient_assertions] ||
|
28
22
|
opts_[:lenient_multi_polygon_assertions] || opts_[:uses_lenient_multi_polygon_assertions]
|
@@ -46,7 +40,7 @@ module RGeo
|
|
46
40
|
@wkt_generator = WKRep::WKTGenerator.new(wkt_generator_)
|
47
41
|
@wkt_writer = nil
|
48
42
|
else
|
49
|
-
@wkt_generator = WKRep::WKTGenerator.new(:
|
43
|
+
@wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
|
50
44
|
@wkt_writer = nil
|
51
45
|
end
|
52
46
|
wkb_generator_ = opts_[:wkb_generator]
|
@@ -66,15 +60,19 @@ module RGeo
|
|
66
60
|
@srid = opts_[:srid]
|
67
61
|
@proj4 = opts_[:proj4]
|
68
62
|
if CoordSys::Proj4.supported?
|
69
|
-
if @proj4.
|
63
|
+
if @proj4.is_a?(::String) || @proj4.is_a?(::Hash)
|
70
64
|
@proj4 = CoordSys::Proj4.create(@proj4)
|
71
65
|
end
|
72
66
|
else
|
73
67
|
@proj4 = nil
|
74
68
|
end
|
75
69
|
@coord_sys = opts_[:coord_sys]
|
76
|
-
if @coord_sys.
|
77
|
-
@coord_sys =
|
70
|
+
if @coord_sys.is_a?(::String)
|
71
|
+
@coord_sys = begin
|
72
|
+
CoordSys::CS.create_from_wkt(@coord_sys)
|
73
|
+
rescue
|
74
|
+
nil
|
75
|
+
end
|
78
76
|
end
|
79
77
|
if (!@proj4 || !@coord_sys) && @srid && (db_ = opts_[:srs_database])
|
80
78
|
entry_ = db_.get(@srid.to_i)
|
@@ -113,14 +111,12 @@ module RGeo
|
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
116
|
-
|
117
114
|
# Standard object inspection output
|
118
115
|
|
119
116
|
def inspect
|
120
117
|
"#<#{self.class}:0x#{object_id.to_s(16)} srid=#{srid}>"
|
121
118
|
end
|
122
119
|
|
123
|
-
|
124
120
|
# Factory equivalence test.
|
125
121
|
|
126
122
|
def eql?(rhs_)
|
@@ -132,129 +128,119 @@ module RGeo
|
|
132
128
|
end
|
133
129
|
alias_method :==, :eql?
|
134
130
|
|
135
|
-
|
136
131
|
# Standard hash code
|
137
132
|
|
138
133
|
def hash
|
139
134
|
@hash ||= [@srid, @has_z, @has_m, @buffer_resolution, @proj4].hash
|
140
135
|
end
|
141
136
|
|
142
|
-
|
143
137
|
# Marshal support
|
144
138
|
|
145
|
-
def marshal_dump
|
139
|
+
def marshal_dump # :nodoc:
|
146
140
|
hash_ = {
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
141
|
+
"hasz" => @has_z,
|
142
|
+
"hasm" => @has_m,
|
143
|
+
"srid" => @srid,
|
144
|
+
"bufr" => @buffer_resolution,
|
145
|
+
"wktg" => @wkt_generator._properties,
|
146
|
+
"wkbg" => @wkb_generator._properties,
|
147
|
+
"wktp" => @wkt_parser._properties,
|
148
|
+
"wkbp" => @wkb_parser._properties,
|
149
|
+
"lmpa" => @uses_lenient_multi_polygon_assertions,
|
150
|
+
"apre" => @_auto_prepare
|
157
151
|
}
|
158
|
-
hash_[
|
159
|
-
hash_[
|
152
|
+
hash_["proj4"] = @proj4.marshal_dump if @proj4
|
153
|
+
hash_["cs"] = @coord_sys.to_wkt if @coord_sys
|
160
154
|
hash_
|
161
155
|
end
|
162
156
|
|
163
|
-
def marshal_load(data_)
|
164
|
-
if CoordSys::Proj4.supported? && (proj4_data_ = data_[
|
157
|
+
def marshal_load(data_) # :nodoc:
|
158
|
+
if CoordSys::Proj4.supported? && (proj4_data_ = data_["proj4"])
|
165
159
|
proj4_ = CoordSys::Proj4.allocate
|
166
160
|
proj4_.marshal_load(proj4_data_)
|
167
161
|
else
|
168
162
|
proj4_ = nil
|
169
163
|
end
|
170
|
-
if (coord_sys_data_ = data_[
|
164
|
+
if (coord_sys_data_ = data_["cs"])
|
171
165
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
|
172
166
|
else
|
173
167
|
coord_sys_ = nil
|
174
168
|
end
|
175
169
|
initialize(
|
176
|
-
:
|
177
|
-
:
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
186
|
-
:
|
187
|
-
:
|
170
|
+
has_z_coordinate: data_["hasz"],
|
171
|
+
has_m_coordinate: data_["hasm"],
|
172
|
+
srid: data_["srid"],
|
173
|
+
buffer_resolution: data_["bufr"],
|
174
|
+
wkt_generator: ImplHelper::Utils.symbolize_hash(data_["wktg"]),
|
175
|
+
wkb_generator: ImplHelper::Utils.symbolize_hash(data_["wkbg"]),
|
176
|
+
wkt_parser: ImplHelper::Utils.symbolize_hash(data_["wktp"]),
|
177
|
+
wkb_parser: ImplHelper::Utils.symbolize_hash(data_["wkbp"]),
|
178
|
+
uses_lenient_multi_polygon_assertions: data_["lmpa"],
|
179
|
+
auto_prepare: (data_["apre"] ? :simple : :disabled),
|
180
|
+
proj4: proj4_,
|
181
|
+
coord_sys: coord_sys_
|
188
182
|
)
|
189
183
|
end
|
190
184
|
|
191
|
-
|
192
185
|
# Psych support
|
193
186
|
|
194
|
-
def encode_with(coder_)
|
195
|
-
coder_[
|
196
|
-
coder_[
|
197
|
-
coder_[
|
198
|
-
coder_[
|
199
|
-
coder_[
|
200
|
-
coder_[
|
201
|
-
coder_[
|
202
|
-
coder_[
|
203
|
-
coder_[
|
204
|
-
coder_[
|
187
|
+
def encode_with(coder_) # :nodoc:
|
188
|
+
coder_["has_z_coordinate"] = @has_z
|
189
|
+
coder_["has_m_coordinate"] = @has_m
|
190
|
+
coder_["srid"] = @srid
|
191
|
+
coder_["buffer_resolution"] = @buffer_resolution
|
192
|
+
coder_["lenient_multi_polygon_assertions"] = @uses_lenient_multi_polygon_assertions
|
193
|
+
coder_["wkt_generator"] = @wkt_generator._properties
|
194
|
+
coder_["wkb_generator"] = @wkb_generator._properties
|
195
|
+
coder_["wkt_parser"] = @wkt_parser._properties
|
196
|
+
coder_["wkb_parser"] = @wkb_parser._properties
|
197
|
+
coder_["auto_prepare"] = @_auto_prepare ? "simple" : "disabled"
|
205
198
|
if @proj4
|
206
199
|
str_ = @proj4.original_str || @proj4.canonical_str
|
207
|
-
coder_[
|
200
|
+
coder_["proj4"] = @proj4.radians? ? { "proj4" => str_, "radians" => true } : str_
|
208
201
|
end
|
209
|
-
coder_[
|
202
|
+
coder_["coord_sys"] = @coord_sys.to_wkt if @coord_sys
|
210
203
|
end
|
211
204
|
|
212
|
-
def init_with(coder_)
|
213
|
-
if (proj4_data_ = coder_[
|
205
|
+
def init_with(coder_) # :nodoc:
|
206
|
+
if (proj4_data_ = coder_["proj4"])
|
214
207
|
if proj4_data_.is_a?(::Hash)
|
215
|
-
proj4_ = CoordSys::Proj4.create(proj4_data_[
|
208
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_["proj4"], radians: proj4_data_["radians"])
|
216
209
|
else
|
217
210
|
proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
|
218
211
|
end
|
219
212
|
else
|
220
213
|
proj4_ = nil
|
221
214
|
end
|
222
|
-
if (coord_sys_data_ = coder_[
|
215
|
+
if (coord_sys_data_ = coder_["cs"])
|
223
216
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
|
224
217
|
else
|
225
218
|
coord_sys_ = nil
|
226
219
|
end
|
227
220
|
initialize(
|
228
|
-
:
|
229
|
-
:
|
230
|
-
:
|
231
|
-
:
|
232
|
-
:
|
233
|
-
:
|
234
|
-
:
|
235
|
-
:
|
236
|
-
:
|
237
|
-
:
|
238
|
-
:
|
239
|
-
:
|
221
|
+
has_z_coordinate: coder_["has_z_coordinate"],
|
222
|
+
has_m_coordinate: coder_["has_m_coordinate"],
|
223
|
+
srid: coder_["srid"],
|
224
|
+
buffer_resolution: coder_["buffer_resolution"],
|
225
|
+
wkt_generator: ImplHelper::Utils.symbolize_hash(coder_["wkt_generator"]),
|
226
|
+
wkb_generator: ImplHelper::Utils.symbolize_hash(coder_["wkb_generator"]),
|
227
|
+
wkt_parser: ImplHelper::Utils.symbolize_hash(coder_["wkt_parser"]),
|
228
|
+
wkb_parser: ImplHelper::Utils.symbolize_hash(coder_["wkb_parser"]),
|
229
|
+
auto_prepare: coder_["auto_prepare"] == "disabled" ? :disabled : :simple,
|
230
|
+
uses_lenient_multi_polygon_assertions: coder_["lenient_multi_polygon_assertions"],
|
231
|
+
proj4: proj4_,
|
232
|
+
coord_sys: coord_sys_
|
240
233
|
)
|
241
234
|
end
|
242
235
|
|
243
|
-
|
244
236
|
# Returns the SRID of geometries created by this factory.
|
245
237
|
|
246
|
-
|
247
|
-
@srid
|
248
|
-
end
|
249
|
-
|
238
|
+
attr_reader :srid
|
250
239
|
|
251
240
|
# Returns the resolution used by buffer calculations on geometries
|
252
241
|
# created by this factory
|
253
242
|
|
254
|
-
|
255
|
-
@buffer_resolution
|
256
|
-
end
|
257
|
-
|
243
|
+
attr_reader :buffer_resolution
|
258
244
|
|
259
245
|
# Returns true if this factory is lenient with MultiPolygon assertions
|
260
246
|
|
@@ -262,7 +248,6 @@ module RGeo
|
|
262
248
|
@uses_lenient_multi_polygon_assertions
|
263
249
|
end
|
264
250
|
|
265
|
-
|
266
251
|
# See ::RGeo::Feature::Factory#property
|
267
252
|
|
268
253
|
def property(name_)
|
@@ -279,19 +264,15 @@ module RGeo
|
|
279
264
|
@uses_lenient_multi_polygon_assertions
|
280
265
|
when :auto_prepare
|
281
266
|
@_auto_prepare ? :simple : :disabled
|
282
|
-
else
|
283
|
-
nil
|
284
267
|
end
|
285
268
|
end
|
286
269
|
|
287
|
-
|
288
270
|
# Create a feature that wraps the given ffi-geos geometry object
|
289
271
|
|
290
272
|
def wrap_fg_geom(fg_geom_)
|
291
273
|
_wrap_fg_geom(fg_geom_, nil)
|
292
274
|
end
|
293
275
|
|
294
|
-
|
295
276
|
# See ::RGeo::Feature::Factory#parse_wkt
|
296
277
|
|
297
278
|
def parse_wkt(str_)
|
@@ -302,7 +283,6 @@ module RGeo
|
|
302
283
|
end
|
303
284
|
end
|
304
285
|
|
305
|
-
|
306
286
|
# See ::RGeo::Feature::Factory#parse_wkb
|
307
287
|
|
308
288
|
def parse_wkb(str_)
|
@@ -313,10 +293,9 @@ module RGeo
|
|
313
293
|
end
|
314
294
|
end
|
315
295
|
|
316
|
-
|
317
296
|
# See ::RGeo::Feature::Factory#point
|
318
297
|
|
319
|
-
def point(x_, y_, z_=0)
|
298
|
+
def point(x_, y_, z_ = 0)
|
320
299
|
cs_ = ::Geos::CoordinateSequence.new(1, 3)
|
321
300
|
cs_.set_x(0, x_)
|
322
301
|
cs_.set_y(0, y_)
|
@@ -324,11 +303,10 @@ module RGeo
|
|
324
303
|
FFIPointImpl.new(self, ::Geos::Utils.create_point(cs_), nil)
|
325
304
|
end
|
326
305
|
|
327
|
-
|
328
306
|
# See ::RGeo::Feature::Factory#line_string
|
329
307
|
|
330
308
|
def line_string(points_)
|
331
|
-
points_ = points_.to_a unless points_.
|
309
|
+
points_ = points_.to_a unless points_.is_a?(::Array)
|
332
310
|
size_ = points_.size
|
333
311
|
return nil if size_ == 1
|
334
312
|
cs_ = ::Geos::CoordinateSequence.new(size_, 3)
|
@@ -345,7 +323,6 @@ module RGeo
|
|
345
323
|
FFILineStringImpl.new(self, ::Geos::Utils.create_line_string(cs_), nil)
|
346
324
|
end
|
347
325
|
|
348
|
-
|
349
326
|
# See ::RGeo::Feature::Factory#line
|
350
327
|
|
351
328
|
def line(start_, end_)
|
@@ -366,20 +343,18 @@ module RGeo
|
|
366
343
|
FFILineImpl.new(self, ::Geos::Utils.create_line_string(cs_), nil)
|
367
344
|
end
|
368
345
|
|
369
|
-
|
370
346
|
# See ::RGeo::Feature::Factory#linear_ring
|
371
347
|
|
372
348
|
def linear_ring(points_)
|
373
|
-
points_ = points_.to_a unless points_.
|
349
|
+
points_ = points_.to_a unless points_.is_a?(::Array)
|
374
350
|
fg_geom_ = _create_fg_linear_ring(points_)
|
375
351
|
fg_geom_ ? FFILinearRingImpl.new(self, fg_geom_, nil) : nil
|
376
352
|
end
|
377
353
|
|
378
|
-
|
379
354
|
# See ::RGeo::Feature::Factory#polygon
|
380
355
|
|
381
|
-
def polygon(outer_ring_, inner_rings_=nil)
|
382
|
-
inner_rings_ = inner_rings_.to_a unless inner_rings_.
|
356
|
+
def polygon(outer_ring_, inner_rings_ = nil)
|
357
|
+
inner_rings_ = inner_rings_.to_a unless inner_rings_.is_a?(::Array)
|
383
358
|
return nil unless ::RGeo::Feature::LineString.check_type(outer_ring_)
|
384
359
|
outer_ring_ = _create_fg_linear_ring(outer_ring_.points)
|
385
360
|
inner_rings_ = inner_rings_.map do |r_|
|
@@ -391,11 +366,10 @@ module RGeo
|
|
391
366
|
fg_geom_ ? FFIPolygonImpl.new(self, fg_geom_, nil) : nil
|
392
367
|
end
|
393
368
|
|
394
|
-
|
395
369
|
# See ::RGeo::Feature::Factory#collection
|
396
370
|
|
397
371
|
def collection(elems_)
|
398
|
-
elems_ = elems_.to_a unless elems_.
|
372
|
+
elems_ = elems_.to_a unless elems_.is_a?(::Array)
|
399
373
|
klasses_ = []
|
400
374
|
fg_geoms_ = []
|
401
375
|
elems_.each do |elem_|
|
@@ -411,11 +385,10 @@ module RGeo
|
|
411
385
|
fg_geom_ ? FFIGeometryCollectionImpl.new(self, fg_geom_, klasses_) : nil
|
412
386
|
end
|
413
387
|
|
414
|
-
|
415
388
|
# See ::RGeo::Feature::Factory#multi_point
|
416
389
|
|
417
390
|
def multi_point(elems_)
|
418
|
-
elems_ = elems_.to_a unless elems_.
|
391
|
+
elems_ = elems_.to_a unless elems_.is_a?(::Array)
|
419
392
|
elems_ = elems_.map do |elem_|
|
420
393
|
elem_ = ::RGeo::Feature.cast(elem_, self, ::RGeo::Feature::Point,
|
421
394
|
:force_new, :keep_subtype)
|
@@ -428,11 +401,10 @@ module RGeo
|
|
428
401
|
fg_geom_ ? FFIMultiPointImpl.new(self, fg_geom_, klasses_) : nil
|
429
402
|
end
|
430
403
|
|
431
|
-
|
432
404
|
# See ::RGeo::Feature::Factory#multi_line_string
|
433
405
|
|
434
406
|
def multi_line_string(elems_)
|
435
|
-
elems_ = elems_.to_a unless elems_.
|
407
|
+
elems_ = elems_.to_a unless elems_.is_a?(::Array)
|
436
408
|
klasses_ = []
|
437
409
|
elems_ = elems_.map do |elem_|
|
438
410
|
elem_ = ::RGeo::Feature.cast(elem_, self, ::RGeo::Feature::LineString,
|
@@ -446,11 +418,10 @@ module RGeo
|
|
446
418
|
fg_geom_ ? FFIMultiLineStringImpl.new(self, fg_geom_, klasses_) : nil
|
447
419
|
end
|
448
420
|
|
449
|
-
|
450
421
|
# See ::RGeo::Feature::Factory#multi_polygon
|
451
422
|
|
452
423
|
def multi_polygon(elems_)
|
453
|
-
elems_ = elems_.to_a unless elems_.
|
424
|
+
elems_ = elems_.to_a unless elems_.is_a?(::Array)
|
454
425
|
elems_ = elems_.map do |elem_|
|
455
426
|
elem_ = ::RGeo::Feature.cast(elem_, self, ::RGeo::Feature::Polygon,
|
456
427
|
:force_new, :keep_subtype)
|
@@ -473,34 +444,25 @@ module RGeo
|
|
473
444
|
fg_geom_ ? FFIMultiPolygonImpl.new(self, fg_geom_, klasses_) : nil
|
474
445
|
end
|
475
446
|
|
476
|
-
|
477
447
|
# See ::RGeo::Feature::Factory#proj4
|
478
448
|
|
479
|
-
|
480
|
-
@proj4
|
481
|
-
end
|
482
|
-
|
449
|
+
attr_reader :proj4
|
483
450
|
|
484
451
|
# See ::RGeo::Feature::Factory#coord_sys
|
485
452
|
|
486
|
-
|
487
|
-
@coord_sys
|
488
|
-
end
|
489
|
-
|
453
|
+
attr_reader :coord_sys
|
490
454
|
|
491
455
|
# See ::RGeo::Feature::Factory#override_cast
|
492
456
|
|
493
|
-
def override_cast(
|
457
|
+
def override_cast(_original_, _ntype_, _flags_)
|
494
458
|
false
|
495
459
|
# TODO
|
496
460
|
end
|
497
461
|
|
462
|
+
attr_reader :_has_3d # :nodoc:
|
463
|
+
attr_reader :_auto_prepare # :nodoc:
|
498
464
|
|
499
|
-
|
500
|
-
attr_reader :_auto_prepare # :nodoc:
|
501
|
-
|
502
|
-
|
503
|
-
def _wrap_fg_geom(fg_geom_, klass_) # :nodoc:
|
465
|
+
def _wrap_fg_geom(fg_geom_, klass_) # :nodoc:
|
504
466
|
klasses_ = nil
|
505
467
|
|
506
468
|
# We don't allow "empty" points, so replace such objects with
|
@@ -510,7 +472,7 @@ module RGeo
|
|
510
472
|
klass_ = FFIGeometryCollectionImpl
|
511
473
|
end
|
512
474
|
|
513
|
-
unless klass_.
|
475
|
+
unless klass_.is_a?(::Class)
|
514
476
|
is_collection_ = false
|
515
477
|
case fg_geom_.type_id
|
516
478
|
when ::Geos::GeomTypes::GEOS_POINT
|
@@ -536,16 +498,13 @@ module RGeo
|
|
536
498
|
else
|
537
499
|
inferred_klass_ = FFIGeometryImpl
|
538
500
|
end
|
539
|
-
if is_collection_ && klass_.is_a?(::Array)
|
540
|
-
klasses_ = klass_
|
541
|
-
end
|
501
|
+
klasses_ = klass_ if is_collection_ && klass_.is_a?(::Array)
|
542
502
|
klass_ = inferred_klass_
|
543
503
|
end
|
544
504
|
klass_.new(self, fg_geom_, klasses_)
|
545
505
|
end
|
546
506
|
|
547
|
-
|
548
|
-
def _convert_to_fg_geometry(obj_, type_=nil) # :nodoc:
|
507
|
+
def _convert_to_fg_geometry(obj_, type_ = nil) # :nodoc:
|
549
508
|
if type_.nil? && obj_.factory == self
|
550
509
|
obj_
|
551
510
|
else
|
@@ -554,12 +513,11 @@ module RGeo
|
|
554
513
|
obj_ ? obj_.fg_geom : nil
|
555
514
|
end
|
556
515
|
|
557
|
-
|
558
|
-
def _create_fg_linear_ring(points_) # :nodoc:
|
516
|
+
def _create_fg_linear_ring(points_) # :nodoc:
|
559
517
|
size_ = points_.size
|
560
518
|
return nil if size_ == 1 || size_ == 2
|
561
519
|
if size_ > 0 && points_.first != points_.last
|
562
|
-
points_
|
520
|
+
points_ += [points_.first]
|
563
521
|
size_ += 1
|
564
522
|
end
|
565
523
|
cs_ = ::Geos::CoordinateSequence.new(size_, 3)
|
@@ -576,7 +534,6 @@ module RGeo
|
|
576
534
|
::Geos::Utils.create_linear_ring(cs_)
|
577
535
|
end
|
578
536
|
|
579
|
-
|
580
537
|
def _generate_wkt(geom_) # :nodoc:
|
581
538
|
if @wkt_writer
|
582
539
|
@wkt_writer.write(geom_.fg_geom)
|
@@ -585,7 +542,6 @@ module RGeo
|
|
585
542
|
end
|
586
543
|
end
|
587
544
|
|
588
|
-
|
589
545
|
def _generate_wkb(geom_) # :nodoc:
|
590
546
|
if @wkb_writer
|
591
547
|
@wkb_writer.write(geom_.fg_geom)
|
@@ -594,8 +550,7 @@ module RGeo
|
|
594
550
|
end
|
595
551
|
end
|
596
552
|
|
597
|
-
|
598
|
-
def _write_for_marshal(geom_) # :nodoc:
|
553
|
+
def _write_for_marshal(geom_) # :nodoc:
|
599
554
|
if Utils.ffi_supports_set_output_dimension || !@_has_3d
|
600
555
|
unless defined?(@marshal_wkb_writer)
|
601
556
|
@marshal_wkb_writer = ::Geos::WkbWriter.new
|
@@ -607,7 +562,6 @@ module RGeo
|
|
607
562
|
end
|
608
563
|
end
|
609
564
|
|
610
|
-
|
611
565
|
def _read_for_marshal(str_) # :nodoc:
|
612
566
|
unless defined?(@marshal_wkb_reader)
|
613
567
|
@marshal_wkb_reader = ::Geos::WkbReader.new
|
@@ -615,7 +569,6 @@ module RGeo
|
|
615
569
|
@marshal_wkb_reader.read(str_)
|
616
570
|
end
|
617
571
|
|
618
|
-
|
619
572
|
def _write_for_psych(geom_) # :nodoc:
|
620
573
|
if Utils.ffi_supports_set_output_dimension || !@_has_3d
|
621
574
|
unless defined?(@psych_wkt_writer)
|
@@ -628,18 +581,12 @@ module RGeo
|
|
628
581
|
end
|
629
582
|
end
|
630
583
|
|
631
|
-
|
632
|
-
def _read_for_psych(str_) # :nodoc:
|
584
|
+
def _read_for_psych(str_) # :nodoc:
|
633
585
|
unless defined?(@psych_wkt_reader)
|
634
586
|
@psych_wkt_reader = ::Geos::WktReader.new
|
635
587
|
end
|
636
588
|
@psych_wkt_reader.read(str_)
|
637
589
|
end
|
638
|
-
|
639
|
-
|
640
590
|
end
|
641
|
-
|
642
|
-
|
643
591
|
end
|
644
|
-
|
645
592
|
end
|