Sha256: 9427cb4dfd0ea0d5212f03a2cd8cf05663d70210bfb24b749e33d48fee26b6b3

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require 'geo_ruby/simple_features/geometry_collection'


module GeoRuby
  module SimpleFeatures
    #Represents a group of polygons (see Polygon).
   class MultiPolygon < GeometryCollection
      def initialize(srid = DEFAULT_SRID)
        super(srid)
      end
      def binary_geometry_type
        6
      end
      #Text representation of a MultiPolygon
      def text_representation(dimension=2)
        @geometries.collect{|polygon| "(" + polygon.text_representation(dimension) + ")"}.join(",")
      end
      #WKT geometry type
      def text_geometry_type
        "MULTIPOLYGON"
      end
      
      #Creates a multi polygon from an array of polygons
      def self.from_polygons(polygons,srid=DEFAULT_SRID)
        multi_polygon = MultiPolygon::new(srid)
        multi_polygon.concat(polygons)
        multi_polygon
      end
      #Creates a multi polygon from sequences of points : ((((x,y)...(x,y)),((x,y)...(x,y)),((x,y)...(x,y))) 
      def self.from_raw_point_sequences(point_sequences, srid= DEFAULT_SRID)
        multi_polygon = MultiPolygon::new(srid)
        multi_polygon.concat( point_sequences.collect {|point_sequence| Polygon.from_raw_point_sequences(point_sequence,srid) } )
        multi_polygon
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
GeoRuby-0.0.1 lib/geo_ruby/simple_features/multi_polygon.rb
GeoRuby-0.0.3 lib/geo_ruby/simple_features/multi_polygon.rb
GeoRuby-0.0.2 lib/geo_ruby/simple_features/multi_polygon.rb
GeoRuby-0.0.4 lib/geo_ruby/simple_features/multi_polygon.rb