rgeo-dschee 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +29 -0
  3. data/ext/geos_c_impl/coordinates.c +65 -0
  4. data/ext/geos_c_impl/coordinates.h +2 -0
  5. data/ext/geos_c_impl/extconf.rb +43 -0
  6. data/ext/geos_c_impl/factory.c +995 -0
  7. data/ext/geos_c_impl/factory.h +238 -0
  8. data/ext/geos_c_impl/geometry.c +1093 -0
  9. data/ext/geos_c_impl/geometry.h +23 -0
  10. data/ext/geos_c_impl/geometry_collection.c +757 -0
  11. data/ext/geos_c_impl/geometry_collection.h +46 -0
  12. data/ext/geos_c_impl/line_string.c +675 -0
  13. data/ext/geos_c_impl/line_string.h +32 -0
  14. data/ext/geos_c_impl/main.c +40 -0
  15. data/ext/geos_c_impl/point.c +236 -0
  16. data/ext/geos_c_impl/point.h +30 -0
  17. data/ext/geos_c_impl/polygon.c +359 -0
  18. data/ext/geos_c_impl/polygon.h +43 -0
  19. data/ext/geos_c_impl/preface.h +38 -0
  20. data/ext/proj4_c_impl/extconf.rb +62 -0
  21. data/ext/proj4_c_impl/main.c +315 -0
  22. data/lib/rgeo.rb +89 -0
  23. data/lib/rgeo/cartesian.rb +25 -0
  24. data/lib/rgeo/cartesian/analysis.rb +77 -0
  25. data/lib/rgeo/cartesian/bounding_box.rb +398 -0
  26. data/lib/rgeo/cartesian/calculations.rb +113 -0
  27. data/lib/rgeo/cartesian/factory.rb +347 -0
  28. data/lib/rgeo/cartesian/feature_classes.rb +100 -0
  29. data/lib/rgeo/cartesian/feature_methods.rb +88 -0
  30. data/lib/rgeo/cartesian/interface.rb +135 -0
  31. data/lib/rgeo/coord_sys.rb +43 -0
  32. data/lib/rgeo/coord_sys/cs/entities.rb +1315 -0
  33. data/lib/rgeo/coord_sys/cs/factories.rb +148 -0
  34. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +272 -0
  35. data/lib/rgeo/coord_sys/proj4.rb +293 -0
  36. data/lib/rgeo/coord_sys/srs_database/interface.rb +115 -0
  37. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +140 -0
  38. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +62 -0
  39. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +63 -0
  40. data/lib/rgeo/error.rb +27 -0
  41. data/lib/rgeo/feature.rb +54 -0
  42. data/lib/rgeo/feature/curve.rb +111 -0
  43. data/lib/rgeo/feature/factory.rb +278 -0
  44. data/lib/rgeo/feature/factory_generator.rb +96 -0
  45. data/lib/rgeo/feature/geometry.rb +624 -0
  46. data/lib/rgeo/feature/geometry_collection.rb +95 -0
  47. data/lib/rgeo/feature/line.rb +26 -0
  48. data/lib/rgeo/feature/line_string.rb +60 -0
  49. data/lib/rgeo/feature/linear_ring.rb +26 -0
  50. data/lib/rgeo/feature/mixins.rb +143 -0
  51. data/lib/rgeo/feature/multi_curve.rb +71 -0
  52. data/lib/rgeo/feature/multi_line_string.rb +26 -0
  53. data/lib/rgeo/feature/multi_point.rb +33 -0
  54. data/lib/rgeo/feature/multi_polygon.rb +57 -0
  55. data/lib/rgeo/feature/multi_surface.rb +73 -0
  56. data/lib/rgeo/feature/point.rb +84 -0
  57. data/lib/rgeo/feature/polygon.rb +97 -0
  58. data/lib/rgeo/feature/surface.rb +79 -0
  59. data/lib/rgeo/feature/types.rb +284 -0
  60. data/lib/rgeo/geographic.rb +40 -0
  61. data/lib/rgeo/geographic/factory.rb +450 -0
  62. data/lib/rgeo/geographic/interface.rb +489 -0
  63. data/lib/rgeo/geographic/proj4_projector.rb +58 -0
  64. data/lib/rgeo/geographic/projected_feature_classes.rb +107 -0
  65. data/lib/rgeo/geographic/projected_feature_methods.rb +212 -0
  66. data/lib/rgeo/geographic/projected_window.rb +383 -0
  67. data/lib/rgeo/geographic/simple_mercator_projector.rb +110 -0
  68. data/lib/rgeo/geographic/spherical_feature_classes.rb +100 -0
  69. data/lib/rgeo/geographic/spherical_feature_methods.rb +134 -0
  70. data/lib/rgeo/geographic/spherical_math.rb +188 -0
  71. data/lib/rgeo/geos.rb +89 -0
  72. data/lib/rgeo/geos/capi_factory.rb +470 -0
  73. data/lib/rgeo/geos/capi_feature_classes.rb +129 -0
  74. data/lib/rgeo/geos/ffi_factory.rb +592 -0
  75. data/lib/rgeo/geos/ffi_feature_classes.rb +83 -0
  76. data/lib/rgeo/geos/ffi_feature_methods.rb +574 -0
  77. data/lib/rgeo/geos/interface.rb +202 -0
  78. data/lib/rgeo/geos/utils.rb +74 -0
  79. data/lib/rgeo/geos/zm_factory.rb +405 -0
  80. data/lib/rgeo/geos/zm_feature_classes.rb +80 -0
  81. data/lib/rgeo/geos/zm_feature_methods.rb +344 -0
  82. data/lib/rgeo/impl_helper.rb +19 -0
  83. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +185 -0
  84. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +61 -0
  85. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +146 -0
  86. data/lib/rgeo/impl_helper/basic_point_methods.rb +104 -0
  87. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +87 -0
  88. data/lib/rgeo/impl_helper/math.rb +14 -0
  89. data/lib/rgeo/impl_helper/utils.rb +29 -0
  90. data/lib/rgeo/version.rb +3 -0
  91. data/lib/rgeo/wkrep.rb +37 -0
  92. data/lib/rgeo/wkrep/wkb_generator.rb +201 -0
  93. data/lib/rgeo/wkrep/wkb_parser.rb +251 -0
  94. data/lib/rgeo/wkrep/wkt_generator.rb +207 -0
  95. data/lib/rgeo/wkrep/wkt_parser.rb +415 -0
  96. data/lib/rgeo/yaml.rb +23 -0
  97. data/test/cartesian_analysis_test.rb +65 -0
  98. data/test/cartesian_bbox_test.rb +123 -0
  99. data/test/common/factory_tests.rb +78 -0
  100. data/test/common/geometry_collection_tests.rb +237 -0
  101. data/test/common/line_string_tests.rb +330 -0
  102. data/test/common/multi_line_string_tests.rb +182 -0
  103. data/test/common/multi_point_tests.rb +200 -0
  104. data/test/common/multi_polygon_tests.rb +191 -0
  105. data/test/common/point_tests.rb +370 -0
  106. data/test/common/polygon_tests.rb +261 -0
  107. data/test/coord_sys/ogc_cs_test.rb +342 -0
  108. data/test/coord_sys/proj4_srs_data_test.rb +41 -0
  109. data/test/coord_sys/proj4_test.rb +150 -0
  110. data/test/coord_sys/sr_org_test.rb +32 -0
  111. data/test/coord_sys/url_reader_test.rb +42 -0
  112. data/test/geos_capi/factory_test.rb +31 -0
  113. data/test/geos_capi/geometry_collection_test.rb +24 -0
  114. data/test/geos_capi/line_string_test.rb +24 -0
  115. data/test/geos_capi/misc_test.rb +116 -0
  116. data/test/geos_capi/multi_line_string_test.rb +24 -0
  117. data/test/geos_capi/multi_point_test.rb +24 -0
  118. data/test/geos_capi/multi_polygon_test.rb +39 -0
  119. data/test/geos_capi/parsing_unparsing_test.rb +40 -0
  120. data/test/geos_capi/point_test.rb +72 -0
  121. data/test/geos_capi/polygon_test.rb +154 -0
  122. data/test/geos_capi/zmfactory_test.rb +57 -0
  123. data/test/geos_ffi/factory_test.rb +31 -0
  124. data/test/geos_ffi/geometry_collection_test.rb +24 -0
  125. data/test/geos_ffi/line_string_test.rb +24 -0
  126. data/test/geos_ffi/misc_test.rb +63 -0
  127. data/test/geos_ffi/multi_line_string_test.rb +24 -0
  128. data/test/geos_ffi/multi_point_test.rb +24 -0
  129. data/test/geos_ffi/multi_polygon_test.rb +33 -0
  130. data/test/geos_ffi/parsing_unparsing_test.rb +41 -0
  131. data/test/geos_ffi/point_test.rb +77 -0
  132. data/test/geos_ffi/polygon_test.rb +46 -0
  133. data/test/geos_ffi/zmfactory_test.rb +58 -0
  134. data/test/mixins_test.rb +141 -0
  135. data/test/oneoff_test.rb +26 -0
  136. data/test/projected_geographic/factory_test.rb +25 -0
  137. data/test/projected_geographic/geometry_collection_test.rb +24 -0
  138. data/test/projected_geographic/line_string_test.rb +24 -0
  139. data/test/projected_geographic/multi_line_string_test.rb +26 -0
  140. data/test/projected_geographic/multi_point_test.rb +30 -0
  141. data/test/projected_geographic/multi_polygon_test.rb +25 -0
  142. data/test/projected_geographic/point_test.rb +51 -0
  143. data/test/projected_geographic/polygon_test.rb +24 -0
  144. data/test/simple_cartesian/calculations_test.rb +99 -0
  145. data/test/simple_cartesian/factory_test.rb +27 -0
  146. data/test/simple_cartesian/geometry_collection_test.rb +30 -0
  147. data/test/simple_cartesian/line_string_test.rb +31 -0
  148. data/test/simple_cartesian/multi_line_string_test.rb +28 -0
  149. data/test/simple_cartesian/multi_point_test.rb +31 -0
  150. data/test/simple_cartesian/multi_polygon_test.rb +31 -0
  151. data/test/simple_cartesian/point_test.rb +50 -0
  152. data/test/simple_cartesian/polygon_test.rb +28 -0
  153. data/test/simple_mercator/factory_test.rb +25 -0
  154. data/test/simple_mercator/geometry_collection_test.rb +24 -0
  155. data/test/simple_mercator/line_string_test.rb +24 -0
  156. data/test/simple_mercator/multi_line_string_test.rb +26 -0
  157. data/test/simple_mercator/multi_point_test.rb +29 -0
  158. data/test/simple_mercator/multi_polygon_test.rb +25 -0
  159. data/test/simple_mercator/point_test.rb +55 -0
  160. data/test/simple_mercator/polygon_test.rb +24 -0
  161. data/test/simple_mercator/window_test.rb +173 -0
  162. data/test/spherical_geographic/calculations_test.rb +167 -0
  163. data/test/spherical_geographic/factory_test.rb +27 -0
  164. data/test/spherical_geographic/geometry_collection_test.rb +31 -0
  165. data/test/spherical_geographic/line_string_test.rb +31 -0
  166. data/test/spherical_geographic/multi_line_string_test.rb +29 -0
  167. data/test/spherical_geographic/multi_point_test.rb +31 -0
  168. data/test/spherical_geographic/multi_polygon_test.rb +31 -0
  169. data/test/spherical_geographic/point_test.rb +78 -0
  170. data/test/spherical_geographic/polygon_test.rb +28 -0
  171. data/test/types_test.rb +42 -0
  172. data/test/wkrep/wkb_generator_test.rb +185 -0
  173. data/test/wkrep/wkb_parser_test.rb +293 -0
  174. data/test/wkrep/wkt_generator_test.rb +294 -0
  175. data/test/wkrep/wkt_parser_test.rb +412 -0
  176. metadata +386 -0
