Permalink
Browse files

Allow extra co-ordinate values to be stored, to support the extra values

allowed in the GeoJSON spec.
  • Loading branch information...
lukeredpath committed Aug 30, 2011
1 parent 8bb6920 commit 11370d546b16604c8ff1d09d4c704bde5e3c2d68
Showing with 12 additions and 3 deletions.
  1. +2 −3 lib/rgeo/impl_helper/basic_point_methods.rb
  2. +10 −0 test/common/point_tests.rb
@@ -41,16 +41,15 @@ module ImplHelper # :nodoc:
module BasicPointMethods # :nodoc:
+ attr_reader :extra
def initialize(factory_, x_, y_, *extra_)
_set_factory(factory_)
@x = x_.to_f
@y = y_.to_f
@z = factory_.property(:has_z_coordinate) ? extra_.shift.to_f : nil
@m = factory_.property(:has_m_coordinate) ? extra_.shift.to_f : nil
- if extra_.size > 0
- raise ::ArgumentError, "Too many arguments for point initializer"
- end
+ @extra = extra_
_validate_geometry
end
View
@@ -318,6 +318,16 @@ def test_4d_creation
end
+ def test_creation_with_extra_values
+ point_ = @zmfactory.point(11, 12, 13, 14, 15, 16, 17)
+ assert_equal(11, point_.x)
+ assert_equal(12, point_.y)
+ assert_equal(13, point_.z)
+ assert_equal(14, point_.m)
+ assert_equal([15, 16, 17], point_.extra)
+ end
+
+
def test_wkt_creation_3d
point2_ = @zfactory.parse_wkt('POINT(11 12 13)')
assert_equal(11, point2_.x)

0 comments on commit 11370d5

Please sign in to comment.