rgeo 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/History.rdoc +11 -0
  2. data/README.rdoc +23 -7
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/factory.c +1 -1
  5. data/{lib/rgeo/geography/simple_mercator.rb → ext/proj4_c_impl/extconf.rb} +35 -30
  6. data/ext/proj4_c_impl/main.c +256 -0
  7. data/lib/rgeo.rb +54 -42
  8. data/lib/rgeo/active_record/arel_modifications.rb +2 -2
  9. data/lib/rgeo/active_record/base_modifications.rb +1 -1
  10. data/lib/rgeo/active_record/mysql_common.rb +12 -12
  11. data/lib/rgeo/all.rb +5 -4
  12. data/lib/rgeo/cartesian.rb +3 -2
  13. data/lib/rgeo/cartesian/bounding_box.rb +9 -9
  14. data/lib/rgeo/cartesian/factory.rb +30 -13
  15. data/lib/rgeo/cartesian/feature_classes.rb +33 -33
  16. data/lib/rgeo/cartesian/interface.rb +2 -2
  17. data/lib/rgeo/{geography/all.rb → coord_sys.rb} +22 -4
  18. data/lib/rgeo/coord_sys/proj4.rb +275 -0
  19. data/lib/rgeo/{errors.rb → error.rb} +5 -6
  20. data/lib/rgeo/{features.rb → feature.rb} +22 -20
  21. data/lib/rgeo/{features → feature}/curve.rb +6 -6
  22. data/lib/rgeo/{features → feature}/factory.rb +19 -3
  23. data/lib/rgeo/{features → feature}/factory_generator.rb +1 -1
  24. data/lib/rgeo/{features → feature}/geometry.rb +34 -34
  25. data/lib/rgeo/{features → feature}/geometry_collection.rb +4 -4
  26. data/lib/rgeo/{features → feature}/line.rb +1 -1
  27. data/lib/rgeo/{features → feature}/line_string.rb +4 -4
  28. data/lib/rgeo/{features → feature}/linear_ring.rb +1 -1
  29. data/lib/rgeo/{features → feature}/multi_curve.rb +3 -3
  30. data/lib/rgeo/{features → feature}/multi_line_string.rb +1 -1
  31. data/lib/rgeo/{features → feature}/multi_point.rb +1 -1
  32. data/lib/rgeo/{features → feature}/multi_polygon.rb +1 -1
  33. data/lib/rgeo/{features → feature}/multi_surface.rb +4 -4
  34. data/lib/rgeo/{features → feature}/point.rb +5 -5
  35. data/lib/rgeo/{features → feature}/polygon.rb +5 -5
  36. data/lib/rgeo/{features → feature}/surface.rb +4 -4
  37. data/lib/rgeo/feature/types.rb +301 -0
  38. data/lib/rgeo/geo_json.rb +1 -1
  39. data/lib/rgeo/geo_json/coder.rb +13 -13
  40. data/lib/rgeo/geo_json/interface.rb +2 -2
  41. data/lib/rgeo/geography.rb +33 -6
  42. data/lib/rgeo/geography/factory.rb +82 -39
  43. data/lib/rgeo/geography/interface.rb +135 -89
  44. data/lib/rgeo/geography/proj4_projector.rb +98 -0
  45. data/lib/rgeo/geography/projected_feature_classes.rb +213 -0
  46. data/lib/rgeo/geography/projected_feature_methods.rb +228 -0
  47. data/lib/rgeo/geography/projected_window.rb +7 -7
  48. data/lib/rgeo/geography/simple_mercator_projector.rb +133 -0
  49. data/lib/rgeo/geography/spherical_feature_classes.rb +212 -0
  50. data/lib/rgeo/geography/{simple_spherical/feature_methods.rb → spherical_feature_methods.rb} +39 -43
  51. data/lib/rgeo/geography/{simple_spherical/calculations.rb → spherical_math.rb} +7 -7
  52. data/lib/rgeo/geos.rb +1 -1
  53. data/lib/rgeo/geos/factory.rb +37 -19
  54. data/lib/rgeo/geos/impl_additions.rb +10 -11
  55. data/lib/rgeo/geos/interface.rb +1 -1
  56. data/lib/rgeo/geos/zm_factory.rb +15 -15
  57. data/lib/rgeo/geos/zm_impl.rb +10 -10
  58. data/lib/rgeo/{impl_helpers.rb → impl_helper.rb} +8 -8
  59. data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_collection_methods.rb +13 -13
  60. data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_methods.rb +2 -2
  61. data/lib/rgeo/{impl_helpers → impl_helper}/basic_line_string_methods.rb +13 -13
  62. data/lib/rgeo/{impl_helpers → impl_helper}/basic_point_methods.rb +5 -5
  63. data/lib/rgeo/{impl_helpers → impl_helper}/basic_polygon_methods.rb +6 -6
  64. data/lib/rgeo/{impl_helpers → impl_helper}/math.rb +1 -1
  65. data/lib/rgeo/shapefile.rb +1 -1
  66. data/lib/rgeo/shapefile/reader.rb +3 -3
  67. data/lib/rgeo/wkrep.rb +1 -1
  68. data/lib/rgeo/wkrep/wkb_generator.rb +17 -17
  69. data/lib/rgeo/wkrep/wkb_parser.rb +12 -12
  70. data/lib/rgeo/wkrep/wkt_generator.rb +8 -8
  71. data/lib/rgeo/wkrep/wkt_parser.rb +10 -10
  72. data/{tests → test}/active_record/readme.txt +0 -0
  73. data/{tests → test}/active_record/tc_mysqlspatial.rb +2 -2
  74. data/{tests → test}/common/geometry_collection_tests.rb +22 -22
  75. data/{tests → test}/common/line_string_tests.rb +20 -20
  76. data/{tests → test}/common/multi_line_string_tests.rb +19 -19
  77. data/{tests → test}/common/multi_point_tests.rb +17 -17
  78. data/{tests → test}/common/multi_polygon_tests.rb +16 -16
  79. data/{tests → test}/common/point_tests.rb +9 -9
  80. data/{tests → test}/common/polygon_tests.rb +9 -9
  81. data/test/coord_sys/tc_proj4.rb +111 -0
  82. data/{tests → test}/geos/tc_factory.rb +1 -1
  83. data/{tests → test}/geos/tc_geometry_collection.rb +1 -1
  84. data/{tests → test}/geos/tc_line_string.rb +0 -0
  85. data/{tests → test}/geos/tc_misc.rb +1 -1
  86. data/{tests → test}/geos/tc_multi_line_string.rb +1 -1
  87. data/{tests → test}/geos/tc_multi_point.rb +1 -1
  88. data/{tests → test}/geos/tc_multi_polygon.rb +1 -1
  89. data/{tests → test}/geos/tc_point.rb +1 -1
  90. data/{tests → test}/geos/tc_polygon.rb +0 -0
  91. data/{tests → test}/geos/tc_zmfactory.rb +2 -2
  92. data/test/projected_geography/tc_geometry_collection.rb +62 -0
  93. data/test/projected_geography/tc_line_string.rb +62 -0
  94. data/test/projected_geography/tc_multi_line_string.rb +62 -0
  95. data/test/projected_geography/tc_multi_point.rb +62 -0
  96. data/test/projected_geography/tc_multi_polygon.rb +63 -0
  97. data/test/projected_geography/tc_point.rb +93 -0
  98. data/test/projected_geography/tc_polygon.rb +62 -0
  99. data/{tests → test}/shapefile/shapelib_testcases/readme.txt +0 -0
  100. data/{tests → test}/shapefile/shapelib_testcases/test.dbf +0 -0
  101. data/{tests → test}/shapefile/shapelib_testcases/test.shp +0 -0
  102. data/{tests → test}/shapefile/shapelib_testcases/test.shx +0 -0
  103. data/{tests → test}/shapefile/shapelib_testcases/test0.shp +0 -0
  104. data/{tests → test}/shapefile/shapelib_testcases/test0.shx +0 -0
  105. data/{tests → test}/shapefile/shapelib_testcases/test1.shp +0 -0
  106. data/{tests → test}/shapefile/shapelib_testcases/test1.shx +0 -0
  107. data/{tests → test}/shapefile/shapelib_testcases/test10.shp +0 -0
  108. data/{tests → test}/shapefile/shapelib_testcases/test10.shx +0 -0
  109. data/{tests → test}/shapefile/shapelib_testcases/test11.shp +0 -0
  110. data/{tests → test}/shapefile/shapelib_testcases/test11.shx +0 -0
  111. data/{tests → test}/shapefile/shapelib_testcases/test12.shp +0 -0
  112. data/{tests → test}/shapefile/shapelib_testcases/test12.shx +0 -0
  113. data/{tests → test}/shapefile/shapelib_testcases/test13.shp +0 -0
  114. data/{tests → test}/shapefile/shapelib_testcases/test13.shx +0 -0
  115. data/{tests → test}/shapefile/shapelib_testcases/test2.shp +0 -0
  116. data/{tests → test}/shapefile/shapelib_testcases/test2.shx +0 -0
  117. data/{tests → test}/shapefile/shapelib_testcases/test3.shp +0 -0
  118. data/{tests → test}/shapefile/shapelib_testcases/test3.shx +0 -0
  119. data/{tests → test}/shapefile/shapelib_testcases/test4.shp +0 -0
  120. data/{tests → test}/shapefile/shapelib_testcases/test4.shx +0 -0
  121. data/{tests → test}/shapefile/shapelib_testcases/test5.shp +0 -0
  122. data/{tests → test}/shapefile/shapelib_testcases/test5.shx +0 -0
  123. data/{tests → test}/shapefile/shapelib_testcases/test6.shp +0 -0
  124. data/{tests → test}/shapefile/shapelib_testcases/test6.shx +0 -0
  125. data/{tests → test}/shapefile/shapelib_testcases/test7.shp +0 -0
  126. data/{tests → test}/shapefile/shapelib_testcases/test7.shx +0 -0
  127. data/{tests → test}/shapefile/shapelib_testcases/test8.shp +0 -0
  128. data/{tests → test}/shapefile/shapelib_testcases/test8.shx +0 -0
  129. data/{tests → test}/shapefile/shapelib_testcases/test9.shp +0 -0
  130. data/{tests → test}/shapefile/shapelib_testcases/test9.shx +0 -0
  131. data/{tests → test}/shapefile/tc_shapelib_tests.rb +17 -17
  132. data/{tests → test}/simple_cartesian/tc_calculations.rb +0 -0
  133. data/{tests → test}/simple_cartesian/tc_geometry_collection.rb +0 -0
  134. data/{tests → test}/simple_cartesian/tc_line_string.rb +0 -0
  135. data/{tests → test}/simple_cartesian/tc_multi_line_string.rb +0 -0
  136. data/{tests → test}/simple_cartesian/tc_multi_point.rb +0 -0
  137. data/{tests → test}/simple_cartesian/tc_multi_polygon.rb +0 -0
  138. data/{tests → test}/simple_cartesian/tc_point.rb +0 -0
  139. data/{tests → test}/simple_cartesian/tc_polygon.rb +0 -0
  140. data/{tests → test}/simple_mercator/tc_geometry_collection.rb +1 -1
  141. data/{tests → test}/simple_mercator/tc_line_string.rb +0 -0
  142. data/{tests → test}/simple_mercator/tc_multi_line_string.rb +1 -1
  143. data/{tests → test}/simple_mercator/tc_multi_point.rb +1 -1
  144. data/{tests → test}/simple_mercator/tc_multi_polygon.rb +1 -1
  145. data/{tests → test}/simple_mercator/tc_point.rb +2 -2
  146. data/{tests → test}/simple_mercator/tc_polygon.rb +0 -0
  147. data/{tests → test}/simple_mercator/tc_window.rb +1 -1
  148. data/test/spherical_geography/tc_calculations.rb +203 -0
  149. data/{tests/simple_spherical → test/spherical_geography}/tc_geometry_collection.rb +2 -2
  150. data/{tests/simple_spherical → test/spherical_geography}/tc_line_string.rb +2 -2
  151. data/{tests/simple_spherical → test/spherical_geography}/tc_multi_line_string.rb +2 -2
  152. data/{tests/simple_spherical → test/spherical_geography}/tc_multi_point.rb +2 -2
  153. data/{tests/simple_spherical → test/spherical_geography}/tc_multi_polygon.rb +3 -3
  154. data/{tests/simple_spherical → test/spherical_geography}/tc_point.rb +7 -7
  155. data/{tests/simple_spherical → test/spherical_geography}/tc_polygon.rb +2 -2
  156. data/{tests → test}/tc_cartesian_analysis.rb +0 -0
  157. data/{tests → test}/tc_geojson.rb +0 -0
  158. data/{tests → test}/tc_oneoff.rb +2 -1
  159. data/{tests → test}/wkrep/tc_wkb_generator.rb +0 -0
  160. data/{tests → test}/wkrep/tc_wkb_parser.rb +32 -32
  161. data/{tests → test}/wkrep/tc_wkt_generator.rb +0 -0
  162. data/{tests → test}/wkrep/tc_wkt_parser.rb +46 -46
  163. metadata +183 -164
  164. data/lib/rgeo/features/types.rb +0 -272
  165. data/lib/rgeo/geography/simple_mercator/feature_classes.rb +0 -279
  166. data/lib/rgeo/geography/simple_mercator/feature_methods.rb +0 -278
  167. data/lib/rgeo/geography/simple_mercator/projector.rb +0 -112
  168. data/lib/rgeo/geography/simple_spherical.rb +0 -68
  169. data/lib/rgeo/geography/simple_spherical/feature_classes.rb +0 -216
  170. data/tests/simple_spherical/tc_calculations.rb +0 -203
