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
data/lib/rgeo/feature/polygon.rb
CHANGED
@@ -5,10 +5,7 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Feature
|
10
|
-
|
11
|
-
|
12
9
|
# == SFS 1.1 Description
|
13
10
|
#
|
14
11
|
# A Polygon is a planar Surface defined by 1 exterior boundary and 0 or
|
@@ -48,11 +45,9 @@ module RGeo
|
|
48
45
|
# class method (or === operator) defined in the Type module.
|
49
46
|
|
50
47
|
module Polygon
|
51
|
-
|
52
48
|
include Surface
|
53
49
|
extend Type
|
54
50
|
|
55
|
-
|
56
51
|
# === SFS 1.1 Description
|
57
52
|
#
|
58
53
|
# Returns the exterior ring of this Polygon.
|
@@ -65,7 +60,6 @@ module RGeo
|
|
65
60
|
raise Error::UnsupportedOperation, "Method Polygon#exterior_ring not defined."
|
66
61
|
end
|
67
62
|
|
68
|
-
|
69
63
|
# === SFS 1.1 Description
|
70
64
|
#
|
71
65
|
# Returns the number of interiorRings in this Polygon.
|
@@ -78,7 +72,6 @@ module RGeo
|
|
78
72
|
raise Error::UnsupportedOperation, "Method Polygon#num_interior_rings not defined."
|
79
73
|
end
|
80
74
|
|
81
|
-
|
82
75
|
# === SFS 1.1 Description
|
83
76
|
#
|
84
77
|
# Returns the Nth interiorRing for this Polygon as a LineString.
|
@@ -89,22 +82,16 @@ module RGeo
|
|
89
82
|
# if the given N is out of range. N is zero-based.
|
90
83
|
# Does not support negative indexes.
|
91
84
|
|
92
|
-
def interior_ring_n(
|
85
|
+
def interior_ring_n(_n_)
|
93
86
|
raise Error::UnsupportedOperation, "Method Polygon#interior_ring_n not defined."
|
94
87
|
end
|
95
88
|
|
96
|
-
|
97
89
|
# Returns the interior rings as a (possibly empty) array of objects
|
98
90
|
# that support the LinearRing interface.
|
99
91
|
|
100
92
|
def interior_rings
|
101
93
|
raise Error::UnsupportedOperation, "Method Polygon#interior_rings not defined."
|
102
94
|
end
|
103
|
-
|
104
|
-
|
105
95
|
end
|
106
|
-
|
107
|
-
|
108
96
|
end
|
109
|
-
|
110
97
|
end
|
data/lib/rgeo/feature/surface.rb
CHANGED
@@ -5,10 +5,7 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Feature
|
10
|
-
|
11
|
-
|
12
9
|
# == SFS 1.1 Description
|
13
10
|
#
|
14
11
|
# A Surface is a 2-dimensional geometric object.
|
@@ -37,11 +34,9 @@ module RGeo
|
|
37
34
|
# Some implementations may support higher dimensional points.
|
38
35
|
|
39
36
|
module Surface
|
40
|
-
|
41
37
|
include Geometry
|
42
38
|
extend Type
|
43
39
|
|
44
|
-
|
45
40
|
# === SFS 1.1 Description
|
46
41
|
#
|
47
42
|
# The area of this Surface, as measured in the spatial reference
|
@@ -55,7 +50,6 @@ module RGeo
|
|
55
50
|
raise Error::UnsupportedOperation, "Method Surface#area not defined."
|
56
51
|
end
|
57
52
|
|
58
|
-
|
59
53
|
# === SFS 1.1 Description
|
60
54
|
#
|
61
55
|
# The mathematical centroid for this Surface as a Point. The result
|
@@ -69,7 +63,6 @@ module RGeo
|
|
69
63
|
raise Error::UnsupportedOperation, "Method Surface#centroid not defined."
|
70
64
|
end
|
71
65
|
|
72
|
-
|
73
66
|
# === SFS 1.1 Description
|
74
67
|
#
|
75
68
|
# A Point guaranteed to be on this Surface.
|
@@ -81,11 +74,6 @@ module RGeo
|
|
81
74
|
def point_on_surface
|
82
75
|
raise Error::UnsupportedOperation, "Method Surface#point_on_surface not defined."
|
83
76
|
end
|
84
|
-
|
85
|
-
|
86
77
|
end
|
87
|
-
|
88
|
-
|
89
78
|
end
|
90
|
-
|
91
79
|
end
|
data/lib/rgeo/feature/types.rb
CHANGED
@@ -5,10 +5,7 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Feature
|
10
|
-
|
11
|
-
|
12
9
|
# All geometry implementations MUST include this submodule.
|
13
10
|
# This serves as a marker that may be used to test an object for
|
14
11
|
# feature-ness.
|
@@ -16,7 +13,6 @@ module RGeo
|
|
16
13
|
module Instance
|
17
14
|
end
|
18
15
|
|
19
|
-
|
20
16
|
# This module provides the API for geometry type objects. Technically
|
21
17
|
# these objects are modules (such as ::RGeo::Feature::Point), but as
|
22
18
|
# objects they respond to the methods documented here.
|
@@ -53,12 +49,9 @@ module RGeo
|
|
53
49
|
# ::RGeo::Feature::Type === object.geometry_type # true
|
54
50
|
|
55
51
|
module Type
|
56
|
-
|
57
|
-
|
58
52
|
# Deprecated alias for RGeo::Feature::Instance
|
59
53
|
Instance = Feature::Instance
|
60
54
|
|
61
|
-
|
62
55
|
# Returns true if the given object is this type or a subtype
|
63
56
|
# thereof, or if it is a feature object whose geometry_type is
|
64
57
|
# this type or a subtype thereof.
|
@@ -67,12 +60,11 @@ module RGeo
|
|
67
60
|
# Therefore, the is_a? method will generally not work.
|
68
61
|
|
69
62
|
def check_type(rhs_)
|
70
|
-
rhs_ = rhs_.geometry_type if rhs_.
|
71
|
-
rhs_.
|
63
|
+
rhs_ = rhs_.geometry_type if rhs_.is_a?(Feature::Instance)
|
64
|
+
rhs_.is_a?(Type) && (rhs_ == self || rhs_.include?(self))
|
72
65
|
end
|
73
66
|
alias_method :===, :check_type
|
74
67
|
|
75
|
-
|
76
68
|
# Returns true if this type is the same type or a subtype of the
|
77
69
|
# given type.
|
78
70
|
|
@@ -80,7 +72,6 @@ module RGeo
|
|
80
72
|
self == type_ || self.include?(type_)
|
81
73
|
end
|
82
74
|
|
83
|
-
|
84
75
|
# Returns the supertype of this type. The supertype of Geometry
|
85
76
|
# is nil.
|
86
77
|
|
@@ -88,42 +79,33 @@ module RGeo
|
|
88
79
|
@supertype
|
89
80
|
end
|
90
81
|
|
91
|
-
|
92
82
|
# Iterates over the known immediate subtypes of this type.
|
93
83
|
|
94
84
|
def each_immediate_subtype(&block_)
|
95
85
|
@subtypes.each(&block_) if defined?(@subtypes) && @subtypes
|
96
86
|
end
|
97
87
|
|
98
|
-
|
99
88
|
# Returns the OpenGIS type name of this type. For example:
|
100
89
|
#
|
101
90
|
# ::RGeo::Feature::Point.type_name # "Point"
|
102
91
|
|
103
92
|
def type_name
|
104
|
-
|
93
|
+
name.sub("RGeo::Feature::", "")
|
105
94
|
end
|
106
95
|
alias_method :to_s, :type_name
|
107
96
|
|
108
|
-
|
109
|
-
def _add_subtype(type_) # :nodoc:
|
97
|
+
def _add_subtype(type_) # :nodoc:
|
110
98
|
(@subtypes ||= []) << type_
|
111
99
|
end
|
112
100
|
|
113
|
-
|
114
|
-
|
115
|
-
supertype_ = type_.included_modules.find{ |m_| m_.kind_of?(self) }
|
101
|
+
def self.extended(type_) # :nodoc:
|
102
|
+
supertype_ = type_.included_modules.find { |m_| m_.is_a?(self) }
|
116
103
|
type_.instance_variable_set(:@supertype, supertype_)
|
117
104
|
supertype_._add_subtype(type_) if supertype_
|
118
105
|
end
|
119
|
-
|
120
|
-
|
121
106
|
end
|
122
107
|
|
123
|
-
|
124
108
|
class << self
|
125
|
-
|
126
|
-
|
127
109
|
# Cast the given object according to the given parameters, if
|
128
110
|
# possible, and return the resulting object. If the requested cast
|
129
111
|
# is not possible, nil is returned.
|
@@ -232,22 +214,20 @@ module RGeo
|
|
232
214
|
elsif type_ == Line
|
233
215
|
nfactory_.line(cast(obj_.start_point, nfactory_, opts_), cast(obj_.end_point, nfactory_, opts_))
|
234
216
|
elsif type_ == LinearRing
|
235
|
-
nfactory_.linear_ring(obj_.points.map{ |p_| cast(p_, nfactory_, opts_) })
|
217
|
+
nfactory_.linear_ring(obj_.points.map { |p_| cast(p_, nfactory_, opts_) })
|
236
218
|
elsif type_ == LineString
|
237
|
-
nfactory_.line_string(obj_.points.map{ |p_| cast(p_, nfactory_, opts_) })
|
219
|
+
nfactory_.line_string(obj_.points.map { |p_| cast(p_, nfactory_, opts_) })
|
238
220
|
elsif type_ == Polygon
|
239
221
|
nfactory_.polygon(cast(obj_.exterior_ring, nfactory_, opts_),
|
240
|
-
obj_.interior_rings.map{ |r_| cast(r_, nfactory_, opts_) })
|
222
|
+
obj_.interior_rings.map { |r_| cast(r_, nfactory_, opts_) })
|
241
223
|
elsif type_ == MultiPoint
|
242
|
-
nfactory_.multi_point(obj_.map{ |g_| cast(g_, nfactory_, opts_) })
|
224
|
+
nfactory_.multi_point(obj_.map { |g_| cast(g_, nfactory_, opts_) })
|
243
225
|
elsif type_ == MultiLineString
|
244
|
-
nfactory_.multi_line_string(obj_.map{ |g_| cast(g_, nfactory_, opts_) })
|
226
|
+
nfactory_.multi_line_string(obj_.map { |g_| cast(g_, nfactory_, opts_) })
|
245
227
|
elsif type_ == MultiPolygon
|
246
|
-
nfactory_.multi_polygon(obj_.map{ |g_| cast(g_, nfactory_, opts_) })
|
228
|
+
nfactory_.multi_polygon(obj_.map { |g_| cast(g_, nfactory_, opts_) })
|
247
229
|
elsif type_ == GeometryCollection
|
248
|
-
nfactory_.collection(obj_.map{ |g_| cast(g_, nfactory_, opts_) })
|
249
|
-
else
|
250
|
-
nil
|
230
|
+
nfactory_.collection(obj_.map { |g_| cast(g_, nfactory_, opts_) })
|
251
231
|
end
|
252
232
|
end
|
253
233
|
else
|
@@ -255,72 +235,50 @@ module RGeo
|
|
255
235
|
if ntype_ == Point && (type_ == MultiPoint || type_ == GeometryCollection) ||
|
256
236
|
(ntype_ == Line || ntype_ == LineString || ntype_ == LinearRing) && (type_ == MultiLineString || type_ == GeometryCollection) ||
|
257
237
|
ntype_ == Polygon && (type_ == MultiPolygon || type_ == GeometryCollection)
|
258
|
-
then
|
259
238
|
if obj_.num_geometries == 1
|
260
239
|
cast(obj_.geometry_n(0), nfactory_, ntype_, opts_)
|
261
|
-
else
|
262
|
-
nil
|
263
240
|
end
|
264
241
|
elsif ntype_ == Point
|
265
242
|
nil
|
266
243
|
elsif ntype_ == Line
|
267
244
|
if type_ == LineString && obj_.num_points == 2
|
268
245
|
nfactory_.line(cast(obj_.point_n(0), nfactory_, opts_), cast(obj_.point_n(1), nfactory_, opts_))
|
269
|
-
else
|
270
|
-
nil
|
271
246
|
end
|
272
247
|
elsif ntype_ == LinearRing
|
273
248
|
if type_ == LineString
|
274
|
-
nfactory_.linear_ring(obj_.points.map{ |p_| cast(p_, nfactory_, opts_) })
|
275
|
-
else
|
276
|
-
nil
|
249
|
+
nfactory_.linear_ring(obj_.points.map { |p_| cast(p_, nfactory_, opts_) })
|
277
250
|
end
|
278
251
|
elsif ntype_ == LineString
|
279
252
|
if type_ == Line || type_ == LinearRing
|
280
|
-
nfactory_.line_string(obj_.points.map{ |p_| cast(p_, nfactory_, opts_) })
|
281
|
-
else
|
282
|
-
nil
|
253
|
+
nfactory_.line_string(obj_.points.map { |p_| cast(p_, nfactory_, opts_) })
|
283
254
|
end
|
284
255
|
elsif ntype_ == MultiPoint
|
285
256
|
if type_ == Point
|
286
257
|
nfactory_.multi_point([cast(obj_, nfactory_, opts_)])
|
287
258
|
elsif type_ == GeometryCollection
|
288
|
-
nfactory_.multi_point(obj_.map{ |
|
289
|
-
else
|
290
|
-
nil
|
259
|
+
nfactory_.multi_point(obj_.map { |_g_| cast(p_, nfactory_, opts_) })
|
291
260
|
end
|
292
261
|
elsif ntype_ == MultiLineString
|
293
262
|
if type_ == Line || type_ == LinearRing || type_ == LineString
|
294
263
|
nfactory_.multi_line_string([cast(obj_, nfactory_, opts_)])
|
295
264
|
elsif type_ == GeometryCollection
|
296
|
-
nfactory_.multi_line_string(obj_.map{ |
|
297
|
-
else
|
298
|
-
nil
|
265
|
+
nfactory_.multi_line_string(obj_.map { |_g_| cast(p_, nfactory_, opts_) })
|
299
266
|
end
|
300
267
|
elsif ntype_ == MultiPolygon
|
301
268
|
if type_ == Polygon
|
302
269
|
nfactory_.multi_polygon([cast(obj_, nfactory_, opts_)])
|
303
270
|
elsif type_ == GeometryCollection
|
304
|
-
nfactory_.multi_polygon(obj_.map{ |
|
305
|
-
else
|
306
|
-
nil
|
271
|
+
nfactory_.multi_polygon(obj_.map { |_g_| cast(p_, nfactory_, opts_) })
|
307
272
|
end
|
308
273
|
elsif ntype_ == GeometryCollection
|
309
274
|
if type_ == MultiPoint || type_ == MultiLineString || type_ == MultiPolygon
|
310
|
-
nfactory_.collection(obj_.map{ |
|
275
|
+
nfactory_.collection(obj_.map { |_g_| cast(p_, nfactory_, opts_) })
|
311
276
|
else
|
312
277
|
nfactory_.collection([cast(obj_, nfactory_, opts_)])
|
313
278
|
end
|
314
|
-
else
|
315
|
-
nil
|
316
279
|
end
|
317
280
|
end
|
318
281
|
end
|
319
|
-
|
320
|
-
|
321
282
|
end
|
322
|
-
|
323
|
-
|
324
283
|
end
|
325
|
-
|
326
284
|
end
|
data/lib/rgeo/geographic.rb
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
|
-
|
10
8
|
# The Geographic implementation actually comprises a suite of
|
11
9
|
# implementations with one common feature: they represent geographic
|
12
10
|
# latitude/longitude coordinates measured in degrees. The "x"
|
@@ -27,19 +25,16 @@ module RGeo
|
|
27
25
|
|
28
26
|
module Geographic
|
29
27
|
end
|
30
|
-
|
31
|
-
|
32
28
|
end
|
33
29
|
|
34
|
-
|
35
30
|
# Implementation files.
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
40
|
-
require
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
45
|
-
require
|
31
|
+
require "rgeo/geographic/factory"
|
32
|
+
require "rgeo/geographic/projected_window"
|
33
|
+
require "rgeo/geographic/interface"
|
34
|
+
require "rgeo/geographic/spherical_math"
|
35
|
+
require "rgeo/geographic/spherical_feature_methods"
|
36
|
+
require "rgeo/geographic/spherical_feature_classes"
|
37
|
+
require "rgeo/geographic/proj4_projector"
|
38
|
+
require "rgeo/geographic/simple_mercator_projector"
|
39
|
+
require "rgeo/geographic/projected_feature_methods"
|
40
|
+
require "rgeo/geographic/projected_feature_classes"
|
@@ -5,20 +5,15 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geographic
|
10
|
-
|
11
|
-
|
12
9
|
# This class implements the various factories for geography features.
|
13
10
|
# See methods of the RGeo::Geographic module for the API for creating
|
14
11
|
# geography factories.
|
15
12
|
|
16
13
|
class Factory
|
17
|
-
|
18
14
|
include Feature::Factory::Instance
|
19
15
|
|
20
|
-
|
21
|
-
def initialize(impl_prefix_, opts_={}) # :nodoc:
|
16
|
+
def initialize(impl_prefix_, opts_ = {}) # :nodoc:
|
22
17
|
@impl_prefix = impl_prefix_
|
23
18
|
@point_class = Geographic.const_get("#{impl_prefix_}PointImpl")
|
24
19
|
@line_string_class = Geographic.const_get("#{impl_prefix_}LineStringImpl")
|
@@ -34,15 +29,19 @@ module RGeo
|
|
34
29
|
@srid = (opts_[:srid] || 4326).to_i
|
35
30
|
@proj4 = opts_[:proj4]
|
36
31
|
if CoordSys::Proj4.supported?
|
37
|
-
if @proj4.
|
32
|
+
if @proj4.is_a?(::String) || @proj4.is_a?(::Hash)
|
38
33
|
@proj4 = CoordSys::Proj4.create(@proj4)
|
39
34
|
end
|
40
35
|
else
|
41
36
|
@proj4 = nil
|
42
37
|
end
|
43
38
|
@coord_sys = opts_[:coord_sys]
|
44
|
-
if @coord_sys.
|
45
|
-
@coord_sys =
|
39
|
+
if @coord_sys.is_a?(::String)
|
40
|
+
@coord_sys = begin
|
41
|
+
CoordSys::CS.create_from_wkt(@coord_sys)
|
42
|
+
rescue
|
43
|
+
nil
|
44
|
+
end
|
46
45
|
end
|
47
46
|
@lenient_assertions = opts_[:uses_lenient_assertions] ? true : false
|
48
47
|
@buffer_resolution = opts_[:buffer_resolution].to_i
|
@@ -53,7 +52,7 @@ module RGeo
|
|
53
52
|
when ::Hash
|
54
53
|
@wkt_generator = WKRep::WKTGenerator.new(wkt_generator_)
|
55
54
|
else
|
56
|
-
@wkt_generator = WKRep::WKTGenerator.new(:
|
55
|
+
@wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
|
57
56
|
end
|
58
57
|
wkb_generator_ = opts_[:wkb_generator]
|
59
58
|
case wkb_generator_
|
@@ -79,12 +78,10 @@ module RGeo
|
|
79
78
|
@projector = nil
|
80
79
|
end
|
81
80
|
|
82
|
-
|
83
|
-
def _set_projector(projector_) # :nodoc:
|
81
|
+
def _set_projector(projector_) # :nodoc:
|
84
82
|
@projector = projector_
|
85
83
|
end
|
86
84
|
|
87
|
-
|
88
85
|
# Equivalence test.
|
89
86
|
|
90
87
|
def eql?(rhs_)
|
@@ -96,65 +93,67 @@ module RGeo
|
|
96
93
|
end
|
97
94
|
alias_method :==, :eql?
|
98
95
|
|
99
|
-
|
100
96
|
# Standard hash code
|
101
97
|
|
102
98
|
def hash
|
103
99
|
@hash ||= [@impl_prefix, @support_z, @support_m, @proj4].hash
|
104
100
|
end
|
105
101
|
|
106
|
-
|
107
102
|
# Marshal support
|
108
103
|
|
109
|
-
def marshal_dump
|
104
|
+
def marshal_dump # :nodoc:
|
110
105
|
hash_ = {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
106
|
+
"pref" => @impl_prefix,
|
107
|
+
"hasz" => @support_z,
|
108
|
+
"hasm" => @support_m,
|
109
|
+
"srid" => @srid,
|
110
|
+
"wktg" => @wkt_generator._properties,
|
111
|
+
"wkbg" => @wkb_generator._properties,
|
112
|
+
"wktp" => @wkt_parser._properties,
|
113
|
+
"wkbp" => @wkb_parser._properties,
|
114
|
+
"lena" => @lenient_assertions,
|
115
|
+
"bufr" => @buffer_resolution
|
121
116
|
}
|
122
|
-
hash_[
|
123
|
-
hash_[
|
117
|
+
hash_["proj4"] = @proj4.marshal_dump if @proj4
|
118
|
+
hash_["cs"] = @coord_sys.to_wkt if @coord_sys
|
124
119
|
if @projector
|
125
|
-
hash_[
|
126
|
-
hash_[
|
120
|
+
hash_["prjc"] = @projector.class.name.sub(/.*::/, "")
|
121
|
+
hash_["prjf"] = @projector.projection_factory
|
127
122
|
end
|
128
123
|
hash_
|
129
124
|
end
|
130
125
|
|
131
|
-
def marshal_load(data_)
|
132
|
-
if CoordSys::Proj4.supported? && (proj4_data_ = data_[
|
126
|
+
def marshal_load(data_) # :nodoc:
|
127
|
+
if CoordSys::Proj4.supported? && (proj4_data_ = data_["proj4"])
|
133
128
|
proj4_ = CoordSys::Proj4.allocate
|
134
129
|
proj4_.marshal_load(proj4_data_)
|
135
130
|
else
|
136
131
|
proj4_ = nil
|
137
132
|
end
|
138
|
-
if (coord_sys_data_ = data_[
|
133
|
+
if (coord_sys_data_ = data_["cs"])
|
139
134
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
|
140
135
|
else
|
141
136
|
coord_sys_ = nil
|
142
137
|
end
|
143
|
-
initialize(data_[
|
144
|
-
:
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
155
|
-
|
156
|
-
if (projklass_ = data_[
|
157
|
-
klass_ =
|
138
|
+
initialize(data_["pref"],
|
139
|
+
has_z_coordinate: data_["hasz"],
|
140
|
+
has_m_coordinate: data_["hasm"],
|
141
|
+
srid: data_["srid"],
|
142
|
+
wkt_generator: ImplHelper::Utils.symbolize_hash(data_["wktg"]),
|
143
|
+
wkb_generator: ImplHelper::Utils.symbolize_hash(data_["wkbg"]),
|
144
|
+
wkt_parser: ImplHelper::Utils.symbolize_hash(data_["wktp"]),
|
145
|
+
wkb_parser: ImplHelper::Utils.symbolize_hash(data_["wkbp"]),
|
146
|
+
uses_lenient_assertions: data_["lena"],
|
147
|
+
buffer_resolution: data_["bufr"],
|
148
|
+
proj4: proj4_,
|
149
|
+
coord_sys: coord_sys_
|
150
|
+
)
|
151
|
+
if (projklass_ = data_["prjc"]) && (projfactory_ = data_["prjf"])
|
152
|
+
klass_ = begin
|
153
|
+
::RGeo::Geographic.const_get(projklass_)
|
154
|
+
rescue
|
155
|
+
nil
|
156
|
+
end
|
158
157
|
if klass_
|
159
158
|
projector_ = klass_.allocate
|
160
159
|
projector_._set_factories(self, projfactory_)
|
@@ -163,61 +162,64 @@ module RGeo
|
|
163
162
|
end
|
164
163
|
end
|
165
164
|
|
166
|
-
|
167
165
|
# Psych support
|
168
166
|
|
169
|
-
def encode_with(coder_)
|
170
|
-
coder_[
|
171
|
-
coder_[
|
172
|
-
coder_[
|
173
|
-
coder_[
|
174
|
-
coder_[
|
175
|
-
coder_[
|
176
|
-
coder_[
|
177
|
-
coder_[
|
178
|
-
coder_[
|
179
|
-
coder_[
|
167
|
+
def encode_with(coder_) # :nodoc:
|
168
|
+
coder_["impl_prefix"] = @impl_prefix
|
169
|
+
coder_["has_z_coordinate"] = @support_z
|
170
|
+
coder_["has_m_coordinate"] = @support_m
|
171
|
+
coder_["srid"] = @srid
|
172
|
+
coder_["wkt_generator"] = @wkt_generator._properties
|
173
|
+
coder_["wkb_generator"] = @wkb_generator._properties
|
174
|
+
coder_["wkt_parser"] = @wkt_parser._properties
|
175
|
+
coder_["wkb_parser"] = @wkb_parser._properties
|
176
|
+
coder_["lenient_assertions"] = @lenient_assertions
|
177
|
+
coder_["buffer_resolution"] = @buffer_resolution
|
180
178
|
if @proj4
|
181
179
|
str_ = @proj4.original_str || @proj4.canonical_str
|
182
|
-
coder_[
|
180
|
+
coder_["proj4"] = @proj4.radians? ? { "proj4" => str_, "radians" => true } : str_
|
183
181
|
end
|
184
|
-
coder_[
|
182
|
+
coder_["coord_sys"] = @coord_sys.to_wkt if @coord_sys
|
185
183
|
if @projector
|
186
|
-
coder_[
|
187
|
-
coder_[
|
184
|
+
coder_["projector_class"] = @projector.class.name.sub(/.*::/, "")
|
185
|
+
coder_["projection_factory"] = @projector.projection_factory
|
188
186
|
end
|
189
187
|
end
|
190
188
|
|
191
|
-
def init_with(coder_)
|
192
|
-
if (proj4_data_ = coder_[
|
189
|
+
def init_with(coder_) # :nodoc:
|
190
|
+
if (proj4_data_ = coder_["proj4"])
|
193
191
|
if proj4_data_.is_a?(::Hash)
|
194
|
-
proj4_ = CoordSys::Proj4.create(proj4_data_[
|
192
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_["proj4"], radians: proj4_data_["radians"])
|
195
193
|
else
|
196
194
|
proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
|
197
195
|
end
|
198
196
|
else
|
199
197
|
proj4_ = nil
|
200
198
|
end
|
201
|
-
if (coord_sys_data_ = coder_[
|
199
|
+
if (coord_sys_data_ = coder_["cs"])
|
202
200
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
|
203
201
|
else
|
204
202
|
coord_sys_ = nil
|
205
203
|
end
|
206
|
-
initialize(coder_[
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
213
|
-
:
|
214
|
-
:
|
215
|
-
:
|
216
|
-
:
|
217
|
-
:
|
218
|
-
|
219
|
-
if (projklass_ = coder_[
|
220
|
-
klass_ =
|
204
|
+
initialize(coder_["impl_prefix"],
|
205
|
+
has_z_coordinate: coder_["has_z_coordinate"],
|
206
|
+
has_m_coordinate: coder_["has_m_coordinate"],
|
207
|
+
srid: coder_["srid"],
|
208
|
+
wkt_generator: ImplHelper::Utils.symbolize_hash(coder_["wkt_generator"]),
|
209
|
+
wkb_generator: ImplHelper::Utils.symbolize_hash(coder_["wkb_generator"]),
|
210
|
+
wkt_parser: ImplHelper::Utils.symbolize_hash(coder_["wkt_parser"]),
|
211
|
+
wkb_parser: ImplHelper::Utils.symbolize_hash(coder_["wkb_parser"]),
|
212
|
+
uses_lenient_assertions: coder_["lenient_assertions"],
|
213
|
+
buffer_resolution: coder_["buffer_resolution"],
|
214
|
+
proj4: proj4_,
|
215
|
+
coord_sys: coord_sys_
|
216
|
+
)
|
217
|
+
if (projklass_ = coder_["projector_class"]) && (projfactory_ = coder_["projection_factory"])
|
218
|
+
klass_ = begin
|
219
|
+
::RGeo::Geographic.const_get(projklass_)
|
220
|
+
rescue
|
221
|
+
nil
|
222
|
+
end
|
221
223
|
if klass_
|
222
224
|
projector_ = klass_.allocate
|
223
225
|
projector_._set_factories(self, projfactory_)
|
@@ -226,13 +228,9 @@ module RGeo
|
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
229
|
-
|
230
231
|
# Returns the srid reported by this factory.
|
231
232
|
|
232
|
-
|
233
|
-
@srid
|
234
|
-
end
|
235
|
-
|
233
|
+
attr_reader :srid
|
236
234
|
|
237
235
|
# Returns true if this factory supports a projection.
|
238
236
|
|
@@ -240,7 +238,6 @@ module RGeo
|
|
240
238
|
!@projector.nil?
|
241
239
|
end
|
242
240
|
|
243
|
-
|
244
241
|
# Returns the factory for the projected coordinate space,
|
245
242
|
# or nil if this factory does not support a projection.
|
246
243
|
|
@@ -248,7 +245,6 @@ module RGeo
|
|
248
245
|
@projector ? @projector.projection_factory : nil
|
249
246
|
end
|
250
247
|
|
251
|
-
|
252
248
|
# Projects the given geometry into the projected coordinate space,
|
253
249
|
# and returns the projected geometry.
|
254
250
|
# Returns nil if this factory does not support a projection.
|
@@ -258,12 +254,11 @@ module RGeo
|
|
258
254
|
def project(geometry_)
|
259
255
|
return nil unless @projector && geometry_
|
260
256
|
unless geometry_.factory == self
|
261
|
-
raise Error::InvalidGeometry,
|
257
|
+
raise Error::InvalidGeometry, "Wrong geometry type"
|
262
258
|
end
|
263
259
|
@projector.project(geometry_)
|
264
260
|
end
|
265
261
|
|
266
|
-
|
267
262
|
# Reverse-projects the given geometry from the projected coordinate
|
268
263
|
# space into lat-long space.
|
269
264
|
# Raises Error::InvalidGeometry if the given geometry is not of
|
@@ -272,12 +267,11 @@ module RGeo
|
|
272
267
|
def unproject(geometry_)
|
273
268
|
return nil unless geometry_
|
274
269
|
unless @projector && @projector.projection_factory == geometry_.factory
|
275
|
-
raise Error::InvalidGeometry,
|
270
|
+
raise Error::InvalidGeometry, "You can unproject only features that are in the projected coordinate space."
|
276
271
|
end
|
277
272
|
@projector.unproject(geometry_)
|
278
273
|
end
|
279
274
|
|
280
|
-
|
281
275
|
# Returns true if this factory supports a projection and the
|
282
276
|
# projection wraps its x (easting) direction. For example, a
|
283
277
|
# Mercator projection wraps, but a local projection that is valid
|
@@ -289,7 +283,6 @@ module RGeo
|
|
289
283
|
@projector ? @projector.wraps? : nil
|
290
284
|
end
|
291
285
|
|
292
|
-
|
293
286
|
# Returns a ProjectedWindow specifying the limits of the domain of
|
294
287
|
# the projection space.
|
295
288
|
# Returns nil if this factory does not support a projection, or the
|
@@ -301,12 +294,9 @@ module RGeo
|
|
301
294
|
@projection_limits_window = @projector.limits_window
|
302
295
|
end
|
303
296
|
@projection_limits_window
|
304
|
-
else
|
305
|
-
nil
|
306
297
|
end
|
307
298
|
end
|
308
299
|
|
309
|
-
|
310
300
|
# See ::RGeo::Feature::Factory#property
|
311
301
|
|
312
302
|
def property(name_)
|
@@ -321,151 +311,140 @@ module RGeo
|
|
321
311
|
@buffer_resolution
|
322
312
|
when :is_geographic
|
323
313
|
true
|
324
|
-
else
|
325
|
-
nil
|
326
314
|
end
|
327
315
|
end
|
328
316
|
|
329
|
-
|
330
317
|
# See ::RGeo::Feature::Factory#parse_wkt
|
331
318
|
|
332
319
|
def parse_wkt(str_)
|
333
320
|
@wkt_parser.parse(str_)
|
334
321
|
end
|
335
322
|
|
336
|
-
|
337
323
|
# See ::RGeo::Feature::Factory#parse_wkb
|
338
324
|
|
339
325
|
def parse_wkb(str_)
|
340
326
|
@wkb_parser.parse(str_)
|
341
327
|
end
|
342
328
|
|
343
|
-
|
344
329
|
# See ::RGeo::Feature::Factory#point
|
345
330
|
|
346
331
|
def point(x_, y_, *extra_)
|
347
|
-
@point_class.new(self, x_, y_, *extra_)
|
332
|
+
@point_class.new(self, x_, y_, *extra_)
|
333
|
+
rescue
|
334
|
+
nil
|
348
335
|
end
|
349
336
|
|
350
|
-
|
351
337
|
# See ::RGeo::Feature::Factory#line_string
|
352
338
|
|
353
339
|
def line_string(points_)
|
354
|
-
@line_string_class.new(self, points_)
|
340
|
+
@line_string_class.new(self, points_)
|
341
|
+
rescue
|
342
|
+
nil
|
355
343
|
end
|
356
344
|
|
357
|
-
|
358
345
|
# See ::RGeo::Feature::Factory#line
|
359
346
|
|
360
347
|
def line(start_, end_)
|
361
|
-
@line_class.new(self, start_, end_)
|
348
|
+
@line_class.new(self, start_, end_)
|
349
|
+
rescue
|
350
|
+
nil
|
362
351
|
end
|
363
352
|
|
364
|
-
|
365
353
|
# See ::RGeo::Feature::Factory#linear_ring
|
366
354
|
|
367
355
|
def linear_ring(points_)
|
368
|
-
@linear_ring_class.new(self, points_)
|
356
|
+
@linear_ring_class.new(self, points_)
|
357
|
+
rescue
|
358
|
+
nil
|
369
359
|
end
|
370
360
|
|
371
|
-
|
372
361
|
# See ::RGeo::Feature::Factory#polygon
|
373
362
|
|
374
|
-
def polygon(outer_ring_, inner_rings_=nil)
|
375
|
-
@polygon_class.new(self, outer_ring_, inner_rings_)
|
363
|
+
def polygon(outer_ring_, inner_rings_ = nil)
|
364
|
+
@polygon_class.new(self, outer_ring_, inner_rings_)
|
365
|
+
rescue
|
366
|
+
nil
|
376
367
|
end
|
377
368
|
|
378
|
-
|
379
369
|
# See ::RGeo::Feature::Factory#collection
|
380
370
|
|
381
371
|
def collection(elems_)
|
382
|
-
@geometry_collection_class.new(self, elems_)
|
372
|
+
@geometry_collection_class.new(self, elems_)
|
373
|
+
rescue
|
374
|
+
nil
|
383
375
|
end
|
384
376
|
|
385
|
-
|
386
377
|
# See ::RGeo::Feature::Factory#multi_point
|
387
378
|
|
388
379
|
def multi_point(elems_)
|
389
|
-
@multi_point_class.new(self, elems_)
|
380
|
+
@multi_point_class.new(self, elems_)
|
381
|
+
rescue
|
382
|
+
nil
|
390
383
|
end
|
391
384
|
|
392
|
-
|
393
385
|
# See ::RGeo::Feature::Factory#multi_line_string
|
394
386
|
|
395
387
|
def multi_line_string(elems_)
|
396
|
-
@multi_line_string_class.new(self, elems_)
|
388
|
+
@multi_line_string_class.new(self, elems_)
|
389
|
+
rescue
|
390
|
+
nil
|
397
391
|
end
|
398
392
|
|
399
|
-
|
400
393
|
# See ::RGeo::Feature::Factory#multi_polygon
|
401
394
|
|
402
395
|
def multi_polygon(elems_)
|
403
|
-
@multi_polygon_class.new(self, elems_)
|
396
|
+
@multi_polygon_class.new(self, elems_)
|
397
|
+
rescue
|
398
|
+
nil
|
404
399
|
end
|
405
400
|
|
406
|
-
|
407
401
|
# See ::RGeo::Feature::Factory#proj4
|
408
402
|
|
409
|
-
|
410
|
-
@proj4
|
411
|
-
end
|
412
|
-
|
403
|
+
attr_reader :proj4
|
413
404
|
|
414
405
|
# See ::RGeo::Feature::Factory#coord_sys
|
415
406
|
|
416
|
-
|
417
|
-
@coord_sys
|
418
|
-
end
|
419
|
-
|
407
|
+
attr_reader :coord_sys
|
420
408
|
|
421
409
|
def _generate_wkt(obj_) # :nodoc:
|
422
410
|
@wkt_generator.generate(obj_)
|
423
411
|
end
|
424
412
|
|
425
|
-
|
426
413
|
def _generate_wkb(obj_) # :nodoc:
|
427
414
|
@wkb_generator.generate(obj_)
|
428
415
|
end
|
429
416
|
|
430
|
-
|
431
|
-
def _marshal_wkb_generator # :nodoc:
|
417
|
+
def _marshal_wkb_generator # :nodoc:
|
432
418
|
unless defined?(@marshal_wkb_generator)
|
433
419
|
@marshal_wkb_generator = ::RGeo::WKRep::WKBGenerator.new(
|
434
|
-
:
|
420
|
+
type_format: :wkb12)
|
435
421
|
end
|
436
422
|
@marshal_wkb_generator
|
437
423
|
end
|
438
424
|
|
439
|
-
|
440
|
-
def _marshal_wkb_parser # :nodoc:
|
425
|
+
def _marshal_wkb_parser # :nodoc:
|
441
426
|
unless defined?(@marshal_wkb_parser)
|
442
427
|
@marshal_wkb_parser = ::RGeo::WKRep::WKBParser.new(self,
|
443
|
-
:
|
428
|
+
support_wkb12: true)
|
444
429
|
end
|
445
430
|
@marshal_wkb_parser
|
446
431
|
end
|
447
432
|
|
448
|
-
|
449
|
-
def _psych_wkt_generator # :nodoc:
|
433
|
+
def _psych_wkt_generator # :nodoc:
|
450
434
|
unless defined?(@psych_wkt_generator)
|
451
435
|
@psych_wkt_generator = ::RGeo::WKRep::WKTGenerator.new(
|
452
|
-
:
|
436
|
+
tag_format: :wkt12)
|
453
437
|
end
|
454
438
|
@psych_wkt_generator
|
455
439
|
end
|
456
440
|
|
457
|
-
|
458
|
-
def _psych_wkt_parser # :nodoc:
|
441
|
+
def _psych_wkt_parser # :nodoc:
|
459
442
|
unless defined?(@psych_wkt_parser)
|
460
443
|
@psych_wkt_parser = ::RGeo::WKRep::WKTParser.new(self,
|
461
|
-
:
|
444
|
+
support_wkt12: true, support_ewkt: true)
|
462
445
|
end
|
463
446
|
@psych_wkt_parser
|
464
447
|
end
|
465
|
-
|
466
|
-
|
467
448
|
end
|
468
|
-
|
469
449
|
end
|
470
|
-
|
471
450
|
end
|