Complex Type

Definition

List 111 Example of a complex type grid attribute
 1<Item name="vegetation" caption="Vagetation">
 2  <Definition valueType="complex" position="cell">
 3    <Item name="type" caption="Type">
 4      <Definition valueType="integer" option="true" default="1">
 5        <Enumerations>
 6          <Enumeration value="0" caption="No vegetation"/>
 7          <Enumeration value="1" caption="Vegetation"/>
 8        </Enumerations>
 9      </Definition>
10    </Item>
11    <Item name="density" caption="Vegetation density">
12      <Definition valueType="real" default="0">
13        <Condition type="isEqual" target="type" value="1"/>
14      </Definition>
15    </Item>
16  </Definition>
17</Item>

Display example

../_images/grid_att_example_complex_object_browser.png

Figure 67 Example of complex type grid attribute defined at cells

../_images/grid_att_example_complex_edit_dialog.png

Figure 68 Dialog to edit value of complex type grid attribute defined at cells

../_images/grid_att_example_complex_edit_group.png

Figure 69 Dialog to edit groups of complex type grid attribute defined at cells

Example code to read data

FORTRAN

List 112 Code example to load a complex type grid attribute defined at cells FORTRAN
 1integer:: ier, cellcount, vegetation_groupcount
 2integer, dimension(:), allocatable:: vegetation
 3integer, dimension(:), allocatable:: vegetation_type
 4double precision, dimension(:), allocatable:: vegetation_density
 5integer:: i
 6
 7! Read the number of cells
 8call cg_iRIC_Read_Grid_CellCount(fid, cellcount, ier)
 9! Allocate memory
10allocate(roughness(vegetation))
11! Load values at each cell into the allocated memory
12call cg_iRIC_Read_Grid_Complex_Cell(fid, "vegetation", vegetation, ier)
13
14! Read the number of groups
15call cg_iRIC_Read_Complex_Count(fid, "vegetation", vegetation_groupcount, ier)
16! Allocate memory
17allocate(vegetation_type(vegetation_groupcount))
18allocate(vegetation_density(vegetation_groupcount))
19! Load data to allocated memory
20do i = 1, vegetation_groupcount
21  call cg_iRIC_Read_Complex_Integer(fid, "vegetation", "type", vegetation_type(i), ier)
22  call cg_iRIC_Read_Complex_Real(fid, "vegetation", "density", vegetation_density(i), ier)
23end do

C/C++

List 113 Code example to load a complex type grid attribute defined at cells C++
 1int ier, cellcount, vegetation_groupcount;
 2std::vector<int> vegetation;
 3std::vector<int> vegetation_type;
 4std::vector<double> vegetation_density;
 5
 6// Read the number of cells
 7ier = cg_iRIC_Read_Grid_CellCount(fid, &cellcount);
 8// Allocate memory
 9vegetation.assign(cellcount, 0);
10// Load values at each cell into the allocated memory
11ier = cg_iRIC_Read_Grid_Complex_Cell(fid, "vegetation", vegetation.data());
12
13// Read the number of groups
14ier = cg_iRIC_Read_Complex_Count(fid, "vegetation", &vegetation_groupcount);
15// Allocate memory
16vegetation_type.assign(vegetation_groupcount, 0);
17vegetation_density.assign(vegetation_groupcount, 0);
18// Load data to allocated memory
19for (int i = 0; i < vegetation_groupcount; ++i) {
20  ier = cg_iRIC_Read_Complex_Integer(fid, "vegetation", "type", &vegetation_type[i]);
21  ier = cg_iRIC_Read_Complex_Real(fid, "vegetation", "density", &vegetation_density[i]);
22}

Python

List 114 Code example to load a complex type grid attribute defined at cells Python
 1# Load values at each cell
 2vegetation = cg_iRIC_Read_Grid_Complex_Cell(fid, "vegetation")
 3
 4# Read the number of groups
 5vegetation_groupcount = cg_iRIC_Read_Complex_Count(fid, "vegetation")
 6# Prepare list
 7vegetation_type = list()
 8vegetation_density = list()
 9
10for i in range(vegetation_groupcount):
11  vegetation_type.append(cg_iRIC_Read_Complex_Integer(fid, "vegetation", "type"))
12  vegetation_density.append(cg_iRIC_Read_Complex_Real(fid, "vegetation", "density"))