@@ -0,0 +1,275 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Proj4 wrapper for RGeo
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module RGeo
38
+
39
+ module CoordSys
40
+
41
+
42
+ # This is a Ruby wrapper around a Proj4 coordinate system.
43
+ # It represents a single geographic coordinate system, which may be
44
+ # a flat projection, a geocentric (3-dimensional) coordinate system,
45
+ # or a geographic (latitude-longitude) coordinate system.
46
+ #
47
+ # Generally, these are used to define the projection for a
48
+ # Feature::Factory. You can then convert between coordinate systems
49
+ # by casting geometries between such factories using the :project
50
+ # option. You may also use this object directly to perform low-level
51
+ # coordinate transformations.
52
+
53
+ class Proj4
54
+
55
+
56
+ def inspect # :nodoc:
57
+ "#<#{self.class}:0x#{object_id.to_s(16)} #{_canonical_str.inspect}>"
58
+ end
59
+
60
+
61
+ def to_s # :nodoc:
62
+ canonical_str
63
+ end
64
+
65
+
66
+ def hash # :nodoc:
67
+ canonical_hash.hash
68
+ end
69
+
70
+
71
+ # Returns true if this Proj4 is equivalent to the given Proj4.
72
+ #
73
+ # Note: this tests for equivalence by comparing only the hash
74
+ # definitions of the Proj4 objects, and returning true if those
75
+ # definitions are equivalent. In some cases, this may still return
76
+ # false even if the actual coordinate systems are identical, since
77
+ # there are sometimes multiple ways to express a given coordinate
78
+ # system.
79
+
80
+ def eql?(rhs_)
81
+ rhs_.is_a?(Proj4) && rhs_._canonical_hash == canonical_hash
82
+ end
83
+
84
+
85
+ # Returns the "canonical" string definition for this coordinate
86
+ # system, as reported by Proj4. This may be slightly different
87
+ # from the definition used to construct this object.
88
+
89
+ def canonical_str
90
+ unless defined?(@canonical_str)
91
+ @canonical_str = _canonical_str
92
+ end
93
+ @canonical_str
94
+ end
95
+
96
+
97
+ # Returns the "canonical" hash definition for this coordinate
98
+ # system, as reported by Proj4. This may be slightly different
99
+ # from the definition used to construct this object.
100
+
101
+ def canonical_hash
102
+ unless defined?(@canonical_hash)
103
+ @canonical_hash = {}
104
+ canonical_str.strip.split(/\s+/).each do |elem_|
105
+ if elem_ =~ /^\+(\w+)(=(\S+))?$/
106
+ @canonical_hash[$1] = $3
107
+ end
108
+ end
109
+ end
110
+ @canonical_hash
111
+ end
112
+
113
+
114
+ # Returns the string definition originally used to construct this
115
+ # object. Returns nil if this object wasn't created by a string
116
+ # definition; i.e. if it was created using get_geographic.
117
+
118
+ def original_str
119
+ _original_str
120
+ end
121
+
122
+
123
+ # Returns true if this Proj4 object is a geographic (lat-long)
124
+ # coordinate system.
125
+
126
+ def geographic?
127
+ _geographic?
128
+ end
129
+
130
+
131
+ # Returns true if this Proj4 object is a geocentric (3dz)
132
+ # coordinate system.
133
+
134
+ def geocentric?
135
+ _geocentric?
136
+ end
137
+
138
+
139
+ # Get the geographic (unprojected lat-long) coordinate system
140
+ # corresponding to this coordinate system; i.e. the one that uses
141
+ # the same ellipsoid and datum.
142
+
143
+ def get_geographic
144
+ _get_geographic
145
+ end
146
+
147
+
148
+ class << self
149
+
150
+
151
+ # Returns true if Proj4 is supported in this installation.
152
+ # If this returns false, the other methods such as create
153
+ # will not work.
154
+
155
+ def supported?
156
+ respond_to?(:_create)
157
+ end
158
+
159
+
160
+ # Create a new Proj4 object, given a definition, which may be
161
+ # either a string or a hash. Returns nil if the given definition
162
+ # is invalid or Proj4 is not supported.
163
+
164
+ def create(defn_)
165
+ result_ = nil
166
+ if supported?
167
+ if defn_.kind_of?(::Hash)
168
+ defn_ = defn_.map{ |k_, v_| v_ ? "+#{k_}=#{v_}" : "+#{k_}" }.join(' ')
169
+ end
170
+ result_ = _create(defn_)
171
+ result_ = nil unless result_._valid?
172
+ end
173
+ result_
174
+ end
175
+
176
+
177
+ # Create a new Proj4 object, given a definition, which may be
178
+ # either a string or a hash. Raises Error::UnsupportedCapability
179
+ # if the given definition is invalid or Proj4 is not supported.
180
+
181
+ def new(defn_)
182
+ result_ = create(defn_)
183
+ unless result_
184
+ raise Error::UnsupportedCapability, "Proj4 not supported in this installation"
185
+ end
186
+ result_
187
+ end
188
+
189
+
190
+ # Low-level coordinate transform method.
191
+ # Transforms the given coordinate (x, y, [z]) from one proj4
192
+ # coordinate system to another. Returns an array with either two
193
+ # or three elements.
194
+
195
+ def transform_coords(from_proj_, to_proj_, x_, y_, z_=nil, opts_={})
196
+ degrees_ = !opts_[:radians]
197
+ if degrees_ && from_proj_._geographic?
198
+ x_ *= ImplHelper::Math::RADIANS_PER_DEGREE
199
+ y_ *= ImplHelper::Math::RADIANS_PER_DEGREE
200
+ end
201
+ result_ = _transform_coords(from_proj_, to_proj_, x_, y_, z_)
202
+ if result_ && degrees_ && to_proj_._geographic?
203
+ result_[0] *= ImplHelper::Math::DEGREES_PER_RADIAN
204
+ result_[1] *= ImplHelper::Math::DEGREES_PER_RADIAN
205
+ end
206
+ result_
207
+ end
208
+
209
+
210
+ # Low-level geometry transform method.
211
+ # Transforms the given geometry between the given two projections.
212
+ # The resulting geometry is constructed using the to_factory.
213
+ # Any projections associated with the factories themselves are
214
+ # ignored.
215
+
216
+ def transform(from_proj_, from_geometry_, to_proj_, to_factory_)
217
+ case from_geometry_
218
+ when Feature::Point
219
+ _transform_point(from_proj_, from_geometry_, to_proj_, to_factory_)
220
+ when Feature::Line
221
+ to_factory_.line(from_geometry_.points.map{ |p_| transform(from_proj_, p_, to_proj_, to_factory_) })
222
+ when Feature::LinearRing
223
+ _transform_linear_ring(from_proj_, from_geometry_, to_proj_, to_factory_)
224
+ when Feature::LineString
225
+ to_factory_.line_string(from_geometry_.points.map{ |p_| transform(from_proj_, p_, to_proj_, to_factory_) })
226
+ when Feature::Polygon
227
+ _transform_polygon(from_proj_, from_geometry_, to_proj_, to_factory_)
228
+ when Feature::MultiPoint
229
+ to_factory_.multi_point(from_geometry_.map{ |p_| _transform_point(from_proj_, p_, to_proj_, to_factory_) })
230
+ when Feature::MultiLineString
231
+ to_factory_.multi_line_string(from_geometry_.map{ |g_| transform(from_proj_, g_, to_proj_, to_factory_) })
232
+ when Feature::MultiPolygon
233
+ to_factory_.multi_polygon(from_geometry_.map{ |p_| _transform_polygon(from_proj_, p_, to_proj_, to_factory_) })
234
+ when Feature::GeometryCollection
235
+ to_factory_.collection(from_geometry_.map{ |g_| transform(from_proj_, g_, to_proj_, to_factory_) })
236
+ end
237
+ end
238
+
239
+
240
+ def _transform_point(from_proj_, from_point_, to_proj_, to_factory_) # :nodoc:
241
+ from_factory_ = from_point_.factory
242
+ from_has_z_ = from_factory_.has_capability?(:z_coordinate)
243
+ from_has_m_ = from_factory_.has_capability?(:m_coordinate)
244
+ to_has_z_ = to_factory_.has_capability?(:z_coordinate)
245
+ to_has_m_ = to_factory_.has_capability?(:m_coordinate)
246
+ coords_ = _transform_coords(from_proj_, to_proj_, from_point_.x, from_point_.y,
247
+ from_has_z_ ? from_point_.z : nil)
248
+ extras_ = []
249
+ extras_ << coords_[2].to_f if to_has_z_
250
+ extras_ << from_has_m_ ? from_point_.m : 0.0 if to_has_m_?
251
+ to_factory_.point(coords_[0], coords_[1], extras_)
252
+ end
253
+
254
+
255
+ def _transform_linear_ring(from_proj_, from_ring_, to_proj_, to_factory_) # :nodoc:
256
+ to_factory_.linear_ring(from_ring_.points[0..-2].map{ |p_| transform(from_proj_, p_, to_proj_, to_factory_) })
257
+ end
258
+
259
+
260
+ def _transform_polygon(from_proj_, from_polygon_, to_proj_, to_factory_) # :nodoc:
261
+ ext_ = _transform_linear_ring(from_proj_, from_polygon_.exterior_ring, to_proj_, to_factory_)
262
+ int_ = from_polygon_.interior_rings.map{ |r_| _transform_linear_ring(from_proj_, r_, to_proj_, to_factory_) }
263
+ to_factory_.polygon(ext_, int_)
264
+ end
265
+
266
+
267
+ end
268
+
269
+
270
+ end
271
+
272
+
273
+ end
274
+
275
+ end
@@ -43,21 +43,17 @@ module RGeo
43
43
 
