octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hpw to assign a struct to a cell array element in an .oct file


From: PhilipNienhuis
Subject: Hpw to assign a struct to a cell array element in an .oct file
Date: Sat, 19 Dec 2015 07:55:37 -0800 (PST)

Hi,

Notwithstanding my limited C++ proficiency I'm trying to debug a binary
function for reading GIS raster data (for the mapping package). That
function was kindly supplied by Shashank Khare [1] but I found several
problems with it when reading more complicated raster files.

The function returns a cell array containing structs, where each cell array
element (a struct) contains raster band data.

Reading single-band raster files is fine. When reading multiple-band raster
data it crashes.
Using std::cout statements I found that the function crashes at the point
that a second band struct is to be added to the last but one cell array
element.

The setup of  the (AFAIU) relevant statements goes as follows:

:
int band_count = poDS->GetRasterCount();    // call a GDAL library function
:
Cell m_band(band_count);         // declare m_band to be a cell array
:
for (int curr_band = 0; curr_band < band_count; curr_band++) {
:
< generate struct with raster info for current band >
< finally resulting in a struct (octave_scalar_map) band_struct >
:
m_band(curr_band) = band_struct;   // crash if curr_band > 0
:

How should this code sequence be done properly (so that it doesn't crash) ?

Looking in the manual I've only found code examples for getting data *from*
structs and cell arrays, not how to add (heterogeneous) data.
The doxygen stuff is a little over my head, but I think I understand enough
of it to suspect that the cell array might require more thorough
dimensioning and/or indexing.

Thanks,

Philip

[1]
http://octave.1599824.n4.nabble.com/how-to-put-in-octave-forge-tt4671382.html#a4671657



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Hpw-to-assign-a-struct-to-a-cell-array-element-in-an-oct-file-tp4674118.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]