Module: RGeo::ImplHelper::BasicPointMethods
- Defined in:
- lib/rgeo/impl_helper/basic_point_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #boundary ⇒ Object
- #convex_hull ⇒ Object
- #coordinates ⇒ Object
- #dimension ⇒ Object
- #empty? ⇒ Boolean
- #envelope ⇒ Object
- #equals?(rhs) ⇒ Boolean
- #geometry_type ⇒ Object
- #hash ⇒ Object
- #initialize(factory, x, y, *extra) ⇒ Object
- #m ⇒ Object
- #rep_equals?(rhs) ⇒ Boolean
- #simple? ⇒ Boolean
- #x ⇒ Object
- #y ⇒ Object
- #z ⇒ Object
Instance Method Details
#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
88 89 90 91 92 93 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 88 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 |
#empty? ⇒ Boolean
46 47 48 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 46 def empty? false 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
12 13 14 15 16 17 18 19 20 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 12 def initialize(factory, x, y, *extra) self.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 raise ArgumentError, "Too many arguments for point initializer" unless extra.empty? init_geometry 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 |
#simple? ⇒ Boolean
50 51 52 |
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 50 def simple? true 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 |