rgeo 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/History.rdoc +6 -0
  2. data/README.rdoc +1 -1
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/extconf.rb +13 -13
  5. data/ext/geos_c_impl/factory.c +30 -18
  6. data/ext/geos_c_impl/factory.h +18 -12
  7. data/ext/geos_c_impl/geometry.c +11 -11
  8. data/ext/geos_c_impl/geometry.h +7 -7
  9. data/ext/geos_c_impl/geometry_collection.c +15 -15
  10. data/ext/geos_c_impl/geometry_collection.h +8 -8
  11. data/ext/geos_c_impl/line_string.c +14 -14
  12. data/ext/geos_c_impl/line_string.h +7 -7
  13. data/ext/geos_c_impl/main.c +7 -7
  14. data/ext/geos_c_impl/point.c +9 -9
  15. data/ext/geos_c_impl/point.h +7 -7
  16. data/ext/geos_c_impl/polygon.c +9 -9
  17. data/ext/geos_c_impl/polygon.h +7 -7
  18. data/ext/geos_c_impl/preface.h +7 -7
  19. data/ext/proj4_c_impl/extconf.rb +13 -13
  20. data/ext/proj4_c_impl/main.c +12 -12
  21. data/lib/rgeo.rb +26 -26
  22. data/lib/rgeo/cartesian.rb +12 -12
  23. data/lib/rgeo/cartesian/analysis.rb +26 -26
  24. data/lib/rgeo/cartesian/bounding_box.rb +83 -83
  25. data/lib/rgeo/cartesian/calculations.rb +36 -36
  26. data/lib/rgeo/cartesian/factory.rb +78 -78
  27. data/lib/rgeo/cartesian/feature_classes.rb +74 -74
  28. data/lib/rgeo/cartesian/feature_methods.rb +34 -34
  29. data/lib/rgeo/cartesian/interface.rb +33 -33
  30. data/lib/rgeo/coord_sys.rb +15 -15
  31. data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
  32. data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
  33. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
  34. data/lib/rgeo/coord_sys/proj4.rb +85 -85
  35. data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
  36. data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
  37. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
  38. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
  39. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
  40. data/lib/rgeo/error.rb +17 -17
  41. data/lib/rgeo/feature.rb +15 -15
  42. data/lib/rgeo/feature/curve.rb +58 -58
  43. data/lib/rgeo/feature/factory.rb +84 -84
  44. data/lib/rgeo/feature/factory_generator.rb +32 -32
  45. data/lib/rgeo/feature/geometry.rb +215 -215
  46. data/lib/rgeo/feature/geometry_collection.rb +46 -46
  47. data/lib/rgeo/feature/line.rb +21 -21
  48. data/lib/rgeo/feature/line_string.rb +35 -35
  49. data/lib/rgeo/feature/linear_ring.rb +20 -20
  50. data/lib/rgeo/feature/mixins.rb +61 -61
  51. data/lib/rgeo/feature/multi_curve.rb +37 -37
  52. data/lib/rgeo/feature/multi_line_string.rb +20 -20
  53. data/lib/rgeo/feature/multi_point.rb +22 -22
  54. data/lib/rgeo/feature/multi_polygon.rb +28 -28
  55. data/lib/rgeo/feature/multi_surface.rb +39 -39
  56. data/lib/rgeo/feature/point.rb +42 -42
  57. data/lib/rgeo/feature/polygon.rb +50 -50
  58. data/lib/rgeo/feature/surface.rb +42 -42
  59. data/lib/rgeo/feature/types.rb +58 -58
  60. data/lib/rgeo/geographic.rb +14 -14
  61. data/lib/rgeo/geographic/factory.rb +87 -87
  62. data/lib/rgeo/geographic/interface.rb +55 -55
  63. data/lib/rgeo/geographic/proj4_projector.rb +35 -35
  64. data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
  65. data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
  66. data/lib/rgeo/geographic/projected_window.rb +103 -103
  67. data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
  68. data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
  69. data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
  70. data/lib/rgeo/geographic/spherical_math.rb +58 -58
  71. data/lib/rgeo/geos.rb +22 -17
  72. data/lib/rgeo/geos/factory.rb +93 -93
  73. data/lib/rgeo/geos/ffi_classes.rb +306 -231
  74. data/lib/rgeo/geos/ffi_factory.rb +100 -96
  75. data/lib/rgeo/geos/impl_additions.rb +22 -22
  76. data/lib/rgeo/geos/interface.rb +45 -45
  77. data/lib/rgeo/geos/zm_factory.rb +90 -90
  78. data/lib/rgeo/geos/zm_impl.rb +167 -167
  79. data/lib/rgeo/impl_helper.rb +11 -11
  80. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
  81. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
  82. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
  83. data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
  84. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
  85. data/lib/rgeo/impl_helper/math.rb +13 -13
  86. data/lib/rgeo/version.rb +10 -10
  87. data/lib/rgeo/wkrep.rb +16 -16
  88. data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
  89. data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
  90. data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
  91. data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
  92. data/lib/rgeo/yaml.rb +14 -14
  93. data/test/common/geometry_collection_tests.rb +53 -53
  94. data/test/common/line_string_tests.rb +57 -57
  95. data/test/common/multi_line_string_tests.rb +43 -43
  96. data/test/common/multi_point_tests.rb +43 -43
  97. data/test/common/multi_polygon_tests.rb +43 -43
  98. data/test/common/point_tests.rb +75 -75
  99. data/test/common/polygon_tests.rb +37 -37
  100. data/test/coord_sys/tc_active_record_table.rb +25 -25
  101. data/test/coord_sys/tc_ogc_cs.rb +72 -72
  102. data/test/coord_sys/tc_proj4.rb +51 -51
  103. data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
  104. data/test/coord_sys/tc_sr_org.rb +15 -15
  105. data/test/coord_sys/tc_url_reader.rb +19 -19
  106. data/test/geos_capi/tc_factory.rb +21 -21
  107. data/test/geos_capi/tc_geometry_collection.rb +15 -15
  108. data/test/geos_capi/tc_line_string.rb +15 -15
  109. data/test/geos_capi/tc_misc.rb +33 -22
  110. data/test/geos_capi/tc_multi_line_string.rb +15 -15
  111. data/test/geos_capi/tc_multi_point.rb +15 -15
  112. data/test/geos_capi/tc_multi_polygon.rb +15 -15
  113. data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
  114. data/test/geos_capi/tc_point.rb +21 -21
  115. data/test/geos_capi/tc_polygon.rb +19 -19
  116. data/test/geos_capi/tc_zmfactory.rb +17 -17
  117. data/test/geos_ffi/tc_factory.rb +21 -21
  118. data/test/geos_ffi/tc_geometry_collection.rb +15 -15
  119. data/test/geos_ffi/tc_line_string.rb +15 -15
  120. data/test/geos_ffi/tc_misc.rb +49 -15
  121. data/test/geos_ffi/tc_multi_line_string.rb +15 -15
  122. data/test/geos_ffi/tc_multi_point.rb +15 -15
  123. data/test/geos_ffi/tc_multi_polygon.rb +15 -15
  124. data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
  125. data/test/geos_ffi/tc_point.rb +21 -21
  126. data/test/geos_ffi/tc_polygon.rb +19 -19
  127. data/test/geos_ffi/tc_zmfactory.rb +17 -17
  128. data/test/projected_geographic/tc_geometry_collection.rb +15 -15
  129. data/test/projected_geographic/tc_line_string.rb +15 -15
  130. data/test/projected_geographic/tc_multi_line_string.rb +15 -15
  131. data/test/projected_geographic/tc_multi_point.rb +15 -15
  132. data/test/projected_geographic/tc_multi_polygon.rb +15 -15
  133. data/test/projected_geographic/tc_point.rb +23 -23
  134. data/test/projected_geographic/tc_polygon.rb +15 -15
  135. data/test/simple_cartesian/tc_calculations.rb +31 -31
  136. data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
  137. data/test/simple_cartesian/tc_line_string.rb +17 -17
  138. data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
  139. data/test/simple_cartesian/tc_multi_point.rb +17 -17
  140. data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
  141. data/test/simple_cartesian/tc_point.rb +21 -21
  142. data/test/simple_cartesian/tc_polygon.rb +17 -17
  143. data/test/simple_mercator/tc_geometry_collection.rb +15 -15
  144. data/test/simple_mercator/tc_line_string.rb +15 -15
  145. data/test/simple_mercator/tc_multi_line_string.rb +15 -15
  146. data/test/simple_mercator/tc_multi_point.rb +15 -15
  147. data/test/simple_mercator/tc_multi_polygon.rb +15 -15
  148. data/test/simple_mercator/tc_point.rb +23 -23
  149. data/test/simple_mercator/tc_polygon.rb +15 -15
  150. data/test/simple_mercator/tc_window.rb +50 -50
  151. data/test/spherical_geographic/tc_calculations.rb +47 -47
  152. data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
  153. data/test/spherical_geographic/tc_line_string.rb +17 -17
  154. data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
  155. data/test/spherical_geographic/tc_multi_point.rb +17 -17
  156. data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
  157. data/test/spherical_geographic/tc_point.rb +23 -23
  158. data/test/spherical_geographic/tc_polygon.rb +17 -17
  159. data/test/tc_cartesian_analysis.rb +23 -23
  160. data/test/tc_mixins.rb +39 -39
  161. data/test/tc_oneoff.rb +15 -15
  162. data/test/tc_types.rb +17 -17
  163. data/test/wkrep/tc_wkb_generator.rb +67 -67
  164. data/test/wkrep/tc_wkb_parser.rb +73 -73
  165. data/test/wkrep/tc_wkt_generator.rb +75 -75
  166. data/test/wkrep/tc_wkt_parser.rb +97 -97
  167. metadata +3 -3
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Geographic data for RGeo
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,17 +35,17 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
39
-
38
+
39
+
40
40
  # The Geographic implementation actually comprises a suite of
