Sha256: 3caa0ad52515dab4c27039b67d0b55f215080124242f3e2ee1546807e3608675

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

module RGeo
  module Cartesian
    module GeometryMethods
      
      def to_georuby
        if self.class == PointImpl
          GeoRuby::SimpleFeatures::Point.from_x_y x, y, srid
        elsif self.class == LineStringImpl
          GeoRuby::SimpleFeatures::LineString.from_points points.collect(&:to_georuby), srid     
        elsif self.class == LinearRingImpl
          GeoRuby::SimpleFeatures::LinearRing.from_points points.collect(&:to_georuby), srid
        elsif self.class == PolygonImpl
          GeoRuby::SimpleFeatures::Polygon.from_linear_rings linear_rings.collect(&:to_georuby), srid
        else
          GeoRuby::SimpleFeatures::Geometry.from_geometry collect(&:to_georuby), srid
        end      
        
      end    
      
    end 
    
    module GeometryCollectionMethods
      def to_georuby
        if self.class == MultiPolygonImpl
          GeoRuby::SimpleFeatures::MultiPolygon.from_polygons collect(&:to_georuby), srid
        else
          GeoRuby::SimpleFeatures::GeometryCollection.from_geometries collect(&:to_georuby), srid
        end
      end
    end 

    module LineStringMethods      
      def to_linear_ring
        linear_ring_points = points.first == points.last ? points : points.push(points.first)
        factory.linear_ring linear_ring_points
      end
    end

    module LinearRingMethods      
      def to_linear_ring
        linear_ring_points = points.first == points.last ? points : points.push(points.first)
        factory.linear_ring linear_ring_points
      end
    end

    module PolygonMethods      
      def rings
        [exterior_ring] + interior_rings
      end
      
      def linear_rings
        rings.collect(&:to_linear_ring)
      end
    end


  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
georuby-ext-0.0.5 lib/georuby-ext/rgeo/cartesian/feature_methods.rb
georuby-ext-0.0.4 lib/georuby-ext/rgeo/cartesian/feature_methods.rb
georuby-ext-0.0.3 lib/georuby-ext/rgeo/cartesian/feature_methods.rb
georuby-ext-0.0.2 lib/georuby-ext/rgeo/cartesian/feature_methods.rb