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
Binary file
|
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -5,26 +5,20 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geos
|
10
|
-
|
11
9
|
class << self
|
12
|
-
|
13
|
-
|
14
10
|
# Returns true if the CAPI GEOS implementation is supported.
|
15
11
|
|
16
12
|
def capi_supported?
|
17
13
|
CAPI_SUPPORTED
|
18
14
|
end
|
19
15
|
|
20
|
-
|
21
16
|
# Returns true if the FFI GEOS implementation is supported.
|
22
17
|
|
23
18
|
def ffi_supported?
|
24
19
|
FFI_SUPPORTED
|
25
20
|
end
|
26
21
|
|
27
|
-
|
28
22
|
# Returns true if any GEOS implementation is supported.
|
29
23
|
# If this returns false, GEOS features are not available at all.
|
30
24
|
|
@@ -32,7 +26,6 @@ module RGeo
|
|
32
26
|
FFI_SUPPORTED || CAPI_SUPPORTED
|
33
27
|
end
|
34
28
|
|
35
|
-
|
36
29
|
# Returns true if the given feature is a CAPI GEOS feature, or if
|
37
30
|
# the given factory is a CAPI GEOS factory.
|
38
31
|
|
@@ -43,7 +36,6 @@ module RGeo
|
|
43
36
|
ZMGeometryMethods === object_ && CAPIGeometryMethods === object_.z_geometry)
|
44
37
|
end
|
45
38
|
|
46
|
-
|
47
39
|
# Returns true if the given feature is an FFI GEOS feature, or if
|
48
40
|
# the given factory is an FFI GEOS factory.
|
49
41
|
|
@@ -54,7 +46,6 @@ module RGeo
|
|
54
46
|
ZMGeometryMethods === object_ && FFIGeometryMethods === object_.z_geometry)
|
55
47
|
end
|
56
48
|
|
57
|
-
|
58
49
|
# Returns true if the given feature is a GEOS feature, or if the given
|
59
50
|
# factory is a GEOS factory. Does not distinguish between CAPI and FFI.
|
60
51
|
|
@@ -64,7 +55,6 @@ module RGeo
|
|
64
55
|
ZMFactory === object_ || ZMGeometryMethods === object_
|
65
56
|
end
|
66
57
|
|
67
|
-
|
68
58
|
# Returns the GEOS library version as a string of the format "x.y.z".
|
69
59
|
# Returns nil if GEOS is not available.
|
70
60
|
|
@@ -73,7 +63,7 @@ module RGeo
|
|
73
63
|
if ::RGeo::Geos::CAPI_SUPPORTED
|
74
64
|
@version = ::RGeo::Geos::CAPIFactory._geos_version.freeze
|
75
65
|
elsif ::RGeo::Geos::FFI_SUPPORTED
|
76
|
-
@version = ::Geos::FFIGeos.GEOSversion.sub(/-CAPI-.*$/,
|
66
|
+
@version = ::Geos::FFIGeos.GEOSversion.sub(/-CAPI-.*$/, "").freeze
|
77
67
|
else
|
78
68
|
@version = nil
|
79
69
|
end
|
@@ -81,7 +71,6 @@ module RGeo
|
|
81
71
|
@version
|
82
72
|
end
|
83
73
|
|
84
|
-
|
85
74
|
# The preferred native interface. This is the native interface
|
86
75
|
# used by default when a factory is created.
|
87
76
|
# Supported values are <tt>:capi</tt> and <tt>:ffi</tt>.
|
@@ -94,7 +83,6 @@ module RGeo
|
|
94
83
|
|
95
84
|
attr_accessor :preferred_native_interface
|
96
85
|
|
97
|
-
|
98
86
|
# Returns a factory for the GEOS implementation.
|
99
87
|
# Returns nil if the GEOS implementation is not supported.
|
100
88
|
#
|
@@ -185,7 +173,7 @@ module RGeo
|
|
185
173
|
# never automatically generates a prepared geometry (unless you
|
186
174
|
# generate one explicitly using the <tt>prepare!</tt> method).
|
187
175
|
|
188
|
-
def factory(opts_={})
|
176
|
+
def factory(opts_ = {})
|
189
177
|
if supported?
|
190
178
|
native_interface_ = opts_[:native_interface] || Geos.preferred_native_interface
|
191
179
|
if opts_[:has_z_coordinate] && opts_[:has_m_coordinate]
|
@@ -195,12 +183,9 @@ module RGeo
|
|
195
183
|
else
|
196
184
|
CAPIFactory.create(opts_)
|
197
185
|
end
|
198
|
-
else
|
199
|
-
nil
|
200
186
|
end
|
201
187
|
end
|
202
188
|
|
203
|
-
|
204
189
|
# Returns a Feature::FactoryGenerator that creates Geos-backed
|
205
190
|
# factories. The given options are used as the default options.
|
206
191
|
#
|
@@ -209,13 +194,9 @@ module RGeo
|
|
209
194
|
# an SRID and it will automatically fetch the appropriate Proj4
|
210
195
|
# and CoordSys objects.
|
211
196
|
|
212
|
-
def factory_generator(defaults_={})
|
213
|
-
::Proc.new{ |c_| factory(defaults_.merge(c_)) }
|
197
|
+
def factory_generator(defaults_ = {})
|
198
|
+
::Proc.new { |c_| factory(defaults_.merge(c_)) }
|
214
199
|
end
|
215
|
-
|
216
|
-
|
217
200
|
end
|
218
|
-
|
219
201
|
end
|
220
|
-
|
221
202
|
end
|
data/lib/rgeo/geos/utils.rb
CHANGED
@@ -5,15 +5,9 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geos
|
10
|
-
|
11
|
-
|
12
|
-
module Utils # :nodoc:
|
13
|
-
|
9
|
+
module Utils # :nodoc:
|
14
10
|
class << self
|
15
|
-
|
16
|
-
|
17
11
|
def ffi_coord_seqs_equal?(cs1_, cs2_, check_z_)
|
18
12
|
len1_ = cs1_.length
|
19
13
|
len2_ = cs2_.length
|
@@ -29,7 +23,6 @@ module RGeo
|
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
32
|
-
|
33
26
|
def ffi_compute_dimension(geom_)
|
34
27
|
result_ = -1
|
35
28
|
case geom_.type_id
|
@@ -54,21 +47,19 @@ module RGeo
|
|
54
47
|
result_
|
55
48
|
end
|
56
49
|
|
57
|
-
|
58
|
-
|
59
|
-
(0...cs_.length).inject(hash_) do |h_, i_|
|
50
|
+
def ffi_coord_seq_hash(cs_, hash_ = 0)
|
51
|
+
(0...cs_.length).inject(hash_) do |_h_, i_|
|
60
52
|
[hash_, cs_.get_x(i_), cs_.get_y(i_), cs_.get_z(i_)].hash
|
61
53
|
end
|
62
54
|
end
|
63
55
|
|
64
|
-
|
65
56
|
def _init
|
66
57
|
if FFI_SUPPORTED
|
67
58
|
@ffi_supports_prepared_level_1 = ::Geos::FFIGeos.respond_to?(:GEOSPreparedContains_r)
|
68
59
|
@ffi_supports_prepared_level_2 = ::Geos::FFIGeos.respond_to?(:GEOSPreparedDisjoint_r)
|
69
60
|
@ffi_supports_set_output_dimension = ::Geos::FFIGeos.respond_to?(:GEOSWKTWriter_setOutputDimension_r)
|
70
61
|
end
|
71
|
-
@psych_wkt_generator = WKRep::WKTGenerator.new(:
|
62
|
+
@psych_wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
|
72
63
|
@marshal_wkb_generator = WKRep::WKBGenerator.new
|
73
64
|
end
|
74
65
|
|
@@ -77,13 +68,7 @@ module RGeo
|
|
77
68
|
attr_reader :ffi_supports_set_output_dimension
|
78
69
|
attr_reader :psych_wkt_generator
|
79
70
|
attr_reader :marshal_wkb_generator
|
80
|
-
|
81
|
-
|
82
71
|
end
|
83
|
-
|
84
72
|
end
|
85
|
-
|
86
|
-
|
87
73
|
end
|
88
|
-
|
89
74
|
end
|
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -5,17 +5,12 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geos
|
10
|
-
|
11
|
-
|
12
9
|
# A factory for Geos that handles both Z and M.
|
13
10
|
|
14
11
|
class ZMFactory
|
15
|
-
|
16
12
|
include Feature::Factory::Instance
|
17
13
|
|
18
|
-
|
19
14
|
# :stopdoc:
|
20
15
|
|
21
16
|
TYPE_KLASSES = {
|
@@ -27,28 +22,22 @@ module RGeo
|
|
27
22
|
Feature::GeometryCollection => ZMGeometryCollectionImpl,
|
28
23
|
Feature::MultiPoint => ZMMultiPointImpl,
|
29
24
|
Feature::MultiLineString => ZMMultiLineStringImpl,
|
30
|
-
Feature::MultiPolygon => ZMMultiPolygonImpl
|
25
|
+
Feature::MultiPolygon => ZMMultiPolygonImpl
|
31
26
|
}.freeze
|
32
27
|
|
33
28
|
# :startdoc:
|
34
29
|
|
35
|
-
|
36
30
|
class << self
|
37
|
-
|
38
|
-
|
39
31
|
# Create a new factory. Returns nil if the GEOS implementation is
|
40
32
|
# not supported.
|
41
33
|
|
42
|
-
def create(opts_={})
|
34
|
+
def create(opts_ = {})
|
43
35
|
return nil unless Geos.supported?
|
44
36
|
new(opts_)
|
45
37
|
end
|
46
|
-
|
47
|
-
|
48
38
|
end
|
49
39
|
|
50
|
-
|
51
|
-
def initialize(opts_={}) # :nodoc:
|
40
|
+
def initialize(opts_ = {}) # :nodoc:
|
52
41
|
proj4_ = opts_[:proj4]
|
53
42
|
coord_sys_ = opts_[:coord_sys]
|
54
43
|
srid_ = opts_[:srid]
|
@@ -61,20 +50,20 @@ module RGeo
|
|
61
50
|
end
|
62
51
|
srid_ ||= coord_sys_.authority_code if coord_sys_
|
63
52
|
config_ = {
|
64
|
-
:
|
53
|
+
uses_lenient_multi_polygon_assertions: opts_[:lenient_multi_polygon_assertions] ||
|
65
54
|
opts_[:uses_lenient_multi_polygon_assertions],
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
55
|
+
buffer_resolution: opts_[:buffer_resolution], auto_prepare: opts_[:auto_prepare],
|
56
|
+
wkt_generator: opts_[:wkt_generator], wkt_parser: opts_[:wkt_parser],
|
57
|
+
wkb_generator: opts_[:wkb_generator], wkb_parser: opts_[:wkb_parser],
|
58
|
+
srid: srid_.to_i, proj4: proj4_, coord_sys: coord_sys_
|
70
59
|
}
|
71
60
|
native_interface_ = opts_[:native_interface] || Geos.preferred_native_interface
|
72
61
|
if native_interface_ == :ffi
|
73
|
-
@zfactory = FFIFactory.new(config_.merge(:
|
74
|
-
@mfactory = FFIFactory.new(config_.merge(:
|
62
|
+
@zfactory = FFIFactory.new(config_.merge(has_z_coordinate: true))
|
63
|
+
@mfactory = FFIFactory.new(config_.merge(has_m_coordinate: true))
|
75
64
|
else
|
76
|
-
@zfactory = CAPIFactory.create(config_.merge(:
|
77
|
-
@mfactory = CAPIFactory.create(config_.merge(:
|
65
|
+
@zfactory = CAPIFactory.create(config_.merge(has_z_coordinate: true))
|
66
|
+
@mfactory = CAPIFactory.create(config_.merge(has_m_coordinate: true))
|
78
67
|
end
|
79
68
|
|
80
69
|
wkt_generator_ = opts_[:wkt_generator]
|
@@ -82,7 +71,7 @@ module RGeo
|
|
82
71
|
when ::Hash
|
83
72
|
@wkt_generator = WKRep::WKTGenerator.new(wkt_generator_)
|
84
73
|
else
|
85
|
-
@wkt_generator = WKRep::WKTGenerator.new(:
|
74
|
+
@wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
|
86
75
|
end
|
87
76
|
wkb_generator_ = opts_[:wkb_generator]
|
88
77
|
case wkb_generator_
|
@@ -107,119 +96,115 @@ module RGeo
|
|
107
96
|
end
|
108
97
|
end
|
109
98
|
|
110
|
-
|
111
99
|
# Marshal support
|
112
100
|
|
113
|
-
def marshal_dump
|
101
|
+
def marshal_dump # :nodoc:
|
114
102
|
hash_ = {
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
103
|
+
"srid" => @zfactory.srid,
|
104
|
+
"bufr" => @zfactory.buffer_resolution,
|
105
|
+
"wktg" => @wkt_generator._properties,
|
106
|
+
"wkbg" => @wkb_generator._properties,
|
107
|
+
"wktp" => @wkt_parser._properties,
|
108
|
+
"wkbp" => @wkb_parser._properties,
|
109
|
+
"lmpa" => @zfactory.lenient_multi_polygon_assertions?,
|
110
|
+
"apre" => @zfactory.property(:auto_prepare) == :simple,
|
111
|
+
"nffi" => @zfactory.is_a?(FFIFactory)
|
124
112
|
}
|
125
113
|
proj4_ = @zfactory.proj4
|
126
114
|
coord_sys_ = @zfactory.coord_sys
|
127
|
-
hash_[
|
128
|
-
hash_[
|
115
|
+
hash_["proj4"] = proj4_.marshal_dump if proj4_
|
116
|
+
hash_["cs"] = coord_sys_.to_wkt if coord_sys_
|
129
117
|
hash_
|
130
118
|
end
|
131
119
|
|
132
|
-
def marshal_load(data_)
|
133
|
-
if CoordSys::Proj4.supported? && (proj4_data_ = data_[
|
120
|
+
def marshal_load(data_) # :nodoc:
|
121
|
+
if CoordSys::Proj4.supported? && (proj4_data_ = data_["proj4"])
|
134
122
|
proj4_ = CoordSys::Proj4.allocate
|
135
123
|
proj4_.marshal_load(proj4_data_)
|
136
124
|
else
|
137
125
|
proj4_ = nil
|
138
126
|
end
|
139
|
-
if (coord_sys_data_ = data_[
|
127
|
+
if (coord_sys_data_ = data_["cs"])
|
140
128
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
|
141
129
|
else
|
142
130
|
coord_sys_ = nil
|
143
131
|
end
|
144
132
|
initialize(
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
133
|
+
native_interface: (data_["nffi"] ? :ffi : :capi),
|
134
|
+
has_z_coordinate: data_["hasz"],
|
135
|
+
has_m_coordinate: data_["hasm"],
|
136
|
+
srid: data_["srid"],
|
137
|
+
buffer_resolution: data_["bufr"],
|
138
|
+
wkt_generator: ImplHelper::Utils.symbolize_hash(data_["wktg"]),
|
139
|
+
wkb_generator: ImplHelper::Utils.symbolize_hash(data_["wkbg"]),
|
140
|
+
wkt_parser: ImplHelper::Utils.symbolize_hash(data_["wktp"]),
|
141
|
+
wkb_parser: ImplHelper::Utils.symbolize_hash(data_["wkbp"]),
|
142
|
+
uses_lenient_multi_polygon_assertions: data_["lmpa"],
|
143
|
+
auto_prepare: (data_["apre"] ? :simple : :disabled),
|
144
|
+
proj4: proj4_,
|
145
|
+
coord_sys: coord_sys_
|
158
146
|
)
|
159
147
|
end
|
160
148
|
|
161
|
-
|
162
149
|
# Psych support
|
163
150
|
|
164
|
-
def encode_with(coder_)
|
165
|
-
coder_[
|
166
|
-
coder_[
|
167
|
-
coder_[
|
168
|
-
coder_[
|
169
|
-
coder_[
|
170
|
-
coder_[
|
171
|
-
coder_[
|
172
|
-
coder_[
|
173
|
-
coder_[
|
151
|
+
def encode_with(coder_) # :nodoc:
|
152
|
+
coder_["srid"] = @zfactory.srid
|
153
|
+
coder_["buffer_resolution"] = @zfactory.buffer_resolution
|
154
|
+
coder_["lenient_multi_polygon_assertions"] = @zfactory.lenient_multi_polygon_assertions?
|
155
|
+
coder_["wkt_generator"] = @wkt_generator._properties
|
156
|
+
coder_["wkb_generator"] = @wkb_generator._properties
|
157
|
+
coder_["wkt_parser"] = @wkt_parser._properties
|
158
|
+
coder_["wkb_parser"] = @wkb_parser._properties
|
159
|
+
coder_["auto_prepare"] = @zfactory.property(:auto_prepare).to_s
|
160
|
+
coder_["native_interface"] = @zfactory.is_a?(FFIFactory) ? "ffi" : "capi"
|
174
161
|
if (proj4_ = @zfactory.proj4)
|
175
162
|
str_ = proj4_.original_str || proj4_.canonical_str
|
176
|
-
coder_[
|
163
|
+
coder_["proj4"] = proj4_.radians? ? { "proj4" => str_, "radians" => true } : str_
|
177
164
|
end
|
178
165
|
if (coord_sys_ = @zfactory.coord_sys)
|
179
|
-
coder_[
|
166
|
+
coder_["coord_sys"] = coord_sys_.to_wkt
|
180
167
|
end
|
181
168
|
end
|
182
169
|
|
183
|
-
def init_with(coder_)
|
184
|
-
if (proj4_data_ = coder_[
|
170
|
+
def init_with(coder_) # :nodoc:
|
171
|
+
if (proj4_data_ = coder_["proj4"])
|
185
172
|
if proj4_data_.is_a?(::Hash)
|
186
|
-
proj4_ = CoordSys::Proj4.create(proj4_data_[
|
173
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_["proj4"], radians: proj4_data_["radians"])
|
187
174
|
else
|
188
175
|
proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
|
189
176
|
end
|
190
177
|
else
|
191
178
|
proj4_ = nil
|
192
179
|
end
|
193
|
-
if (coord_sys_data_ = coder_[
|
180
|
+
if (coord_sys_data_ = coder_["cs"])
|
194
181
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
|
195
182
|
else
|
196
183
|
coord_sys_ = nil
|
197
184
|
end
|
198
185
|
initialize(
|
199
|
-
:
|
200
|
-
:
|
201
|
-
:
|
202
|
-
:
|
203
|
-
:
|
204
|
-
:
|
205
|
-
:
|
206
|
-
:
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
186
|
+
native_interface: coder_["native_interface"] == "ffi" ? :ffi : :capi,
|
187
|
+
has_z_coordinate: coder_["has_z_coordinate"],
|
188
|
+
has_m_coordinate: coder_["has_m_coordinate"],
|
189
|
+
srid: coder_["srid"],
|
190
|
+
buffer_resolution: coder_["buffer_resolution"],
|
191
|
+
wkt_generator: ImplHelper::Utils.symbolize_hash(coder_["wkt_generator"]),
|
192
|
+
wkb_generator: ImplHelper::Utils.symbolize_hash(coder_["wkb_generator"]),
|
193
|
+
wkt_parser: ImplHelper::Utils.symbolize_hash(coder_["wkt_parser"]),
|
194
|
+
wkb_parser: ImplHelper::Utils.symbolize_hash(coder_["wkb_parser"]),
|
195
|
+
auto_prepare: coder_["auto_prepare"] == "disabled" ? :disabled : :simple,
|
196
|
+
uses_lenient_multi_polygon_assertions: coder_["lenient_multi_polygon_assertions"],
|
197
|
+
proj4: proj4_,
|
198
|
+
coord_sys: coord_sys_
|
212
199
|
)
|
213
200
|
end
|
214
201
|
|
215
|
-
|
216
202
|
# Returns the SRID of geometries created by this factory.
|
217
203
|
|
218
204
|
def srid
|
219
205
|
@zfactory.srid
|
220
206
|
end
|
221
207
|
|
222
|
-
|
223
208
|
# Returns the resolution used by buffer calculations on geometries
|
224
209
|
# created by this factory
|
225
210
|
|
@@ -227,28 +212,24 @@ module RGeo
|
|
227
212
|
@zfactory.buffer_resolution
|
228
213
|
end
|
229
214
|
|
230
|
-
|
231
215
|
# Returns true if this factory is lenient with MultiPolygon assertions
|
232
216
|
|
233
217
|
def lenient_multi_polygon_assertions?
|
234
218
|
@zfactory.lenient_multi_polygon_assertions?
|
235
219
|
end
|
236
220
|
|
237
|
-
|
238
221
|
# Returns the z-only factory corresponding to this factory.
|
239
222
|
|
240
223
|
def z_factory
|
241
224
|
@zfactory
|
242
225
|
end
|
243
226
|
|
244
|
-
|
245
227
|
# Returns the m-only factory corresponding to this factory.
|
246
228
|
|
247
229
|
def m_factory
|
248
230
|
@mfactory
|
249
231
|
end
|
250
232
|
|
251
|
-
|
252
233
|
# Factory equivalence test.
|
253
234
|
|
254
235
|
def eql?(rhs_)
|
@@ -256,123 +237,105 @@ module RGeo
|
|
256
237
|
end
|
257
238
|
alias_method :==, :eql?
|
258
239
|
|
259
|
-
|
260
240
|
# Standard hash code
|
261
241
|
|
262
242
|
def hash
|
263
243
|
@hash ||= [@zfactory, @mfactory].hash
|
264
244
|
end
|
265
245
|
|
266
|
-
|
267
246
|
# See ::RGeo::Feature::Factory#property
|
268
247
|
|
269
248
|
def property(name_)
|
270
249
|
case name_
|
271
250
|
when :has_z_coordinate, :has_m_coordinate, :is_cartesian
|
272
251
|
true
|
273
|
-
else
|
274
|
-
nil
|
275
252
|
end
|
276
253
|
end
|
277
254
|
|
278
|
-
|
279
255
|
# See ::RGeo::Feature::Factory#parse_wkt
|
280
256
|
|
281
257
|
def parse_wkt(str_)
|
282
258
|
@wkt_parser.parse(str_)
|
283
259
|
end
|
284
260
|
|
285
|
-
|
286
261
|
# See ::RGeo::Feature::Factory#parse_wkb
|
287
262
|
|
288
263
|
def parse_wkb(str_)
|
289
264
|
@wkb_parser.parse(str_)
|
290
265
|
end
|
291
266
|
|
292
|
-
|
293
267
|
# See ::RGeo::Feature::Factory#point
|
294
268
|
|
295
|
-
def point(x_, y_, z_=0, m_=0)
|
269
|
+
def point(x_, y_, z_ = 0, m_ = 0)
|
296
270
|
_create_feature(ZMPointImpl, @zfactory.point(x_, y_, z_), @mfactory.point(x_, y_, m_))
|
297
271
|
end
|
298
272
|
|
299
|
-
|
300
273
|
# See ::RGeo::Feature::Factory#line_string
|
301
274
|
|
302
275
|
def line_string(points_)
|
303
276
|
_create_feature(ZMLineStringImpl, @zfactory.line_string(points_), @mfactory.line_string(points_))
|
304
277
|
end
|
305
278
|
|
306
|
-
|
307
279
|
# See ::RGeo::Feature::Factory#line
|
308
280
|
|
309
281
|
def line(start_, end_)
|
310
282
|
_create_feature(ZMLineImpl, @zfactory.line(start_, end_), @mfactory.line(start_, end_))
|
311
283
|
end
|
312
284
|
|
313
|
-
|
314
285
|
# See ::RGeo::Feature::Factory#linear_ring
|
315
286
|
|
316
287
|
def linear_ring(points_)
|
317
288
|
_create_feature(ZMLinearRingImpl, @zfactory.linear_ring(points_), @mfactory.linear_ring(points_))
|
318
289
|
end
|
319
290
|
|
320
|
-
|
321
291
|
# See ::RGeo::Feature::Factory#polygon
|
322
292
|
|
323
|
-
def polygon(outer_ring_, inner_rings_=nil)
|
293
|
+
def polygon(outer_ring_, inner_rings_ = nil)
|
324
294
|
_create_feature(ZMPolygonImpl, @zfactory.polygon(outer_ring_, inner_rings_), @mfactory.polygon(outer_ring_, inner_rings_))
|
325
295
|
end
|
326
296
|
|
327
|
-
|
328
297
|
# See ::RGeo::Feature::Factory#collection
|
329
298
|
|
330
299
|
def collection(elems_)
|
331
300
|
_create_feature(ZMGeometryCollectionImpl, @zfactory.collection(elems_), @mfactory.collection(elems_))
|
332
301
|
end
|
333
302
|
|
334
|
-
|
335
303
|
# See ::RGeo::Feature::Factory#multi_point
|
336
304
|
|
337
305
|
def multi_point(elems_)
|
338
306
|
_create_feature(ZMMultiPointImpl, @zfactory.multi_point(elems_), @mfactory.multi_point(elems_))
|
339
307
|
end
|
340
308
|
|
341
|
-
|
342
309
|
# See ::RGeo::Feature::Factory#multi_line_string
|
343
310
|
|
344
311
|
def multi_line_string(elems_)
|
345
312
|
_create_feature(ZMMultiLineStringImpl, @zfactory.multi_line_string(elems_), @mfactory.multi_line_string(elems_))
|
346
313
|
end
|
347
314
|
|
348
|
-
|
349
315
|
# See ::RGeo::Feature::Factory#multi_polygon
|
350
316
|
|
351
317
|
def multi_polygon(elems_)
|
352
318
|
_create_feature(ZMMultiPolygonImpl, @zfactory.multi_polygon(elems_), @mfactory.multi_polygon(elems_))
|
353
319
|
end
|
354
320
|
|
355
|
-
|
356
321
|
# See ::RGeo::Feature::Factory#proj4
|
357
322
|
|
358
323
|
def proj4
|
359
324
|
@zfactory.proj4
|
360
325
|
end
|
361
326
|
|
362
|
-
|
363
327
|
# See ::RGeo::Feature::Factory#coord_sys
|
364
328
|
|
365
329
|
def coord_sys
|
366
330
|
@zfactory.coord_sys
|
367
331
|
end
|
368
332
|
|
369
|
-
|
370
333
|
# See ::RGeo::Feature::Factory#override_cast
|
371
334
|
|
372
335
|
def override_cast(original_, ntype_, flags_)
|
373
336
|
return nil unless Geos.supported?
|
374
337
|
keep_subtype_ = flags_[:keep_subtype]
|
375
|
-
#force_new_ = flags_[:force_new]
|
338
|
+
# force_new_ = flags_[:force_new]
|
376
339
|
project_ = flags_[:project]
|
377
340
|
type_ = original_.geometry_type
|
378
341
|
ntype_ = type_ if keep_subtype_ && type_.include?(ntype_)
|
@@ -382,7 +345,6 @@ module RGeo
|
|
382
345
|
# another ZM factory.
|
383
346
|
if original_.factory != self && ntype_ == type_ &&
|
384
347
|
(!project_ || original_.factory.proj4 == @proj4)
|
385
|
-
then
|
386
348
|
zresult_ = original_.z_geometry.dup
|
387
349
|
zresult_._set_factory(@zfactory)
|
388
350
|
mresult_ = original_.m_geometry.dup
|
@@ -393,7 +355,6 @@ module RGeo
|
|
393
355
|
if (original_.factory != self || ntype_ != type_) &&
|
394
356
|
(!project_ || original_.factory.proj4 == @proj4) &&
|
395
357
|
type_.subtype_of?(Feature::LineString) && ntype_.subtype_of?(Feature::LineString)
|
396
|
-
then
|
397
358
|
klass_ = Factory::IMPL_CLASSES[ntype_]
|
398
359
|
zresult_ = klass_._copy_from(@zfactory, original_.z_geometry)
|
399
360
|
mresult_ = klass_._copy_from(@mfactory, original_.m_geometry)
|
@@ -403,52 +364,42 @@ module RGeo
|
|
403
364
|
false
|
404
365
|
end
|
405
366
|
|
406
|
-
|
407
|
-
def _create_feature(klass_, zgeometry_, mgeometry_) # :nodoc:
|
367
|
+
def _create_feature(klass_, zgeometry_, mgeometry_) # :nodoc:
|
408
368
|
klass_ ||= TYPE_KLASSES[zgeometry_.geometry_type] || ZMGeometryImpl
|
409
369
|
zgeometry_ && mgeometry_ ? klass_.new(self, zgeometry_, mgeometry_) : nil
|
410
370
|
end
|
411
371
|
|
412
|
-
|
413
|
-
def _marshal_wkb_generator # :nodoc:
|
372
|
+
def _marshal_wkb_generator # :nodoc:
|
414
373
|
unless defined?(@marshal_wkb_generator)
|
415
374
|
@marshal_wkb_generator = ::RGeo::WKRep::WKBGenerator.new(
|
416
|
-
:
|
375
|
+
type_format: :wkb12)
|
417
376
|
end
|
418
377
|
@marshal_wkb_generator
|
419
378
|
end
|
420
379
|
|
421
|
-
|
422
|
-
def _marshal_wkb_parser # :nodoc:
|
380
|
+
def _marshal_wkb_parser # :nodoc:
|
423
381
|
unless defined?(@marshal_wkb_parser)
|
424
382
|
@marshal_wkb_parser = ::RGeo::WKRep::WKBParser.new(self,
|
425
|
-
:
|
383
|
+
support_wkb12: true)
|
426
384
|
end
|
427
385
|
@marshal_wkb_parser
|
428
386
|
end
|
429
387
|
|
430
|
-
|
431
|
-
def _psych_wkt_generator # :nodoc:
|
388
|
+
def _psych_wkt_generator # :nodoc:
|
432
389
|
unless defined?(@psych_wkt_generator)
|
433
390
|
@psych_wkt_generator = ::RGeo::WKRep::WKTGenerator.new(
|
434
|
-
:
|
391
|
+
tag_format: :wkt12)
|
435
392
|
end
|
436
393
|
@psych_wkt_generator
|
437
394
|
end
|
438
395
|
|
439
|
-
|
440
|
-
def _psych_wkt_parser # :nodoc:
|
396
|
+
def _psych_wkt_parser # :nodoc:
|
441
397
|
unless defined?(@psych_wkt_parser)
|
442
398
|
@psych_wkt_parser = ::RGeo::WKRep::WKTParser.new(self,
|
443
|
-
:
|
399
|
+
support_wkt12: true, support_ewkt: true)
|
444
400
|
end
|
445
401
|
@psych_wkt_parser
|
446
402
|
end
|
447
|
-
|
448
|
-
|
449
403
|
end
|
450
|
-
|
451
|
-
|
452
404
|
end
|
453
|
-
|
454
405
|
end
|