Module: Terraformer::ConvexHull

Defined in:
lib/terraformer/convex_hull.rb

Constant Summary collapse

DEFAULT_IMPL =
:monotone

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.implObject

Returns the value of attribute impl.



8
9
10
# File 'lib/terraformer/convex_hull.rb', line 8

def impl
  @impl
end

Class Method Details

.for(points) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/terraformer/convex_hull.rb', line 22

def for points
  hull = __send__ @impl || DEFAULT_IMPL, flatten_coordinates_from(points)
  if hull.length == 1
    Point.new hull[0]
  else
    Polygon.new hull
  end
end

.testObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/terraformer/convex_hull.rb', line 10

def test
  require 'ruby-prof'
  wc = Terraformer.parse 'test/examples/waldocanyon.geojson'
  RubyProf.start
  wc.convex_hull
  result = RubyProf.stop
  printer = RubyProf::FlatPrinter.new(result)
  printer.print(STDOUT)
  # printer = RubyProf::GraphPrinter.new(result)
  # printer.print(STDOUT, {})
end