44
44
  # All RGeo errors are members of this namespace.
45
45
 
46
- module Errors
46
+ module Error
47
47
 
48
48
  # Base class for all RGeo-related exceptions
49
49
  class RGeoError < ::RuntimeError
50
50
  end
51
51
 
52
- # The method is unimplemented
53
- class MethodUnimplemented < RGeoError
54
- end
55
-
56
52
  # The specified geometry is invalid
57
53
  class InvalidGeometry < RGeoError
58
54
  end
59
55
 
60
- # The specified capability is not supported
56
+ # The specified capability is not supported or not implemented
61
57
  class UnsupportedCapability < RGeoError
62
58
  end
63
59
 
@@ -67,5 +63,8 @@ module RGeo
67
63
 
68
64
  end
69
65
 
66
+ # Deprecated alias
67
+ Errors = Error
68
+
70
69
 
71
70
  end
@@ -41,7 +41,7 @@ require 'rgeo'
41
41
  module RGeo
42
42
 
43
43
 
44
- # The Features namespace contains interfaces and general tools for
44
+ # The Feature namespace contains interfaces and general tools for
45
45
  # implementations of the Open Geospatial Consortium Simple Features
46
46
  # Specification (SFS), version 1.1.0.
47
47
  #
@@ -65,31 +65,33 @@ module RGeo
65
65
  # itself. The implementation should separately document any such
