rgeo 0.3.3 → 0.3.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 (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
  # A projected window in a geography 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,29 +35,29 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Geographic
40
-
41
-
40
+
41
+
42
42
  # This object represents an axis-aligned rectangle in a map projection
43
43
  # coordinate system. It is commonly used to specify the viewport for a
44
44
  # map visualization, an envelope in a projected coordinate system, or
45
45
  # a spatial constraint. It must be attached to a Geographic::Factory
46
46
  # that has a projection.
47
-
47
+
48
48
  class ProjectedWindow
49
-
50
-
49
+
50
+
51
51
  # Create a new ProjectedWindow given the Geographic::Factory, and the
52
52
  # x and y extents of the rectangle.
53
- #
53
+ #
54
54
  # The window will be intelligently clamped to the limits imposed by
55
55
  # the factory. For example, the simple mercator factory limits
56
56
  # latitude to approximately +/-85 degrees.
57
- #
57
+ #
58
58
  # Generally, you will not need to call this low-level constructor
59
59
  # directly. Instead, use one of the provided class methods.
60
-
60
+
61
61
  def initialize(factory_, x_min_, y_min_, x_max_, y_max_, opts_={})
62
62
  @factory = factory_
63
63
  limits_ = opts_[:is_limits] ? nil : factory_.projection_limits_window
@@ -88,84 +88,84 @@ module RGeo
88
88
  @x_max = x_max_
89
89
  @y_max = y_max_
90
90
  end
91
-
92
-
91
+
92
+
93
93
  def to_s # :nodoc:
94
94
  "#<#{self.class}:0x#{object_id.to_s(16)} s=#{@y_min} w=#{@x_min} n=#{@y_max} e=#{@x_max}>"
95
95
  end
96
-
96
+
97
97
  def inspect # :nodoc:
98
98
  to_s
99
99
  end
100
-
101
-
100
+
101
+
102
102
  def eql?(obj_) # :nodoc:
103
103
  return false unless obj_.kind_of?(ProjectedWindow)
104
104
  @factory == obj_.factory && @x_min == obj_.x_min && @x_max == obj_.x_max &&
105
105
  @y_min = obj_.y_min && @y_max = obj_.y_max
106
106
  end
107
107
  alias_method :==, :eql?
108
-
108
+
109
109
  def hash # :nodoc:
110
110
  @factory.hash + @x_min.hash + @x_max.hash + @y_min.hash + @y_max.hash
111
111
  end
112
-
113
-
112
+
113
+
114
114
  # Returns the Geographic::Factory associated with this window.
115
115
  # Note that this factory is the overall geography factory, not the
116
116
  # projected factory (which can be obtained by calling
117
117
  # Geographic::Factory#projection_factory on this factory).
118
-
118
+
119
119
  def factory
120
120
  @factory
121
121
  end
122
-
123
-
122
+
123
+
124
124
  # Returns the lower limit in the x (easting) direction.
125
-
125
+
126
126
  def x_min
127
127
  @x_min
128
128
  end
129
-
130
-
129
+
130
+
131
131
  # Returns the upper limit in the x (easting) direction.
132
-
132
+
133
133
  def x_max
134
134
  @x_max
135
135
  end
136
-
137
-
136
+
137
+
138
138
  # Returns the lower limit in the y (northing) direction.
139
-
139
+
140
140
  def y_min
141
141
  @y_min
142
142
  end
143
-
144
-
143
+
144
+
145
145
  # Returns the upper limit in the y (northing) direction.
146
-
146
+
147
147
  def y_max
148
148
  @y_max
149
149
  end
150
-
151
-
150
+
151
+
152
152
  # Returns true if the projection wraps along the x axis, and this
153
153
  # rectangle crosses that seam.
154
-
154
+
155
155
  def crosses_seam?
156
156
  @x_max < @x_min
157
157
  end
158
-
159
-
158
+
159
+
160
160
  # Returns true if the rectangle has zero area.
161
-
161
+
162
162
  def degenerate?
163
163
  @x_min == @x_max || @y_min == @y_max
164
164
  end
165
-
166
-
165
+
166
+
167
167
  # Returns the width of the rectangle.
168
-
168
+
169
169
  def x_span
170
170
  span_ = @x_max - @x_min
171
171
  if span_ < 0
@@ -174,19 +174,19 @@ module RGeo
174
174
  span_
175
175
  end
176
176
  alias_method :width, :x_span
177
-
178
-
177
+
178
+
179
179
  # Returns the height of the rectangle.
180
-
180
+
181
181
  def y_span
182
182
  @y_max - @y_min
183
183
  end
184
184
  alias_method :height, :x_span
185
-
186
-
185
+
186
+
187
187
  # Returns a two-element array containing the x and y coordinates
188
188
  # of the center of the rectangle.
189
-
189
+
190
190
  def center_xy
191
191
  y_ = (@y_min + @y_max) * 0.5
192
192
  if @x_min > @x_max
@@ -198,51 +198,51 @@ module RGeo
198
198
  end
199
199
  [x_, y_]
200
200
  end
201
-
202
-
201
+
202
+
203
203
  # Returns the southwest corner of the rectangle in _unprojected_
204
204
  # (lat/lng) space, as a Feature::Point object.
205
-
205
+
206
206
  def sw_point
207
207
  @sw ||= @factory.unproject(@factory.projection_factory.point(@x_min, @y_min))
208
208
  end
209
-
210
-
209
+
210
+
211
211
  # Returns the southeast corner of the rectangle in _unprojected_
212
212
  # (lat/lng) space, as a Feature::Point object.
213
-
213
+
214
214
  def se_point
215
215
  @se ||= @factory.unproject(@factory.projection_factory.point(@x_max, @y_min))
216
216
  end
217
-
218
-
217
+
218
+
219
219
  # Returns the northwest corner of the rectangle in _unprojected_
220
220
  # (lat/lng) space, as a Feature::Point object.
221
-
221
+
222
222
  def nw_point
223
223
  @nw ||= @factory.unproject(@factory.projection_factory.point(@x_min, @y_max))
224
224
  end
225
-
226
-
225
+
226
+
227
227
  # Returns the northeast corner of the rectangle in _unprojected_
228
228
  # (lat/lng) space, as a Feature::Point object.
229
-
229
+
230
230
  def ne_point
231
231
  @ne ||= @factory.unproject(@factory.projection_factory.point(@x_max, @y_max))
232
232
  end
233
-
234
-
233
+
234
+
235
235
  # Returns the center of the rectangle in _unprojected_
236
236
  # (lat/lng) space, as a Feature::Point object.
237
-
237
+
238
238
  def center_point
239
239
  @center ||= @factory.unproject(@factory.projection_factory.point(*center_xy))
240
240
  end
241
-
242
-
241
+
242
+
243
243
  # Returns a random point the rectangle in _unprojected_
244
244
  # (lat/lng) space, as a Feature::Point object.
245
-
245
+
246
246
  def random_point
247
247
  y_ = @y_min + (@y_max - @y_min) * rand
248
248
  if @x_min > @x_max
@@ -254,11 +254,11 @@ module RGeo
254
254
  end
255
255
  @factory.unproject(@factory.projection_factory.point(x_, y_))
256
256
  end
257
-
258
-
257
+
258
+
259
259
  # Returns true if the rectangle contains the given point, which
260
260
  # must be a Feature::Point in _unprojected_ (lat/lng) space.
261
-
261
+
262
262
  def contains_point?(point_)
263
263
  projection_ = @factory.project(point_)
264
264
  y_ = projection_.y
@@ -277,11 +277,11 @@ module RGeo
277
277
  false
278
278
  end
279
279
  end
280
-
281
-
280
+
281
+
282
282
  # Returns true if the given window is completely contained within
283
283
  # this window.
284
-
284
+
285
285
  def contains_window?(window_)
286
286
  return nil if window_.factory != @factory
287
287
  if window_.y_max <= @y_max && window_.y_min >= @y_min
@@ -294,13 +294,13 @@ module RGeo
294
294
  false
295
295
  end
296
296
  end
297
-
298
-
297
+
298
+
299
299
  # Returns a new window resulting from scaling this window by the
300
300
  # given factors, which must be floating-point values.
301
301
  # If y_factor is not explicitly given, it defaults to the same as
302
302
  # the x_factor.
303
-
303
+
304
304
  def scaled_by(x_factor_, y_factor_=nil)
305
305
  y_factor_ ||= x_factor_
306
306
  if x_factor_ != 1.0 || y_factor_ != 1.0
@@ -313,14 +313,14 @@ module RGeo
313
313
  end
314
314
  end
315
315
  alias_method :*, :scaled_by
316
-
317
-
316
+
317
+
318
318
  # Returns a new window resulting from clamping this window to the
319
319
  # given minimum and maximum widths and heights, in the projected
320
320
  # coordinate system. The center of the resulting window is the
321
321
  # same as the center of this window. Any of the arguments may be
322
322
  # given as nil, indicating no constraint.
323
-
323
+
324
324
  def clamped_by(min_width_, min_height_, max_width_, max_height_)
325
325
  xr_ = x_span
326
326
  yr_ = y_span
@@ -350,13 +350,13 @@ module RGeo
350
350
  self
351
351
  end
352
352
  end
353
-
354
-
353
+
354
+
355
355
  # Returns a new window resulting from adding the given margin to
356
356
  # this window. If y_margin is not given, it defaults to the same
357
357
  # value as x_margin. Note that the margins may be negative to
358
358
  # indicate shrinking of the window.
359
-
359
+
360
360
  def with_margin(x_margin_, y_margin_=nil)
361
361
  y_margin_ ||= x_margin_
362
362
  if x_margin_ != 0.0 || y_margin_ != 0.0
@@ -366,29 +366,29 @@ module RGeo
366
366
  self
367
367
  end
368
368
  end
369
-
370
-
369
+
370
+
371
371
  class << self
372
-
373
-
372
+
373
+
374
374
  # Creates a new window whose coordinates are the given points,
375
375
  # which must be Feature::Point objects in unprojected (lat/lng)
376
376
  # space.
377
-
377
+
378
378
  def for_corners(sw_, ne_)
379
379
  factory_ = sw_.factory
380
380
  psw_ = factory_.project(sw_)
381
381
  pne_ = factory_.project(ne_)
382
382
  ProjectedWindow.new(factory_, psw_.x, psw_.y, pne_.x, pne_.y)
383
383
  end
384
-
385
-
384
+
385
+
386
386
  # Creates a new window that surrounds the given point with the
387
387
  # given margin. The point must be a Feature::Point object in
388
388
  # unprojected (lat/lng) space, while the margins are numbers in
389
389
  # projected space. The y_margin may be given as nil, in which
390
390
  # case it is set to the same as the x_margin.
391
-
391
+
392
392
  def surrounding_point(point_, x_margin_=nil, y_margin_=nil)
393
393
  x_margin_ ||= 0.0
394
394
  y_margin_ ||= x_margin_
@@ -397,12 +397,12 @@ module RGeo
397
397
  ProjectedWindow.new(factory_, projection_.x - x_margin_, projection_.y - y_margin_,
398
398
  projection_.x + x_margin_, projection_.y + y_margin_)
399
399
  end
400
-
401
-
400
+
401
+
402
402
  # Creates a new window that contains all of the given points.
403
403
  # which must be Feature::Point objects in unprojected (lat/lng)
404
404
  # space.
405
-
405
+
406
406
  def bounding_points(points_)
407
407
  factory_ = nil
408
408
  limits_ = nil
@@ -456,14 +456,14 @@ module RGeo
456
456
  end
457
457
  ProjectedWindow.new(factory_, x_min_, y_min_, x_max_, y_max_)
458
458
  end
459
-
460
-
459
+
460
+
461
461
  end
462
-
463
-
462
+
463
+
464
464
  end
465
-
466
-
465
+
466
+
467
467
  end
468
-
468
+
469
469
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Simple mercator projection
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,15 +35,15 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Geographic
40
-
41
-
40
+
41
+
42
42
  class SimpleMercatorProjector # :nodoc:
43
-
43
+
44
44
  EQUATORIAL_RADIUS = 6378137.0
45
-
46
-
45
+
46
+
47
47
  def initialize(geography_factory_, opts_={})
48
48
  @geography_factory = geography_factory_
49
49
  @projection_factory = Cartesian.preferred_factory(:srid => 3785,
@@ -54,13 +54,13 @@ module RGeo
54
54
  :has_z_coordinate => opts_[:has_z_coordinate],
55
55
  :has_m_coordinate => opts_[:has_m_coordinate])
56
56
  end
57
-
58
-
57
+
58
+
59
59
  def projection_factory
60
60
  @projection_factory
61
61
  end
62
-
63
-
62
+
63
+
64
64
  def project(geometry_)
65
65
  case geometry_
66
66
  when Feature::Point
@@ -89,8 +89,8 @@ module RGeo
89
89
  nil
90
90
  end
91
91
  end
92
-
93
-
92
+
93
+
94
94
  def unproject(geometry_)
95
95
  case geometry_
96
96
  when Feature::Point
@@ -119,39 +119,39 @@ module RGeo
119
119
  nil
120
120
  end
121
121
  end
122
-
123
-
122
+
123
+
124
124
  def wraps?
125
125
  true
126
126
  end
127
-
128
-
127
+
128
+
129
129
  def limits_window
130
130
  @limits_window ||= ProjectedWindow.new(@geography_factory,
131
131
  -20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789,
132
132
  :is_limits => true)
133
133
  end
134
-
135
-
134
+
135
+
136
136
  def self._proj4_3785 # :nodoc:
137
137
  unless defined?(@proj4_3785)
138
138
  @proj4_3785 = CoordSys::Proj4.create('+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs')
139
139
  end
140
140
  @proj4_3785
141
141
  end
142
-
143
-
142
+
143
+
144
144
  def self._coordsys_3785 # :nodoc:
145
145
  unless defined?(@coordsys_3785)
146
146
  @coordsys_3785 = CoordSys::CS.create_from_wkt('PROJCS["Popular Visualisation CRS / Mercator",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"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","3785"],AXIS["X",EAST],AXIS["Y",NORTH]]')
147
147
  end
148
148
  @coordsys_3785
149
149
  end
150
-
151
-
150
+
151
+
152
152
  end
153
-
154
-
153
+
154
+
155
155
  end
156
-
156
+
157
157
  end