Class: OGR::CoordinateTransformation

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi-ogr/coordinate_transformation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ CoordinateTransformation

Returns a new instance of CoordinateTransformation.


5
6
7
8
# File 'lib/ffi-ogr/coordinate_transformation.rb', line 5

def initialize(ptr)
  @ptr = FFI::AutoPointer.new(ptr, self.class.method(:release))
  @ptr.autorelease = false
end

Instance Attribute Details

#ptrObject

Returns the value of attribute ptr


3
4
5
# File 'lib/ffi-ogr/coordinate_transformation.rb', line 3

def ptr
  @ptr
end

Class Method Details

.find_transformation(in_sr, out_sr) ⇒ Object

Raises:

  • (RuntimeError)

16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ffi-ogr/coordinate_transformation.rb', line 16

def self.find_transformation(in_sr, out_sr)
  bad_sr = []

  if !in_sr.instance_of?(OGR::SpatialReference)
    bad_sr << 'Input SR'
  elsif !out_sr.instance_of?(OGR::SpatialReference)
    bad_sr << 'Output SR'
  end

  raise RuntimeError.new("Invalid Spatial Reference(s): #{bad_sr.join(', ')}") if bad_sr.size > 0

  FFIOGR.OCTNewCoordinateTransformation(in_sr.ptr, out_sr.ptr)
end

.release(ptr) ⇒ Object


10
# File 'lib/ffi-ogr/coordinate_transformation.rb', line 10

def self.release(ptr);end

Instance Method Details

#freeObject


12
13
14
# File 'lib/ffi-ogr/coordinate_transformation.rb', line 12

def free
  FFIOGR.OCTDestroyCoordinateTransformation(@ptr)
end