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

#_copy_state_from(obj_) ⇒ Object

:nodoc:


138
139
140
141
142
143
144
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 138

def _copy_state_from(obj_)  # :nodoc:
  super
  @x = obj_.x
  @y = obj_.y
  @z = obj_.z
  @m = obj_.m
end

#boundaryObject


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

def boundary
  factory.collection([])
end

#convex_hullObject


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

def convex_hull
  self
end

#dimensionObject


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

def dimension
  0
end

#envelopeObject


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

def envelope
  self
end

#equals?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)

113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 113

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_typeObject


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

def geometry_type
  Feature::Point
end

#hashObject


133
134
135
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 133

def hash
  @hash ||= [factory, geometry_type, @x, @y, @z, @m].hash
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)

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

def is_empty?
  false
end

#is_simple?Boolean

Returns:

  • (Boolean)

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

def is_simple?
  true
end

#mObject


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

def m
  @m
end

#rep_equals?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)

128
129
130
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 128

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

#xObject


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

def x
  @x
end

#yObject


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

def y
  @y
end

#zObject


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

def z
  @z
end