41
41
  # implementations with one common feature: they represent geographic
42
42
  # latitude/longitude coordinates measured in degrees. The "x"
43
43
  # coordinate corresponds to longitude, and the "y" coordinate to
44
44
  # latitude. Thus, coordinates are often expressed in reverse
45
45
  # (i.e. long-lat) order. e.g.
46
- #
46
+ #
47
47
  # location = geographic_factory.point(long, lat)
48
- #
48
+ #
49
49
  # Some geographic implementations include a secondary factory that
50
50
  # represents a projection. For these implementations, you can quickly
51
51
  # transform data between lat/long coordinates and the projected
@@ -54,11 +54,11 @@ module RGeo
54
54
  # secondary projection factory, calculations are done on the sphereoid.
55
55
  # See the various class methods of Geographic for more information on
56
56
  # the behaviors of the factories they generate.
57
-
57
+
58
58
  module Geographic
59
59
  end
60
-
61
-
60
+
61
+
62
62
  end
63
63
 
64
64
 
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Geographic data factory implementation
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,19 +35,19 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Geographic
40
-
41
-
40
+
41
+
42
42
  # This class implements the various factories for geography features.
43
43
  # See methods of the RGeo::Geographic module for the API for creating
44
44
  # geography factories.
45
-
45
+
46
46
  class Factory
