class OGR::Envelope

Attributes

max_x[RW]
max_y[RW]
min_x[RW]
min_y[RW]

Public Class Methods

new(env) click to toggle source
# File lib/ffi-ogr/envelope.rb, line 5
def initialize(env)
  raise RuntimeError.new("Invalid envelope specified") unless env.size == 4

  @min_x, @max_x = env[0], env[1]
  @min_y, @max_y = env[2], env[3]
end

Public Instance Methods

to_a(se_nw=false) click to toggle source
# File lib/ffi-ogr/envelope.rb, line 12
def to_a(se_nw=false)
  unless se_nw
    [@min_x, @max_x, @min_y, @max_y]
  else
    [@min_x, @min_y, @max_x, @max_y]
  end
end
to_hash() click to toggle source
# File lib/ffi-ogr/envelope.rb, line 20
def to_hash
  {min_x: @min_x, max_x: @max_x, min_y: @min_y, max_y: @max_y}
end
to_json() click to toggle source
# File lib/ffi-ogr/envelope.rb, line 24
def to_json
  MultiJson.dump(to_hash)
end
to_polygon() click to toggle source
# File lib/ffi-ogr/envelope.rb, line 28
def to_polygon
  coords = [[[@min_x, @min_y], [@min_x, @max_y], [@max_x, @max_y], [@max_x, @min_y], [@min_x, @min_y]]]
  OGR::Polygon.create coords
end