Class: GDAL::VirtualDataset

Inherits:
Object
  • Object
show all
Includes:
MajorObject
Defined in:
lib/gdal/virtual_dataset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MajorObject

#all_metadata, #description, #metadata, #metadata_domain_list, #metadata_item, #null?, #set_metadata_item

Constructor Details

#initialize(x_size, y_size) ⇒ VirtualDataset

Returns a new instance of VirtualDataset.



12
13
14
15
# File 'lib/gdal/virtual_dataset.rb', line 12

def initialize(x_size, y_size)
  FFI::GDAL::VRT.GDALRegister_VRT
  @c_pointer = FFI::GDAL::VRT.VRTCreate(x_size, y_size)
end

Instance Attribute Details

#c_pointerObject (readonly)

Returns the value of attribute c_pointer.



10
11
12
# File 'lib/gdal/virtual_dataset.rb', line 10

def c_pointer
  @c_pointer
end

Instance Method Details

#add_band(data_type, **options) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/gdal/virtual_dataset.rb', line 31

def add_band(data_type, **options)
  options_ptr = GDAL::Options.pointer(options)

  FFI::GDAL::VRT.VRTAddBand(@c_pointer, data_type, options_ptr)
end

#add_complex_source(vrt_band, source_band, no_data_value, src_x_offset: 0, src_y_offset: 0, src_x_size: nil, src_y_size: nil, dst_x_offset: 0, dst_y_offset: 0, dst_x_size: nil, dst_y_size: nil, scale_offset: 0.0, scale_ratio: 0.0) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/gdal/virtual_dataset.rb', line 67

def add_complex_source(vrt_band, source_band, no_data_value,
  src_x_offset: 0, src_y_offset: 0, src_x_size: nil, src_y_size: nil,
  dst_x_offset: 0, dst_y_offset: 0, dst_x_size: nil, dst_y_size: nil,
  scale_offset: 0.0, scale_ratio: 0.0)
  FFI::GDAL::VRT.VRTAddComplexSource(
    vrt_band,
    source_band,      # hSrcBand
    src_x_offset,     # hSrcBand
    src_y_offset,     # hSrcBand
    src_x_size,       # hSrcBand
    src_y_size,       # hSrcBand
    dst_x_offset,     # hSrcBand
    dst_y_offset,     # hSrcBand
    dst_x_size,       # hSrcBand
    dst_y_size,       # hSrcBand
    scale_offset,     # dfScaleOff
    scale_ratio,      # dfScaleRatio
    no_data_value     # dfNoDataValue
  )
end

#add_func_source(vrt_band, read_function, data, no_data_value) ⇒ Boolean

Parameters:

  • vrt_band (FFI::Pointer)
  • read_function (Proc)
  • data (FFI::Pointer)
  • no_data_value (Float)

Returns:

  • (Boolean)


94
95
96
# File 'lib/gdal/virtual_dataset.rb', line 94

def add_func_source(vrt_band, read_function, data, no_data_value)
  FFI::GDAL::VRT.VRTAddFuncSource(vrt_band, read_function, data, no_data_value)
end

#add_simple_source(vrt_band, source_band, no_data_value, src_x_offset: 0, src_y_offset: 0, src_x_size: nil, src_y_size: nil, dst_x_offset: 0, dst_y_offset: 0, dst_x_size: nil, dst_y_size: nil, resampling: "") ⇒ Boolean

rubocop:disable Metrics/ParameterLists

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gdal/virtual_dataset.rb', line 46

def add_simple_source(vrt_band, source_band, no_data_value,
  src_x_offset: 0, src_y_offset: 0, src_x_size: nil, src_y_size: nil,
  dst_x_offset: 0, dst_y_offset: 0, dst_x_size: nil, dst_y_size: nil,
  resampling: "")
  FFI::GDAL::VRT.VRTAddSimpleSource(
    vrt_band,
    source_band,      # hSrcBand
    src_x_offset,     # hSrcBand
    src_y_offset,     # hSrcBand
    src_x_size,       # hSrcBand
    src_y_size,       # hSrcBand
    dst_x_offset,     # hSrcBand
    dst_y_offset,     # hSrcBand
    dst_x_size,       # hSrcBand
    dst_y_size,       # hSrcBand
    resampling,       # pszResampling,
    no_data_value     # dfNoDataValue
  )
end

#add_source(vrt_band, new_source) ⇒ Boolean

Returns [description].

Parameters:

  • vrt_band (FFI::Pointer)
  • new_source (FFI::Pointer)

Returns:

  • (Boolean)
    description


40
41
42
# File 'lib/gdal/virtual_dataset.rb', line 40

def add_source(vrt_band, new_source)
  FFI::GDAL::VRT.VRTAddSource(vrt_band, new_source)
end

#flush_cacheObject



17
18
19
# File 'lib/gdal/virtual_dataset.rb', line 17

def flush_cache
  FFI::GDAL::VRT.VRTFlushCache(@c_pointer)
end

#to_xml(path = "") ⇒ Object

TODO: Build the xml string



22
23
24
25
26
# File 'lib/gdal/virtual_dataset.rb', line 22

def to_xml(path = "")
  xml_node = FFI::GDAL::VRT.VRTSerializeToXML(@c_pointer, path)

  FFI::CPL::MiniXML.CPLSerializeXMLTree(xml_node)
end