47
-
47
+
48
48
  include Feature::Factory::Instance
49
-
50
-
49
+
50
+
51
51
  def initialize(impl_prefix_, opts_={}) # :nodoc:
52
52
  @impl_prefix = impl_prefix_
53
53
  @point_class = Geographic.const_get("#{impl_prefix_}PointImpl")
@@ -74,7 +74,7 @@ module RGeo
74
74
  if @coord_sys.kind_of?(::String)
75
75
  @coord_sys = CoordSys::CS.create_from_wkt(@coord_sys) rescue nil
76
76
  end
77
-
77
+
78
78
  wkt_generator_ = opts_[:wkt_generator]
79
79
  case wkt_generator_
80
80
  when ::Hash
@@ -104,15 +104,15 @@ module RGeo
104
104
  @wkb_parser = WKRep::WKBParser.new(self)
105
105
  end
106
106
  end
107
-
108
-
107
+
108
+
109
109
  def _set_projector(projector_) # :nodoc:
110
110
  @projector = projector_
111
111
  end
112
-
113
-
112
+
113
+
114
114
  # Equivalence test.
115
-
115
+
116
116
  def eql?(rhs_)
117
117
  rhs_.is_a?(Geographic::Factory) &&
118
118
  @impl_prefix == rhs_.instance_variable_get(:@impl_prefix) &&
