class GeoRuby::SimpleFeatures::GeometryFactory

Creates a new geometry according to constructions received from a parser, for example EWKBParser.

Attributes

geometry[R]

the built geometry

Public Class Methods

new() click to toggle source
# File lib/geo_ruby/simple_features/geometry_factory.rb, line 18
def initialize
  @geometry = nil
  @geometry_stack = []
end

Public Instance Methods

abort_geometry() click to toggle source

abort a geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 76
def abort_geometry
  reset
end
add_point_x_y(x,y) click to toggle source

add a 2D point to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 28
def add_point_x_y(x,y)
  @geometry_stack.last.set_x_y(x,y)
end
add_point_x_y_m(x,y,m) click to toggle source

add a 2D point with M to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 44
def add_point_x_y_m(x,y,m)
  @geometry_stack.last.set_x_y(x,y)
  @geometry_stack.last.m=m
end
add_point_x_y_z(x,y,z) click to toggle source

add a 3D point to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 36
def add_point_x_y_z(x,y,z)
  @geometry_stack.last.set_x_y_z(x,y,z)
end
add_point_x_y_z_m(x,y,z,m) click to toggle source

add a 3D point with M to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 53
def add_point_x_y_z_m(x,y,z,m)
  @geometry_stack.last.set_x_y_z(x,y,z)
  @geometry_stack.last.m=m
end
add_points_x_y(xy) click to toggle source

add 2D points to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 32
def add_points_x_y(xy)
  xy.each_slice(2) {|slice| add_point_x_y(*slice)}
end
add_points_x_y_m(xym) click to toggle source

add 2D points with M to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 49
def add_points_x_y_m(xym)
  xym.each_slice(3) {|slice| add_point_x_y_m(*slice)}
end
add_points_x_y_z(xyz) click to toggle source

add 3D points to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 40
def add_points_x_y_z(xyz)
  xyz.each_slice(3) {|slice| add_point_x_y_z(*slice)}
end
add_points_x_y_z_m(xyzm) click to toggle source

add 3D points with M to the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 58
def add_points_x_y_z_m(xyzm)
  xyzm.each_slice(4) {|slice| add_point_x_y_z_m(*slice)}
end
begin_geometry(geometry_type,srid=DEFAULT_SRID) click to toggle source

begin a geometry of type geometry_type

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 62
def begin_geometry(geometry_type,srid=DEFAULT_SRID)
  geometry= geometry_type::new(srid)
  @geometry= geometry if @geometry.nil?
  @geometry_stack << geometry
end
end_geometry(with_z=false,with_m=false) click to toggle source

terminates the current geometry

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 68
def end_geometry(with_z=false,with_m=false)
  @geometry=@geometry_stack.pop
  @geometry.with_z=with_z
  @geometry.with_m=with_m
  #add the newly defined geometry to its parent if there is one

  @geometry_stack.last << geometry if !@geometry_stack.empty?
end
reset() click to toggle source

resets the factory

# File lib/geo_ruby/simple_features/geometry_factory.rb, line 23
def reset
  @geometry = nil
  @geometry_stack = []
end