Module: RGeo::ImplHelper::BasicPointMethods
- Defined in:
- lib/rgeo/impl_helper/basic_point_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#_copy_state_from(obj_) ⇒ Object
:nodoc:.
- #boundary ⇒ Object
- #convex_hull ⇒ Object
- #coordinates ⇒ Object
- #dimension ⇒ Object
- #envelope ⇒ Object
- #equals?(rhs_) ⇒ Boolean
- #geometry_type ⇒ Object
- #hash ⇒ Object
- #initialize(factory_, x_, y_, *extra_) ⇒ Object
- #is_empty? ⇒ Boolean
- #is_simple? ⇒ Boolean
- #m ⇒ Object
- #rep_equals?(rhs_) ⇒ Boolean
- #x ⇒ Object
- #y ⇒ Object
- #z ⇒ Object
Instance Method Details
#_copy_state_from(obj_) ⇒ Object
:nodoc:
88 89 90 91 92 93 94 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 88 def _copy_state_from(obj_) # :nodoc: super @x = obj_.x @y = obj_.y @z = obj_.z @m = obj_.m end |
#boundary ⇒ Object
58 59 60 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 58 def boundary factory.collection([]) end |
#convex_hull ⇒ Object
62 63 64 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 62 def convex_hull self end |
#coordinates ⇒ Object
96 97 98 99 100 101 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 96 def coordinates [x, y].tap do |coords| coords << z if factory.property(:has_z_coordinate) coords << m if factory.property(:has_m_coordinate) end end |
#dimension ⇒ Object
38 39 40 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 38 def dimension 0 end |
#envelope ⇒ Object
54 55 56 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 54 def envelope self end |
#equals?(rhs_) ⇒ Boolean
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 66 def equals?(rhs_) return false unless rhs_.is_a?(self.class) && rhs_.factory == factory case rhs_ when Feature::Point rhs_.x == @x && rhs_.y == @y when Feature::LineString rhs_.num_points > 0 && rhs_.points.all? { |elem_| equals?(elem_) } when Feature::GeometryCollection rhs_.num_geometries > 0 && rhs_.all? { |elem_| equals?(elem_) } else false end end |
#geometry_type ⇒ Object
42 43 44 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 42 def geometry_type Feature::Point end |
#hash ⇒ Object
84 85 86 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 84 def hash @hash ||= [factory, geometry_type, @x, @y, @z, @m].hash end |
#initialize(factory_, x_, y_, *extra_) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 10 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 _validate_geometry end |
#is_empty? ⇒ Boolean
46 47 48 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 46 def is_empty? false end |
#is_simple? ⇒ Boolean
50 51 52 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 50 def is_simple? true end |
#m ⇒ Object
34 35 36 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 34 def m @m end |
#rep_equals?(rhs_) ⇒ Boolean
80 81 82 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 80 def rep_equals?(rhs_) rhs_.is_a?(self.class) && rhs_.factory.eql?(@factory) && @x == rhs_.x && @y == rhs_.y && @z == rhs_.z && @m == rhs_.m end |
#x ⇒ Object
22 23 24 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 22 def x @x end |
#y ⇒ Object
26 27 28 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 26 def y @y end |
#z ⇒ Object
30 31 32 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 30 def z @z end |