@@ -121,36 +121,36 @@ module RGeo
121
121
  @proj4 == rhs_.instance_variable_get(:@proj4)
122
122
  end
123
123
  alias_method :==, :eql?
124
-
125
-
124
+
125
+
126
126
  # Returns the srid reported by this factory.
127
-
127
+
128
128
  def srid
129
129
  @srid
130
130
  end
131
-
132
-
131
+
132
+
133
133
  # Returns true if this factory supports a projection.
134
-
134
+
135
135
  def has_projection?
136
136
  !@projector.nil?
137
137
  end
138
-
139
-
138
+
139
+
140
140
  # Returns the factory for the projected coordinate space,
141
141
  # or nil if this factory does not support a projection.
142
-
142
+
143
143
  def projection_factory
144
144
  @projector ? @projector.projection_factory : nil
145
145
  end
146
-
147
-
146
+
147
+
148
148
  # Projects the given geometry into the projected coordinate space,
149
149
  # and returns the projected geometry.
150
150
  # Returns nil if this factory does not support a projection.
151
151
  # Raises Error::InvalidGeometry if the given geometry is not of
152
152
  # this factory.
153
-
153
+
154
154
  def project(geometry_)
155
155
  return nil unless @projector
156
156
  unless geometry_.factory == self
@@ -158,38 +158,38 @@ module RGeo
158
158
  end
159
159
  @projector.project(geometry_)
160
160
  end
161
-
162
-
161
+
162
+
163
163
  # Reverse-projects the given geometry from the projected coordinate
164
164
  # space into lat-long space.
165
165
  # Raises Error::InvalidGeometry if the given geometry is not of
166
166
  # the projection defined by this factory.
167
-
167
+
168
168
  def unproject(geometry_)
169
169
  unless @projector && @projector.projection_factory == geometry_.factory
170
170
  raise Error::InvalidGeometry, 'You can unproject only features that are in the projected coordinate space.'
171
171
  end
172
172
  @projector.unproject(geometry_)
173
173
  end
174
-
175
-
174
+
175
+
176
176
  # Returns true if this factory supports a projection and the
177
177
  # projection wraps its x (easting) direction. For example, a
178
178
  # Mercator projection wraps, but a local projection that is valid
179
179
  # only for a small area does not wrap. Returns nil if this factory
180
180
  # does not support or a projection, or if it is not known whether
181
181
  # or not it wraps.
182
-
182
+
183
183
  def projection_wraps?
184
184
  @projector ? @projector.wraps? : nil
185
185
  end
186
-
187
-
186
+
187
+
188
188
  # Returns a ProjectedWindow specifying the limits of the domain of
189
189
  # the projection space.
190
190
  # Returns nil if this factory does not support a projection, or the
191
191
  # projection limits are not known.
192
-
192
+
193
193
  def projection_limits_window
194
194
  if @projector
195
195
  unless defined?(@projection_limits_window)
@@ -200,10 +200,10 @@ module RGeo
200
200
  nil
201
201
  end
202
202
  end
203
-
204
-
203
+
204
+
205
205
  # See ::RGeo::Feature::Factory#property
206
-
206
+
207
207
  def property(name_)
208
208
  case name_
209
209
  when :has_z_coordinate
@@ -216,101 +216,101 @@ module RGeo
216
216
  nil
217
217
  end
218
218
  end
219
-
220
-
219
+
220
+
221
221
  # See ::RGeo::Feature::Factory#parse_wkt
222
-
222
+
223
223
  def parse_wkt(str_)
224
224
  @wkt_parser.parse(str_)
225
225
  end
226
-
227
-
226
+
227
+
228
228
  # See ::RGeo::Feature::Factory#parse_wkb
229
-
229
+
230
230
  def parse_wkb(str_)
231
231
  @wkb_parser.parse(str_)
232
232
  end
233
-
234
-
233
+
234
+
235
235
  # See ::RGeo::Feature::Factory#point
236
-
236
+
237
237
  def point(x_, y_, *extra_)
