Module: RGeo::ImplHelper::BasicPointMethods

Included in:
Cartesian::PointImpl, Geographic::ProjectedPointImpl, Geographic::SphericalPointImpl
Defined in:
lib/rgeo/impl_helper/basic_point_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#boundary ⇒ Object



108
109
110
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 108

def boundary
  factory.collection([])
end

#convex_hull ⇒ Object



113
114
115
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 113

def convex_hull
  self
end

#dimension ⇒ Object



83
84
85
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 83

def dimension
  0
end

#envelope ⇒ Object



103
104
105
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 103

def envelope
  self
end

#eql?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 78

def eql?(rhs_)
  rhs_.is_a?(self.class) && rhs_.factory.eql?(@factory) && @x == rhs_.x && @y == rhs_.y && @z == rhs_.z && @m == rhs_.m
end

#equals?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 118

def equals?(rhs_)
  return false unless rhs_.is_a?(self.class) && rhs_.factory == self.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



88
89
90
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 88

def geometry_type
  Feature::Point
end

#initialize(factory_, x_, y_, *extra_) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 45

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

Returns:

  • (Boolean)


93
94
95
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 93

def is_empty?
  false
end

#is_simple? ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 98

def is_simple?
  true
end

#m ⇒ Object



73
74
75
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 73

def m
  @m
end

#x ⇒ Object



58
59
60
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 58

def x
  @x
end

#y ⇒ Object



63
64
65
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 63

def y
  @y
end

#z ⇒ Object



68
69
70
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 68

def z
  @z
end