66
66
  # extensions that it may provide.
67
67
 
68
- module Features
68
+ module Feature
69
69
  end
70
70
 
71
+ # Deprecated alias
72
+ Features = Feature
73
+
71
74
 
72
75
  end
73
76
 
74
77
 
75
78
  # Dependency files
76
- require 'rgeo/errors'
79
+ require 'rgeo/error'
77
80
 
78
81
  # Implementation files
79
- require 'rgeo/features/factory'
80
- require 'rgeo/features/types'
81
- require 'rgeo/features/geometry'
82
- require 'rgeo/features/point'
83
- require 'rgeo/features/curve'
84
- require 'rgeo/features/line_string'
85
- require 'rgeo/features/linear_ring'
86
- require 'rgeo/features/line'
87
- require 'rgeo/features/surface'
88
- require 'rgeo/features/polygon'
89
- require 'rgeo/features/geometry_collection'
90
- require 'rgeo/features/multi_point'
91
- require 'rgeo/features/multi_curve'
92
- require 'rgeo/features/multi_line_string'
93
- require 'rgeo/features/multi_surface'
94
- require 'rgeo/features/multi_polygon'
95
-
82
+ require 'rgeo/feature/factory'
83
+ require 'rgeo/feature/types'
84
+ require 'rgeo/feature/geometry'
85
+ require 'rgeo/feature/point'
86
+ require 'rgeo/feature/curve'
87
+ require 'rgeo/feature/line_string'
88
+ require 'rgeo/feature/linear_ring'
89
+ require 'rgeo/feature/line'
90
+ require 'rgeo/feature/surface'
91
+ require 'rgeo/feature/polygon'
92
+ require 'rgeo/feature/geometry_collection'
93
+ require 'rgeo/feature/multi_point'
94
+ require 'rgeo/feature/multi_curve'
95
+ require 'rgeo/feature/multi_line_string'
96
+ require 'rgeo/feature/multi_surface'
97
+ require 'rgeo/feature/multi_polygon'
@@ -36,7 +36,7 @@
36
36
 
