Class: GDAL::WarpOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/gdal/warp_operation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(warp_options) ⇒ WarpOperation

Returns a new instance of WarpOperation.

Parameters:

Raises:



18
19
20
21
22
23
24
# File 'lib/gdal/warp_operation.rb', line 18

def initialize(warp_options)
  pointer = FFI::GDAL::Warper.GDALCreateWarpOperation(warp_options.c_struct)

  raise GDAL::Error, "Unable to create warp operation" if pointer.null?

  @c_pointer = FFI::AutoPointer.new(pointer, WarpOperation.method(:release))
end

Instance Attribute Details

#c_pointerFFI::Pointer (readonly)

Returns:

  • (FFI::Pointer)


15
16
17
# File 'lib/gdal/warp_operation.rb', line 15

def c_pointer
  @c_pointer
end

Class Method Details

.release(pointer) ⇒ Object

Parameters:

  • pointer (FFI::Pointer)


8
9
10
11
12
# File 'lib/gdal/warp_operation.rb', line 8

def self.release(pointer)
  return unless pointer && !pointer.null?

  FFI::GDAL::Warper.GDALDestroyWarpOperation(pointer)
end

Instance Method Details

#chunk_and_warp_image(x_offset, y_offset, x_size, y_size) ⇒ Object

Parameters:

  • x_offset (Integer)

    X offset of the destination image.

  • y_offset (Integer)

    Y offset of the destination image.

  • x_size (Integer)

    X size (width) of the destination image.

  • y_size (Integer)

    Y size (height) of the destination image.



36
37
38
39
40
41
42
# File 'lib/gdal/warp_operation.rb', line 36

def chunk_and_warp_image(x_offset, y_offset, x_size, y_size)
  !!FFI::GDAL::Warper.GDALChunkAndWarpImage(@c_pointer,
                                            x_offset,
                                            y_offset,
                                            x_size,
                                            y_size)
end

#chunk_and_warp_multi(x_offset, y_offset, x_size, y_size) ⇒ Object

Parameters:

  • x_offset (Integer)

    X offset of the destination image.

  • y_offset (Integer)

    Y offset of the destination image.

  • x_size (Integer)

    X size (width) of the destination image.

  • y_size (Integer)

    Y size (height) of the destination image.



48
49
50
51
52
53
54
# File 'lib/gdal/warp_operation.rb', line 48

def chunk_and_warp_multi(x_offset, y_offset, x_size, y_size)
  FFI::GDAL::Warper.GDALChunkAndWarpMulti(@c_pointer,
                                          x_offset,
                                          y_offset,
                                          x_size,
                                          y_size)
end

#destroy!Object



26
27
28
29
30
# File 'lib/gdal/warp_operation.rb', line 26

def destroy!
  WarpOperation.release(@c_pointer)

  @c_pointer = nil
end

#warp_region(destination_x_offset, destination_y_offset, destination_x_size, destination_y_size, source_x_offset, source_y_offset, source_x_size, source_y_size) ⇒ Object

Parameters:

  • destination_x_offset (Integer)

    X offset of the destination image.

  • destination_y_offset (Integer)

    Y offset of the destination image.

  • destination_x_size (Integer)

    X size (width) of the destination image.

  • destination_y_size (Integer)

    Y size (height) of the destination image.

  • source_x_offset (Integer)

    X offset of the source image.

  • source_y_offset (Integer)

    Y offset of the source image.

  • source_x_size (Integer)

    X size (width) of the source image.

  • source_y_size (Integer)

    Y size (height) of the source image.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/gdal/warp_operation.rb', line 64

def warp_region(destination_x_offset, destination_y_offset,
  destination_x_size, destination_y_size,
  source_x_offset, source_y_offset,
  source_x_size, source_y_size)
  !!FFI::GDAL::Warper.GDALWarpRegion(@c_pointer,
                                     destination_x_offset,
                                     destination_y_offset,
                                     destination_x_size,
                                     destination_y_size,
                                     source_x_offset,
                                     source_y_offset,
                                     source_x_size,
                                     source_y_size)
end

#warp_region_to_buffer(destination_x_offset, destination_y_offset, destination_x_size, destination_y_size, buffer, data_type, source_x_offset, source_y_offset, source_x_size, source_y_size) ⇒ Object

rubocop:disable Metrics/ParameterLists

Parameters:

  • destination_x_offset (Integer)

    X offset of the destination image.

  • destination_y_offset (Integer)

    Y offset of the destination image.

  • destination_x_size (Integer)

    X size (width) of the destination image.

  • destination_y_size (Integer)

    Y size (height) of the destination image.

  • buffer (FFI::Pointer)
  • data_type (FFI::GDAL::DataType)
  • source_x_offset (Integer)

    X offset of the source image.

  • source_y_offset (Integer)

    Y offset of the source image.

  • source_x_size (Integer)

    X size (width) of the source image.

  • source_y_size (Integer)

    Y size (height) of the source image.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/gdal/warp_operation.rb', line 90

def warp_region_to_buffer(destination_x_offset, destination_y_offset,
  destination_x_size, destination_y_size,
  buffer, data_type,
  source_x_offset, source_y_offset,
  source_x_size, source_y_size)
  !!FFI::GDAL::Warper.GDALWarpRegionToBuffer(@c_pointer,
                                             destination_x_offset,
                                             destination_y_offset,
                                             destination_x_size,
                                             destination_y_size,
                                             buffer,
                                             data_type,
                                             source_x_offset,
                                             source_y_offset,
                                             source_x_size,
                                             source_y_size)
end