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

#boundaryObject


60
61
62
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 60

def boundary
  factory.collection([])
end

#convex_hullObject


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

def convex_hull
  self
end

#coordinatesObject


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

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

#dimensionObject


40
41
42
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 40

def dimension
  0
end

#envelopeObject


56
57
58
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 56

def envelope
  self
end

#equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 68

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_typeObject


44
45
46
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 44

def geometry_type
  Feature::Point
end

#hashObject


86
87
88
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 86

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
21
22
# 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
  if extra.size > 0
    raise ArgumentError, "Too many arguments for point initializer"
  end
  validate_geometry
end

#is_empty?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 48

def is_empty?
  false
end

#is_simple?Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 52

def is_simple?
  true
end

#mObject


36
37
38
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 36

def m
  @m
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

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

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


24
25
26
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 24

def x
  @x
end

#yObject


28
29
30
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 28

def y
  @y
end

#zObject


32
33
34
# File 'lib/rgeo/impl_helper/basic_point_methods.rb', line 32

def z
  @z
end