37
37
  module RGeo
38
38
 
39
- module Features
39
+ module Feature
40
40
 
41
41
 
42
42
  # == SFS 1.1 Description
@@ -88,7 +88,7 @@ module RGeo
88
88
  # Returns a floating-point scalar value.
89
89
 
90
90
  def length
91
- raise Errors::MethodUnimplemented
91
+ raise Error::UnsupportedCapability, "Method Curve#length not defined."
92
92
  end
93
93
 
94
94
 
@@ -101,7 +101,7 @@ module RGeo
101
101
  # Returns an object that supports the Point interface.
102
102
 
103
103
  def start_point
104
- raise Errors::MethodUnimplemented
104
+ raise Error::UnsupportedCapability, "Method Curve#start_point not defined."
105
105
  end
106
106
 
107
107
 
@@ -114,7 +114,7 @@ module RGeo
114
114
  # Returns an object that supports the Point interface.
115
115
 
116
116
  def end_point
117
- raise Errors::MethodUnimplemented
117
+ raise Error::UnsupportedCapability, "Method Curve#end_point not defined."
118
118
  end
119
119
 
120
120
 
@@ -128,7 +128,7 @@ module RGeo
128
128
  # specification, which stipulates an integer return value.
129
129
 
130
130
  def is_closed?
