rgeo 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.3.8 / 2012-03-23
2
+
3
+ * When using the spherical factory, some negative longitudes might get perturbed slightly due to floating point errors. Fixed. (Reported by Pete Deffendol)
4
+ * Fixed a bunch of warnings, and turned on warnings during testing.
5
+
1
6
  === 0.3.7 / 2012-03-12
2
7
 
3
8
  * Marshal and YAML serialization now fully implemented for geometries.
data/Version CHANGED
@@ -1 +1 @@
1
- 0.3.7
1
+ 0.3.8
@@ -78,7 +78,7 @@ module RGeo
78
78
 
79
79
 
80
80
  def _segments
81
- unless @segments
81
+ unless defined?(@segments)
82
82
  @segments = (0..num_points-2).map do |i_|
83
83
  Segment.new(point_n(i_), point_n(i_+1))
84
84
  end
@@ -101,7 +101,7 @@ module RGeo
101
101
  # Iterates over the known immediate subtypes of this type.
102
102
 
103
103
  def each_immediate_subtype(&block_)
104
- @subtypes.each(&block_) if @subtypes
104
+ @subtypes.each(&block_) if defined?(@subtypes) && @subtypes
105
105
  end
106
106
 
107
107
 
@@ -49,8 +49,10 @@ module RGeo
49
49
 
50
50
 
51
51
  def _validate_geometry
52
- @x = @x % 360.0
53
- @x -= 360.0 if @x >= 180.0
52
+ if @x < -180.0 || @x >= 180.0
53
+ @x = @x % 360.0
54
+ @x -= 360.0 if @x >= 180.0
55
+ end
54
56
  @y = 90.0 if @y > 90.0
55
57
  @y = -90.0 if @y < -90.0
56
58
  super
@@ -54,7 +54,7 @@ module RGeo
54
54
 
55
55
 
56
56
  def _arcs
57
- unless @arcs
57
+ unless defined?(@arcs)
58
58
  @arcs = (0..num_points-2).map do |i_|
59
59
  SphericalMath::ArcXYZ.new(point_n(i_)._xyz, point_n(i_+1)._xyz)
60
60
  end
@@ -431,7 +431,7 @@ module RGeo
431
431
  def override_cast(original_, ntype_, flags_)
432
432
  return nil unless Geos.supported?
433
433
  keep_subtype_ = flags_[:keep_subtype]
434
- force_new_ = flags_[:force_new]
434
+ #force_new_ = flags_[:force_new]
435
435
  project_ = flags_[:project]
436
436
  type_ = original_.geometry_type
437
437
  ntype_ = type_ if keep_subtype_ && type_.include?(ntype_)
@@ -465,7 +465,6 @@ module RGeo
465
465
 
466
466
  def multi_point(elems_)
467
467
  elems_ = elems_.to_a unless elems_.kind_of?(::Array)
468
- fg_geoms_ = []
469
468
  elems_.map! do |elem_|
470
469
  elem_ = ::RGeo::Feature.cast(elem_, self, ::RGeo::Feature::Point,
471
470
  :force_new, :keep_subtype)
@@ -378,7 +378,7 @@ module RGeo
378
378
  def override_cast(original_, ntype_, flags_)
379
379
  return nil unless Geos.supported?
380
380
  keep_subtype_ = flags_[:keep_subtype]
381
- force_new_ = flags_[:force_new]
381
+ #force_new_ = flags_[:force_new]
382
382
  project_ = flags_[:project]
383
383
  type_ = original_.geometry_type
384
384
  ntype_ = type_ if keep_subtype_ && type_.include?(ntype_)
@@ -231,7 +231,6 @@ module RGeo
231
231
  end
232
232
 
233
233
  def marshal_load(data_) # :nodoc:
234
- obj_ = data_[0]._marshal_wkb_parser.parse(data_[1])
235
234
  _copy_state_from(data_[0]._marshal_wkb_parser.parse(data_[1]))
236
235
  end
237
236
 
@@ -76,7 +76,7 @@ module RGeo
76
76
 
77
77
 
78
78
  def dimension
79
- unless @dimension
79
+ unless defined?(@dimension)
80
80
  @dimension = -1
81
81
  @elements.each do |elem_|
82
82
  dim_ = elem_.dimension
@@ -87,7 +87,6 @@ module RGeo
87
87
  end
88
88
 
89
89
  def marshal_load(data_) # :nodoc:
