Class: CartesianForGeo::PolygonsCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/cartesian_for_geo.rb

Overview

Collection (Array) of Polygons

Instance Method Summary collapse

Instance Method Details

#<<(new_polygon) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cartesian_for_geo.rb', line 7

def <<(new_polygon)
  each_with_index do |polygon, ind|
    if new_polygon.include?(polygon)
      insert(ind, new_polygon) unless include?(new_polygon)
      next new_polygon.concat delete(polygon)
    elsif polygon.include?(new_polygon)
      break new_polygon = polygon.concat(new_polygon)
    end
  end
  return self if include?(new_polygon)
  super new_polygon
end