Class: Charta::GeometryCollection

Inherits:
Geometry
  • Object
show all
Defined in:
lib/charta/geometry_collection.rb

Overview

Represent a Geometry with contains other geometries

Direct Known Subclasses

MultiPolygon

Instance Attribute Summary

Attributes inherited from Geometry

#ewkt

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Geometry

#!=, #==, #area, #bounding_box, #buffer, #centroid, #circle, #collection?, #convert_to, #difference, #empty?, #find_srid, #flatten, #geom, #inspect, #intersection, #merge, #multi_polygon, #point_on_surface, #select_row, #select_value, #select_values, #srid, #srid=, #to_binary, #to_ewkt, #to_geojson, #to_gml, #to_json_object, #to_kml, #to_rgeo, #to_s, #to_svg, #to_svg_path, #to_text, #transform, #type

Constructor Details

#initialize(ewkt, flatten = true) ⇒ GeometryCollection

Returns a new instance of GeometryCollection.


4
5
6
7
# File 'lib/charta/geometry_collection.rb', line 4

def initialize(ewkt, flatten = true)
  super(ewkt)
  homogenize! if flatten
end

Class Method Details

.empty(srid = nil) ⇒ Object


14
15
16
17
# File 'lib/charta/geometry_collection.rb', line 14

def self.empty(srid = nil)
  srid = Charta.find_srid(srid.blank? ? :WGS84 : srid)
  new("SRID=#{srid};GEOMETRYCOLLECTION EMPTY")
end

Instance Method Details

#homogenize!Object

Homogenize data if it's a GeometryCollection


10
11
12
# File 'lib/charta/geometry_collection.rb', line 10

def homogenize!
  @ewkt = select_value("SELECT ST_AsEWKT(ST_Multi(ST_CollectionHomogenize(#{geom})))")
end