90
- obj_ = data_[0]._marshal_wkb_parser.parse(data_[1])
91
90
  _copy_state_from(data_[0]._marshal_wkb_parser.parse(data_[1]))
92
91
  end
93
92
 
@@ -94,7 +94,8 @@ module RGeo
94
94
 
95
95
  def initialize(opts_={})
96
96
  @type_format = opts_[:type_format] || :wkb11
97
- @emit_ewkb_srid = opts_[:emit_ewkb_srid] ? true : false if @type_format == :ewkb
97
+ @emit_ewkb_srid = @type_format == :ewkb ?
98
+ (opts_[:emit_ewkb_srid] ? true : false) : nil
98
99
  @hex_format = opts_[:hex_format] ? true : false
99
100
  @little_endian = opts_[:little_endian] ? true : false
100
101
  end
@@ -85,7 +85,8 @@ module RGeo
85
85
 
86
86
  def initialize(opts_={})
87
87
  @tag_format = opts_[:tag_format] || opts_[:type_format] || :wkt11
88
- @emit_ewkt_srid = opts_[:emit_ewkt_srid] ? true : false if @tag_format == :ewkt
88
+ @emit_ewkt_srid = @tag_format == :ewkt ?
89
+ (opts_[:emit_ewkt_srid] ? true : false) : nil
89
90
  @square_brackets = opts_[:square_brackets] ? true : false
90
91
  @convert_case = opts_[:convert_case]
91
92
  end
@@ -228,7 +228,7 @@ module RGeo
228
228
  expect_m_ = zm_[-1,1] == 'm' ? true : false
229
229
  if @cur_expect_m.nil?
230
230
  @cur_expect_m = expect_m_
231
- else expect_m_ != @cur_expect_m
231
+ elsif expect_m_ != @cur_expect_m
232
232
  raise Error::ParseError, "Surrounding collection has M but contained geometry doesn't."
233
233
  end
234
234
  if creating_expectation_
@@ -80,6 +80,15 @@ module RGeo
80
80
  end
81
81
 
82
82
 
83
+ def test_floating_point_perturbation
84
+ # A naive way of wrapping longitudes to [-180,180] might cause
85
+ # perturbation due to floating point errors. Make sure this
86
+ # doesn't happen.
87
+ point_ = @factory.point(-98.747534, 38.057583)
88
+ assert_equal(-98.747534, point_.x)
89
+ end
90
+
91
+
83
92
  undef_method :test_disjoint
84
93
  undef_method :test_intersects
85
94
  undef_method :test_touches
@@ -136,7 +136,7 @@ module RGeo
136
136
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
137
137
  parser_ = ::RGeo::WKRep::WKBParser.new(factory_)
138
138
  assert_raise(::RGeo::Error::ParseError) do
139
- obj_ = parser_.parse('00000003e93ff000000000000040000000000000004008000000000000')
139
+ parser_.parse('00000003e93ff000000000000040000000000000004008000000000000')
140
140
  end
141
141
  end
142
142
 
@@ -145,7 +145,7 @@ module RGeo
145
145
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
146
146
  parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
147
147
  assert_raise(::RGeo::Error::ParseError) do
148
- obj_ = parser_.parse('00000003e93ff00000000000004000000000000000')
148
+ parser_.parse('00000003e93ff00000000000004000000000000000')
149
149
  end
150
150
  end
151
151
 
@@ -273,7 +273,7 @@ module RGeo
273
273
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
274
274
  parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
275
275
  assert_raise(::RGeo::Error::ParseError) do
276
- obj_ = parser_.parse('00800000040000000200800000013ff000000000000040000000000000004014000000000000000000000140080000000000004010000000000000')
276
+ parser_.parse('00800000040000000200800000013ff000000000000040000000000000004014000000000000000000000140080000000000004010000000000000')
277
277
  end
278
278
  end
279
279
 
@@ -299,7 +299,7 @@ module RGeo
299
299
  def test_multilinestring_wrong_element_type
300
300
  parser_ = ::RGeo::WKRep::WKBParser.new
301
301
  assert_raise(::RGeo::Error::ParseError) do
302
- obj_ = parser_.parse('0000000005000000020000000002000000033ff00000000000004000000000000000400800000000000040100000000000004014000000000000401800000000000000000000013ff00000000000004000000000000000')
302
+ parser_.parse('0000000005000000020000000002000000033ff00000000000004000000000000000400800000000000040100000000000004014000000000000401800000000000000000000013ff00000000000004000000000000000')
303
303
  end