131
- raise Errors::MethodUnimplemented
131
+ raise Error::UnsupportedCapability, "Method Curve#is_closed? not defined."
132
132
  end
133
133
 
134
134
 
@@ -144,7 +144,7 @@ module RGeo
144
144
  # specification, which stipulates an integer return value.
145
145
 
146
146
  def is_ring?
147
- raise Errors::MethodUnimplemented
147
+ raise Error::UnsupportedCapability, "Method Curve#is_ring? not defined."
148
148
  end
149
149
 
150
150
 
@@ -36,11 +36,11 @@
36
36
 
37
37
  module RGeo
38
38
 
39
- module Features
39
+ module Feature
40
40
 
41
41
 
42
42
  # This is a standard interface for factories of features.
43
- # Generally, each Features implementation will implement these
43
+ # Generally, each Feature implementation will implement these
44
44
  # methods as a standard way to create features.
45
45
  #
46
46
  # If the implementation is unable to create the given feature,
@@ -96,6 +96,9 @@ module RGeo
96
96
  # Supports an "m" coordinate. When an implementation supports
97
97
  # this capability, geometries know about M coordinates, and the
98
98
  # Point#m method is available.
99
+ # <tt>:proj4</tt>::
100
+ # Has a proj4-defined projection. When an implementation supports
101
+ # this capability, the Factory#proj4 method is available.
99
102
 
100
103
  def has_capability?(name_)
101
104
  nil
@@ -238,7 +241,7 @@ module RGeo
238
241
  #
239
242
  # It should return either a casted result object, false, or nil.
240
243
  # A nil return value indicates that casting should be forced to
241
- # fail (and ::RGeo::Features::cast will return nil).
244
+ # fail (and ::RGeo::Feature::cast will return nil).
242
245
  # A false return value indicates that this method declines to
243
246
  # override the casting algorithm, and RGeo should use its default
244
247
  # algorithm to cast the object. Therefore, by default, you should
@@ -249,6 +252,19 @@ module RGeo
249
252
  end
250
253
 
251
254
 
255
+ # This is an optional method that returns a RGeo::CoordSys::Proj4
256
+ # representing the projection for the coordinate system of features
257
+ # created by this factory, or nil if there is no such proj4
258
+ # projection.
259
+ #
260
+ # If a factory supports this method, it should indicate this by
261
+ # returning true for the <tt>:proj4</tt> capability.
262
+
263
+ def proj4
264
+ nil
265
+ end
266
+
267
+
252
268
  end
253
269
 
254
270