Class: GeoRuby::SimpleFeatures::MultiPolygon

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_ruby/simple_features.rb

Instance Method Summary collapse

Instance Method Details

#contains_point?(point) ⇒ Boolean

Returns true if any of the Polygon’s shapes contain this point.

Parameters:

  • GeoRuby (GeoRuby::SimpleFeatures::Point)

    Point object

Returns:

  • (Boolean)

    true if any of the Polygon’s shapes contain this point



20
21
22
23
24
25
26
# File 'lib/geo_ruby/simple_features.rb', line 20

def contains_point?(point)
  self.each do |shape|
    return true if shape.contains_point?(point)
  end
  
  return false
end

#to_arrayArray

A shortcut for grabbing an array of coordinates from GeoRuby’s MultiPolygon.

Returns:

  • (Array)

    an array of polygons, each one an array of coordinate pairs



7
8
9
10
11
12
13
14
15
16
# File 'lib/geo_ruby/simple_features.rb', line 7

def to_array
  coord_array = self.as_json[:coordinates]
  
  ## Fixes weird, unnecessary extra array
  0.upto(coord_array.count - 1).each do |i|
    coord_array[i] = coord_array[i][0]
  end
  
  return coord_array
end