Module: RGeo::Cartesian::PointMethods

Included in:
PointImpl
Defined in:
lib/rgeo/cartesian/feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#buffer(distance_) ⇒ Object


74
75
76
77
78
79
80
81
82
# File 'lib/rgeo/cartesian/feature_methods.rb', line 74

def buffer(distance_)
  point_count_ = factory.property(:buffer_resolution) * 4
  angle_ = -::Math::PI * 2.0 / point_count_
  points_ = (0...point_count_).map do |i_|
    r_ = angle_ * i_
    factory.point(@x + distance_ * ::Math.cos(r_), @y + distance_ * ::Math.sin(r_))
  end
  factory.polygon(factory.linear_ring(points_))
end

#distance(rhs_) ⇒ Object


61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rgeo/cartesian/feature_methods.rb', line 61

def distance(rhs_)
  rhs_ = ::RGeo::Feature.cast(rhs_, @factory)
  case rhs_
  when PointImpl
    dx_ = @x - rhs_.x
    dy_ = @y - rhs_.y
    ::Math.sqrt(dx_ * dx_ + dy_ * dy_)
  else
    super
  end
end