238
238
  @point_class.new(self, x_, y_, *extra_) rescue nil
239
239
  end
240
-
241
-
240
+
241
+
242
242
  # See ::RGeo::Feature::Factory#line_string
243
-
243
+
244
244
  def line_string(points_)
245
245
  @line_string_class.new(self, points_) rescue nil
246
246
  end
247
-
248
-
247
+
248
+
249
249
  # See ::RGeo::Feature::Factory#line
250
-
250
+
251
251
  def line(start_, end_)
252
252
  @line_class.new(self, start_, end_) rescue nil
253
253
  end
254
-
255
-
254
+
255
+
256
256
  # See ::RGeo::Feature::Factory#linear_ring
257
-
257
+
258
258
  def linear_ring(points_)
259
259
  @linear_ring_class.new(self, points_) rescue nil
260
260
  end
261
-
262
-
261
+
262
+
263
263
  # See ::RGeo::Feature::Factory#polygon
264
-
264
+
265
265
  def polygon(outer_ring_, inner_rings_=nil)
266
266
  @polygon_class.new(self, outer_ring_, inner_rings_) rescue nil
267
267
  end
268
-
269
-
268
+
269
+
270
270
  # See ::RGeo::Feature::Factory#collection
271
-
271
+
272
272
  def collection(elems_)
273
273
  @geometry_collection_class.new(self, elems_) rescue nil
274
274
  end
275
-
276
-
275
+
276
+
277
277
  # See ::RGeo::Feature::Factory#multi_point
278
-
278
+
279
279
  def multi_point(elems_)
280
280
  @multi_point_class.new(self, elems_) rescue nil
281
281
  end
282
-
283
-
282
+
283
+
284
284
  # See ::RGeo::Feature::Factory#multi_line_string
285
-
285
+
286
286
  def multi_line_string(elems_)
287
287
  @multi_line_string_class.new(self, elems_) rescue nil
288
288
  end
289
-
290
-
289
+
290
+
291
291
  # See ::RGeo::Feature::Factory#multi_polygon
292
-
292
+
293
293
  def multi_polygon(elems_)
294
294
  @multi_polygon_class.new(self, elems_) rescue nil
295
295
  end
296
-
297
-
296
+
297
+
298
298
  # See ::RGeo::Feature::Factory#proj4
299
-
299
+
300
300
  def proj4
301
301
  @proj4
302
302
  end
303
-
304
-
303
+
304
+
305
305
  # See ::RGeo::Feature::Factory#coord_sys
306
-
306
+
307
307
  def coord_sys
308
308
  @coord_sys
309
309
  end
310
-
311
-
310
+
311
+
312
312
  end
313
-
313
+
314
314
  end
315
-
315
+
316
316
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Access to geographic data factories
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,12 +35,12 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Geographic
40
-
40
+
41
41
  class << self
42
-
43
-
42
+
43
+
44
44
  # Creates and returns a geographic factory that does not include a
45
45
  # a projection, and which performs calculations assuming a
46
46
  # spherical earth. In other words, geodesics are treated as great
@@ -50,18 +50,18 @@ module RGeo
50
50
  # the globe in which good accuracy is desired, but in which it is
51
51
  # not deemed necessary to perform the complex ellipsoidal
52
52
  # calculations needed for greater precision.
53
- #
53
+ #
54
54
  # The maximum error is about 0.5 percent, for objects and
55
55
  # calculations that span a significant percentage of the globe, due
56
56
  # to distortion caused by rotational flattening of the earth. For
57
57
  # calculations that span a much smaller area, the error can drop to
58
58
  # a few meters or less.
59
- #
59
+ #
60
60
  # === Limitations
61
- #
61
+ #
62
62
  # This implementation does not implement some of the more advanced
63
63
  # geometric operations. In particular:
64
- #
64
+ #
65
65
  # * Relational operators such as Feature::Geometry#intersects? are
66
66
  # not implemented for most types.
67
67
  # * Relational constructors such as Feature::Geometry#union are
@@ -74,14 +74,14 @@ module RGeo
74
74
  # * Equality and simplicity evaluation are implemented for some but
75
75
  # not all types.
76
76
  # * Assertions for polygons and multipolygons are not implemented.