304
304
  end
305
305
 
@@ -124,7 +124,7 @@ module RGeo
124
124
  factory_ = ::RGeo::Cartesian.preferred_factory
125
125
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
126
126
  assert_raise(::RGeo::Error::ParseError) do
127
- obj_ = parser_.parse('POINT(1 2 3)')
127
+ parser_.parse('POINT(1 2 3)')
128
128
  end
129
129
  end
130
130
 
@@ -143,7 +143,7 @@ module RGeo
143
143
  factory_ = ::RGeo::Cartesian.preferred_factory
144
144
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
145
145
  assert_raise(::RGeo::Error::ParseError) do
146
- obj_ = parser_.parse('POINT Z(1 2 3)')
146
+ parser_.parse('POINT Z(1 2 3)')
147
147
  end
148
148
  end
149
149
 
@@ -172,7 +172,7 @@ module RGeo
172
172
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
173
173
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
174
174
  assert_raise(::RGeo::Error::ParseError) do
175
- obj_ = parser_.parse('POINT M(1 2 3 4)')
175
+ parser_.parse('POINT M(1 2 3 4)')
176
176
  end
177
177
  end
178
178
 
@@ -191,7 +191,7 @@ module RGeo
191
191
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
192
192
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
193
193
  assert_raise(::RGeo::Error::ParseError) do
194
- obj_ = parser_.parse('POINT ZM(1 2 3)')
194
+ parser_.parse('POINT ZM(1 2 3)')
195
195
  end
196
196
  end
197
197
 
@@ -230,7 +230,7 @@ module RGeo
230
230
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
231
231
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
232
232
  assert_raise(::RGeo::Error::ParseError) do
233
- obj_ = parser_.parse('POINTM(1 2 3 4)')
233
+ parser_.parse('POINTM(1 2 3 4)')
234
234
  end
235
235
  end
236
236
 
@@ -239,7 +239,7 @@ module RGeo
239
239
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
240
240
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :strict_wkt11 => true)
241
241
  assert_raise(::RGeo::Error::ParseError) do
242
- obj_ = parser_.parse('POINT(1 2 3)')
242
+ parser_.parse('POINT(1 2 3)')
243
243
  end
244
244
  end
245
245
 
@@ -247,7 +247,7 @@ module RGeo
247
247
  def test_point_non_ewkt_with_srid
248
248
  parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory))
249
249
  assert_raise(::RGeo::Error::ParseError) do
250
- obj_ = parser_.parse('SRID=1000;POINT(1 2)')
250
+ parser_.parse('SRID=1000;POINT(1 2)')
251
251
  end
252
252
  end
253
253
 
@@ -278,7 +278,7 @@ module RGeo
278
278
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
279
279
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
280
280
  assert_raise(::RGeo::Error::ParseError) do
281
- obj_ = parser_.parse('LINESTRING(1 2 3, 4 5,7 8 9)')
281
+ parser_.parse('LINESTRING(1 2 3, 4 5,7 8 9)')
282
282
  end
283
283
  end
284
284
 
@@ -461,7 +461,7 @@ module RGeo
461
461
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
462
462
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
463
463
  assert_raise(::RGeo::Error::ParseError) do
464
- obj_ = parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2 0, 3 4 0, 5 6 0))')
464
+ parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2 0, 3 4 0, 5 6 0))')
465
465
  end
466
466
  end
467
467
 
@@ -470,7 +470,7 @@ module RGeo
470
470
  factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
471
471
  parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
472
472
  assert_raise(::RGeo::Error::ParseError) do
473
- obj_ = parser_.parse('GEOMETRYCOLLECTION Z(POINT Z(-1 -2 0),LINESTRING M(1 2 0, 3 4 0, 5 6 0))')
473
+ parser_.parse('GEOMETRYCOLLECTION Z(POINT Z(-1 -2 0),LINESTRING M(1 2 0, 3 4 0, 5 6 0))')
474
474
  end
475
475
  end
476
476
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-03-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: RGeo is a geospatial data library for Ruby. It provides an implementation
15
15
  of the Open Geospatial Consortium's Simple Features Specification, used by most
@@ -219,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  version: 1.3.1
220
220
  requirements: []
221
221
  rubyforge_project: virtuoso
222
- rubygems_version: 1.8.17
222
+ rubygems_version: 1.8.19
223
223
  signing_key:
224
224
  specification_version: 3
225
225
  summary: RGeo is a geospatial data library for Ruby.