@@ -0,0 +1,113 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Core calculations in the plane
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+
7
+ module RGeo
8
+ module Cartesian
9
+ # Represents a line segment in the plane.
10
+
11
+ class Segment # :nodoc:
12
+ def initialize(start_, end_)
13
+ @s = start_
14
+ @e = end_
15
+ @sx = @s.x
16
+ @sy = @s.y
17
+ @ex = @e.x
18
+ @ey = @e.y
19
+ @dx = @ex - @sx
20
+ @dy = @ey - @sy
21
+ @lensq = @dx * @dx + @dy * @dy
22
+ end
23
+
24
+ attr_reader :s
25
+ attr_reader :e
26
+ attr_reader :dx
27
+ attr_reader :dy
28
+
29
+ def to_s
30
+ "#{@s} - #{@e}"
31
+ end
32
+
33
+ def eql?(rhs_)
34
+ rhs_.is_a?(Segment) && @s == rhs_.s && @e == rhs_.e
35
+ end
36
+ alias_method :==, :eql?
37
+
38
+ def degenerate?
39
+ @lensq == 0
40
+ end
41
+
42
+ # Returns a negative value if the point is to the left,
43
+ # a positive value if the point is to the right, or
44
+ # 0 if the point is collinear to the segment.
45
+
46
+ def side(p_)
47
+ px_ = p_.x
48
+ py_ = p_.y
49
+ (@sx - px_) * (@ey - py_) - (@sy - py_) * (@ex - px_)
50
+ end
51
+
52
+ def tproj(p_)
53
+ if @lensq == 0
54
+ nil
55
+ else
56
+ (@dx * (p_.x - @sx) + @dy * (p_.y - @sy)) / @lensq
57
+ end
58
+ end
59
+
60
+ def contains_point?(p_)
61
+ if side(p_) == 0
62
+ t_ = tproj(p_)
63
+ t_ && t_ >= 0.0 && t_ <= 1.0
64
+ else
65
+ false
66
+ end
67
+ end
68
+
69
+ def intersects_segment?(seg_)
70
+ s2_ = seg_.s
71
+ # Handle degenerate cases
72
+ if seg_.degenerate?
73
+ if @lensq == 0
74
+ return @s == s2_
75
+ else
76
+ return contains_point?(s2_)
77
+ end
78
+ elsif @lensq == 0
79
+ return seg_.contains_point?(@s)
80
+ end
81
+ # Both segments have nonzero length.
82
+ sx2_ = s2_.x
83
+ sy2_ = s2_.y
84
+ dx2_ = seg_.dx
85
+ dy2_ = seg_.dy
86
+ denom_ = @dx * dy2_ - @dy * dx2_
87
+ if denom_ == 0
88
+ # Segments are parallel. Make sure they are collinear.
89
+ return false unless side(s2_) == 0
90
+ # 1-D check.
91
+ ts_ = (@dx * (sx2_ - @sx) + @dy * (sy2_ - @sy)) / @lensq
92
+ te_ = (@dx * (sx2_ + dx2_ - @sx) + @dy * (sy2_ + dy2_ - @sy)) / @lensq
93
+ if ts_ < te_
94
+ te_ >= 0.0 && ts_ <= 1.0
95
+ else
96
+ ts_ >= 0.0 && te_ <= 1.0
97
+ end
98
+ else
99
+ # Segments are not parallel. Check the intersection of their
100
+ # containing lines.
101
+ t_ = (dy2_ * (sx2_ - @sx) + dx2_ * (@sy - sy2_)) / denom_
102
+ return false if t_ < 0.0 || t_ > 1.0
103
+ t2_ = (@dy * (sx2_ - @sx) + @dx * (@sy - sy2_)) / denom_
104
+ t2_ >= 0.0 && t2_ <= 1.0
105
+ end
106
+ end
107
+
108
+ def length
109
+ ::Math.sqrt(@lensq)
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,347 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Geographic data factory implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+
7
+ module RGeo
8
+ module Cartesian
9
+ # This class implements the factory for the simple cartesian
10
+ # implementation.
11
+
12
+ class Factory
13
+ include Feature::Factory::Instance
14
+
15
+ # Create a new simple cartesian factory.
16
+ #
17
+ # See ::RGeo::Cartesian.simple_factory for a list of supported options.
18
+
19
+ def initialize(opts_ = {})
20
+ @has_z = opts_[:has_z_coordinate] ? true : false
21
+ @has_m = opts_[:has_m_coordinate] ? true : false
22
+ @proj4 = opts_[:proj4]
23
+ if CoordSys::Proj4.supported?
24
+ if @proj4.is_a?(::String) || @proj4.is_a?(::Hash)
25
+ @proj4 = CoordSys::Proj4.create(@proj4)
26
+ end
27
+ else
28
+ @proj4 = nil
29
+ end
30
+ srid_ = opts_[:srid]
31
+ @coord_sys = opts_[:coord_sys]
32
+ if @coord_sys.is_a?(::String)
33
+ @coord_sys = begin
34
+ CoordSys::CS.create_from_wkt(@coord_sys)
35
+ rescue
36
+ nil
37
+ end
38
+ end
39
+ if (!@proj4 || !@coord_sys) && srid_ && (db_ = opts_[:srs_database])
40
+ entry_ = db_.get(srid_.to_i)
41
+ if entry_
42
+ @proj4 ||= entry_.proj4
43
+ @coord_sys ||= entry_.coord_sys
44
+ end
45
+ end
46
+ srid_ ||= @coord_sys.authority_code if @coord_sys
47
+ @srid = srid_.to_i
48
+ @lenient_assertions = opts_[:uses_lenient_assertions] ? true : false
49
+ @buffer_resolution = opts_[:buffer_resolution].to_i
50
+ @buffer_resolution = 1 if @buffer_resolution < 1
51
+
52
+ wkt_generator_ = opts_[:wkt_generator]
53
+ case wkt_generator_
54
+ when ::Hash
55
+ @wkt_generator = WKRep::WKTGenerator.new(wkt_generator_)
56
+ else
57
+ @wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
58
+ end
59
+ wkb_generator_ = opts_[:wkb_generator]
60
+ case wkb_generator_
61
+ when ::Hash
62
+ @wkb_generator = WKRep::WKBGenerator.new(wkb_generator_)
63
+ else
64
+ @wkb_generator = WKRep::WKBGenerator.new
65
+ end
66
+ wkt_parser_ = opts_[:wkt_parser]
67
+ case wkt_parser_
68
+ when ::Hash
69
+ @wkt_parser = WKRep::WKTParser.new(self, wkt_parser_)
70
+ else
71
+ @wkt_parser = WKRep::WKTParser.new(self)
72
+ end
73
+ wkb_parser_ = opts_[:wkb_parser]
74
+ case wkb_parser_
75
+ when ::Hash
76
+ @wkb_parser = WKRep::WKBParser.new(self, wkb_parser_)
77
+ else
78
+ @wkb_parser = WKRep::WKBParser.new(self)
79
+ end
80
+ end
81
+
82
+ # Equivalence test.
83
+
84
+ def eql?(rhs_)
85
+ rhs_.is_a?(self.class) && @srid == rhs_.srid &&
86
+ @has_z == rhs_.property(:has_z_coordinate) &&
87
+ @has_m == rhs_.property(:has_m_coordinate) &&
88
+ @proj4.eql?(rhs_.proj4)
89
+ end
90
+ alias_method :==, :eql?
91
+
92
+ # Standard hash code
93
+
94
+ def hash
95
+ @hash ||= [@srid, @has_z, @has_m, @proj4].hash
96
+ end
97
+
98
+ # Marshal support
99
+
100
+ def marshal_dump # :nodoc:
101
+ hash_ = {
102
+ "hasz" => @has_z,
103
+ "hasm" => @has_m,
104
+ "srid" => @srid,
105
+ "wktg" => @wkt_generator._properties,
106
+ "wkbg" => @wkb_generator._properties,
107
+ "wktp" => @wkt_parser._properties,
108
+ "wkbp" => @wkb_parser._properties,
109
+ "lena" => @lenient_assertions,
110
+ "bufr" => @buffer_resolution
111
+ }
112
+ hash_["proj4"] = @proj4.marshal_dump if @proj4
113
+ hash_["cs"] = @coord_sys.to_wkt if @coord_sys
114
+ hash_
115
+ end
116
+
117
+ def marshal_load(data_) # :nodoc:
118
+ if CoordSys::Proj4.supported? && (proj4_data_ = data_["proj4"])
119
+ proj4_ = CoordSys::Proj4.allocate
120
+ proj4_.marshal_load(proj4_data_)
121
+ else
122
+ proj4_ = nil
123
+ end
124
+ if (coord_sys_data_ = data_["cs"])
125
+ coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
126
+ else
127
+ coord_sys_ = nil
128
+ end
129
+ initialize(
130
+ has_z_coordinate: data_["hasz"],
131
+ has_m_coordinate: data_["hasm"],
132
+ srid: data_["srid"],
133
+ wkt_generator: ImplHelper::Utils.symbolize_hash(data_["wktg"]),
134
+ wkb_generator: ImplHelper::Utils.symbolize_hash(data_["wkbg"]),
135
+ wkt_parser: ImplHelper::Utils.symbolize_hash(data_["wktp"]),
136
+ wkb_parser: ImplHelper::Utils.symbolize_hash(data_["wkbp"]),
137
+ uses_lenient_assertions: data_["lena"],
138
+ buffer_resolution: data_["bufr"],
139
+ proj4: proj4_,
140
+ coord_sys: coord_sys_
141
+ )
142
+ end
143
+
144
+ # Psych support
145
+
146
+ def encode_with(coder_) # :nodoc:
147
+ coder_["has_z_coordinate"] = @has_z
148
+ coder_["has_m_coordinate"] = @has_m
149
+ coder_["srid"] = @srid
150
+ coder_["lenient_assertions"] = @lenient_assertions
151
+ coder_["buffer_resolution"] = @buffer_resolution
152
+ coder_["wkt_generator"] = @wkt_generator._properties
153
+ coder_["wkb_generator"] = @wkb_generator._properties
154
+ coder_["wkt_parser"] = @wkt_parser._properties
155
+ coder_["wkb_parser"] = @wkb_parser._properties
156
+ if @proj4
157
+ str_ = @proj4.original_str || @proj4.canonical_str
158
+ coder_["proj4"] = @proj4.radians? ? { "proj4" => str_, "radians" => true } : str_
159
+ end
160
+ coder_["coord_sys"] = @coord_sys.to_wkt if @coord_sys
161
+ end
162
+
163
+ def init_with(coder_) # :nodoc:
164
+ if (proj4_data_ = coder_["proj4"])
165
+ if proj4_data_.is_a?(::Hash)
166
+ proj4_ = CoordSys::Proj4.create(proj4_data_["proj4"], radians: proj4_data_["radians"])
167
+ else
168
+ proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
169
+ end
170
+ else
171
+ proj4_ = nil
172
+ end
173
+ if (coord_sys_data_ = coder_["cs"])
174
+ coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
175
+ else
176
+ coord_sys_ = nil
177
+ end
178
+ initialize(
179
+ has_z_coordinate: coder_["has_z_coordinate"],
180
+ has_m_coordinate: coder_["has_m_coordinate"],
181
+ srid: coder_["srid"],
182
+ wkt_generator: ImplHelper::Utils.symbolize_hash(coder_["wkt_generator"]),
183
+ wkb_generator: ImplHelper::Utils.symbolize_hash(coder_["wkb_generator"]),
184
+ wkt_parser: ImplHelper::Utils.symbolize_hash(coder_["wkt_parser"]),
185
+ wkb_parser: ImplHelper::Utils.symbolize_hash(coder_["wkb_parser"]),
186
+ uses_lenient_assertions: coder_["lenient_assertions"],
187
+ buffer_resolution: coder_["buffer_resolution"],
188
+ proj4: proj4_,
189
+ coord_sys: coord_sys_
190
+ )
191
+ end
192
+
193
+ # Returns the SRID.
194
+
195
+ attr_reader :srid
196
+
197
+ # See ::RGeo::Feature::Factory#property
198
+
199
+ def property(name_)
200
+ case name_
201
+ when :has_z_coordinate
202
+ @has_z
203
+ when :has_m_coordinate
204
+ @has_m
205
+ when :uses_lenient_assertions
206
+ @lenient_assertions
207
+ when :buffer_resolution
208
+ @buffer_resolution
209
+ when :is_cartesian
210
+ true
211
+ end
212
+ end
213
+
214
+ # See ::RGeo::Feature::Factory#parse_wkt
215
+
216
+ def parse_wkt(str_)
217
+ @wkt_parser.parse(str_)
218
+ end
219
+
220
+ # See ::RGeo::Feature::Factory#parse_wkb
221
+
222
+ def parse_wkb(str_)
223
+ @wkb_parser.parse(str_)
224
+ end
225
+
226
+ # See ::RGeo::Feature::Factory#point
227
+
228
+ def point(x_, y_, *extra_)
229
+ PointImpl.new(self, x_, y_, *extra_)
230
+ rescue
231
+ nil
232
+ end
233
+
234
+ # See ::RGeo::Feature::Factory#line_string
235
+
236
+ def line_string(points_)
237
+ LineStringImpl.new(self, points_)
238
+ rescue
239
+ nil
240
+ end
241
+
242
+ # See ::RGeo::Feature::Factory#line
243
+
244
+ def line(start_, end_)
245
+ LineImpl.new(self, start_, end_)
246
+ rescue
247
+ nil
248
+ end
249
+
250
+ # See ::RGeo::Feature::Factory#linear_ring
251
+
252
+ def linear_ring(points_)
253
+ LinearRingImpl.new(self, points_)
254
+ rescue
255
+ nil
256
+ end
257
+
258
+ # See ::RGeo::Feature::Factory#polygon
259
+
260
+ def polygon(outer_ring_, inner_rings_ = nil)
261
+ PolygonImpl.new(self, outer_ring_, inner_rings_)
262
+ rescue
263
+ nil
264
+ end
265
+
266
+ # See ::RGeo::Feature::Factory#collection
267
+
268
+ def collection(elems_)
269
+ GeometryCollectionImpl.new(self, elems_)
270
+ rescue
271
+ nil
272
+ end
273
+
274
+ # See ::RGeo::Feature::Factory#multi_point
275
+
276
+ def multi_point(elems_)
277
+ MultiPointImpl.new(self, elems_)
278
+ rescue
279
+ nil
280
+ end
281
+
282
+ # See ::RGeo::Feature::Factory#multi_line_string
283
+
284
+ def multi_line_string(elems_)
285
+ MultiLineStringImpl.new(self, elems_)
286
+ rescue
287
+ nil
288
+ end
289
+
290
+ # See ::RGeo::Feature::Factory#multi_polygon
291
+
292
+ def multi_polygon(elems_)
293
+ MultiPolygonImpl.new(self, elems_)
294
+ rescue
295
+ nil
296
+ end
297
+
298
+ # See ::RGeo::Feature::Factory#proj4
299
+
300
+ attr_reader :proj4
301
+
302
+ # See ::RGeo::Feature::Factory#coord_sys
303
+
304
+ attr_reader :coord_sys
305
+
306
+ def _generate_wkt(obj_) # :nodoc:
307
+ @wkt_generator.generate(obj_)
308
+ end
309
+
310
+ def _generate_wkb(obj_) # :nodoc:
311
+ @wkb_generator.generate(obj_)
312
+ end
313
+
314
+ def _marshal_wkb_generator # :nodoc:
315
+ unless defined?(@marshal_wkb_generator)
316
+ @marshal_wkb_generator = ::RGeo::WKRep::WKBGenerator.new(
317
+ type_format: :wkb12)
318
+ end
319
+ @marshal_wkb_generator
320
+ end
321
+
322
+ def _marshal_wkb_parser # :nodoc:
323
+ unless defined?(@marshal_wkb_parser)
324
+ @marshal_wkb_parser = ::RGeo::WKRep::WKBParser.new(self,
325
+ support_wkb12: true)
326
+ end
327
+ @marshal_wkb_parser
328
+ end
329
+
330
+ def _psych_wkt_generator # :nodoc:
331
+ unless defined?(@psych_wkt_generator)
332
+ @psych_wkt_generator = ::RGeo::WKRep::WKTGenerator.new(
333
+ tag_format: :wkt12)
334
+ end
335
+ @psych_wkt_generator
336
+ end
337
+
338
+ def _psych_wkt_parser # :nodoc:
339
+ unless defined?(@psych_wkt_parser)
340
+ @psych_wkt_parser = ::RGeo::WKRep::WKTParser.new(self,
341
+ support_wkt12: true, support_ewkt: true)
342
+ end
343
+ @psych_wkt_parser
344
+ end
345
+ end
346
+ end
347
+ end