77
- #
77
+ #
78
78
  # Unimplemented operations will return nil if invoked.
79
- #
79
+ #
80
80
  # === Options
81
- #
81
+ #
82
82
  # You may use the following options when creating a spherical
83
83
  # factory:
84
- #
84
+ #
85
85
  # [<tt>:has_z_coordinate</tt>]
86
86
  # Support a Z coordinate. Default is false.
87
87
  # [<tt>:has_m_coordinate</tt>]
@@ -129,7 +129,7 @@ module RGeo
129
129
  # configuration parameters for WKRep::WKTGenerator.new.
130
130
  # Default is the empty hash, indicating the default configuration
131
131
  # for WKRep::WKBGenerator.
132
-
132
+
133
133
  def spherical_factory(opts_={})
134
134
  proj4_ = opts_[:proj4]
135
135
  coord_sys_ = opts_[:coord_sys]
@@ -149,28 +149,28 @@ module RGeo
149
149
  :coord_sys => coord_sys_ || _coordsys_4055,
150
150
  :srid => (srid_ || 4055).to_i)
151
151
  end
152
-
153
-
152
+
153
+
154
154
  # Creates and returns a geographic factory that is designed for
155
155
  # visualization applications that use Google or Bing maps, or any
156
156
  # other visualization systems that use the same projection. It
157
157
  # includes a projection factory that matches the projection used
158
158
  # by those mapping systems.
159
- #
159
+ #
160
160
  # Like all geographic factories, this one creates features using
161
161
  # latitude-longitude values. However, calculations such as
162
162
  # intersections are done in the projected coordinate system, and
163
163
  # size and distance calculations report results in the projected
164
164
  # units.
165
- #
165
+ #
166
166
  # The behavior of the simple_mercator factory could also be obtained
167
167
  # using a projected_factory with appropriate Proj4 specifications.
168
168
  # However, the simple_mercator implementation is done without
169
169
  # actually requiring the Proj4 library. The projections are simple
170
170
  # enough to be implemented in pure ruby.
171
- #
171
+ #
172
172
  # === About the coordinate system
173
- #
173
+ #
174
174
  # Many popular visualization technologies, such as Google and Bing
175
175
  # maps, actually use two coordinate systems. The first is the
176
176
  # standard WSG84 lat-long system used by the GPS and represented
@@ -179,19 +179,19 @@ module RGeo
179
179
  # Mercator projection based on a "sphericalization" of the WGS84
180
180
  # lat-long system. This projection is the basis of the map's screen
181
181
  # and tiling coordinates, and has been assigned EPSG 3785.
182
- #
182
+ #
183
183
  # This factory represents both coordinate systems. The main factory
184
184
  # produces data in the lat-long system and reports SRID 4326, and
185
185
  # the projected factory produces data in the projection and reports
186
186
  # SRID 3785. Latitudes are restricted to the range
187
187
  # (-85.05112877980659, 85.05112877980659), which conveniently
188
188
  # results in a square projected domain.
189
- #
189
+ #
190
190
  # === Options
191
- #
191
+ #
192
192
  # You may use the following options when creating a simple_mercator
193
193
  # factory:
194
- #
194
+ #
195
195
  # [<tt>:has_z_coordinate</tt>]
196
196
  # Support a Z coordinate. Default is false.
197
197
  # [<tt>:has_m_coordinate</tt>]
@@ -215,14 +215,14 @@ module RGeo
215
215
  # configuration parameters for WKRep::WKTGenerator.new.
216
216
  # Default is the empty hash, indicating the default configuration
217
217
  # for WKRep::WKBGenerator.
218
- #
218
+ #
219
219
  # You may also provide options understood by the underlying
220
220
  # projected Cartesian factory. For example, if GEOS is used for the
221
221
  # projected factory, you may also set the
222
- # <tt>:lenient_multi_polygon_assertions</tt> and
222
+ # <tt>:lenient_multi_polygon_assertions</tt> and
223
223
  # <tt>:buffer_resolution</tt> options. See RGeo::Geos.factory for
224
224
  # more details.
225
-
225
+
226
226
  def simple_mercator_factory(opts_={})
