class Charta::Factory::SimpleGeometryFactory

Attributes

feature_factory[R]

@return [SimpleFeatureFactory]

Public Class Methods

new(feature_factory:) click to toggle source

@param [SimpleFeatureFactory] feature_factory

# File lib/charta/factory/simple_geometry_factory.rb, line 10
def initialize(feature_factory:)
  @feature_factory = feature_factory
end

Public Instance Methods

empty_geometry(srs) click to toggle source
# File lib/charta/factory/simple_geometry_factory.rb, line 22
def empty_geometry(srs)
  wrap(feature_factory.empty_feature(srs))
end
new_geometry(coordinates, srs: nil, format: nil) click to toggle source
# File lib/charta/factory/simple_geometry_factory.rb, line 14
def new_geometry(coordinates, srs: nil, format: nil)
  if coordinates.is_a?(::Charta::Geometry)
    coordinates
  else
    wrap(feature_factory.new_feature(coordinates, srs: srs, format: format))
  end
end

Protected Instance Methods

wrap(feature) click to toggle source
# File lib/charta/factory/simple_geometry_factory.rb, line 28
def wrap(feature)
  case feature.geometry_type
  when RGeo::Feature::Point
    Point.new(feature)
  when RGeo::Feature::LineString
    LineString.new(feature)
  when RGeo::Feature::Polygon
    Polygon.new(feature)
  when RGeo::Feature::MultiPolygon
    MultiPolygon.new(feature)
  when RGeo::Feature::GeometryCollection
    GeometryCollection.new(feature)
  else
    Geometry.new(feature)
  end
end