227
227
  factory_ = Geographic::Factory.new('Projected',
228
228
  :proj4 => _proj4_4326,
@@ -238,8 +238,8 @@ module RGeo
238
238
  factory_._set_projector(projector_)
239
239
  factory_
240
240
  end
241
-
242
-
241
+
242
+
243
243
  # Creates and returns a geographic factory that includes a
244
244
  # projection specified by a Proj4 coordinate system. Like all
245
245
  # geographic factories, this one creates features using latitude-
@@ -250,12 +250,12 @@ module RGeo
250
250
  # coordinate systems: the main factory representing the geographic
251
251
  # lat-long coordinate system, and an auxiliary "projection factory"
252
252
  # representing the projected coordinate system.
253
- #
253
+ #
254
254
  # This implementation is intended for advanced GIS applications
255
255
  # requiring greater control over the projection being used.
256
- #
256
+ #
257
257
  # === Options
258
- #
258
+ #
259
259
  # When creating a projected implementation, you must provide enough
260
260
  # information to construct a Proj4 specification for the projection.
261
261
  # Generally, this means you will provide either the projection's
@@ -268,10 +268,10 @@ module RGeo
268
268
  # directly via the <tt>:projection_proj4</tt> option, or indirectly
269
269
  # by providing both an <tt>:srid</tt> and a <tt>:srs_database</tt>
270
270
  # to use to look up the coordinate system.
271
- #
271
+ #
272
272
  # Following are detailed descriptions of the various options you can
273
273
  # pass to this method.
274
- #
274
+ #
275
275
  # [<tt>:projection_factory</tt>]
276
276
  # Specify an existing Cartesian factory to use for the projection.
277
277
  # This factory must have a non-nil Proj4. If this is provided, any
@@ -344,14 +344,14 @@ module RGeo
344
344
  # configuration parameters for WKRep::WKTGenerator.new.
345
345
  # Default is the empty hash, indicating the default configuration
346
346
  # for WKRep::WKBGenerator.
347
- #
347
+ #
348
348
  # If a <tt>:projection_factory</tt> is _not_ provided, you may also
349
349
  # provide options for configuring the projected Cartesian factory.
350
350
  # For example, if GEOS is used for the projected factory, you may
351
- # also set the <tt>:lenient_multi_polygon_assertions</tt> and
351
+ # also set the <tt>:lenient_multi_polygon_assertions</tt> and
352
352
  # <tt>:buffer_resolution</tt> options. See RGeo::Geos.factory for
353
353
  # more details.
354
-
354
+
355
355
  def projected_factory(opts_={})
356
356
  unless CoordSys::Proj4.supported?
357
357
  raise Error::UnsupportedOperation, "Proj4 is not supported because the proj4 library was not found at install time."
@@ -464,42 +464,42 @@ module RGeo
464
464
  factory_._set_projector(projector_)
465
465
  factory_
466
466
  end
467
-
468
-
467
+
468
+
469
469
  def _proj4_4055 # :nodoc:
470
470
  unless defined?(@proj4_4055)
471
471
  @proj4_4055 = CoordSys::Proj4.create('+proj=longlat +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +no_defs')
472
472
  end
473
473
  @proj4_4055
474
474
  end
475
-
476
-
475
+
476
+
477
477
  def _coordsys_4055 # :nodoc:
478
478
  unless defined?(@coordsys_4055)
479
479
  @coordsys_4055 = CoordSys::CS.create_from_wkt('GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]]')
480
480
  end
481
481
  @coordsys_4055
482
482
  end
483
-
484
-
483
+
484
+
485
485
  def _proj4_4326 # :nodoc:
486
486
  unless defined?(@proj4_4326)
487
487
  @proj4_4326 = CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
488
488
  end
489
489
  @proj4_4326
490
490
  end
491
-
492
-
491
+
492
+
493
493
  def _coordsys_4326 # :nodoc:
494
494
  unless defined?(@coordsys_4326)
495
495
  @coordsys_4326 = CoordSys::CS.create_from_wkt('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]')
496
496
  end
497
497
  @coordsys_4326
498
498
  end
499
-
500
-
499
+
500
+
501
501
  end
502
-
502
+
503
503
  end
504
-
504
+
505
505
  end