iLand
Public Slots | Public Member Functions | Static Public Member Functions | Properties | List of all members
ScriptGrid Class Reference

#include <scriptgrid.h>

Inheritance diagram for ScriptGrid:

Public Slots

bool create (int awidth, int aheight, int acellsize)
 creates a grid with cellsize / width / height the offset of the grid (lower left corner) is given by coordx/coordy More...
 
void setName (QString arg)
 
void setOrigin (double x, double y)
 set the origin of the grid (iLand coordiantes). More...
 
QJSValue copy ()
 create a copy of the current grid and return a new script object More...
 
void clear ()
 fill the grid with 0-values More...
 
void paint (double min_val, double max_val)
 draw the map More...
 
QString info ()
 
void save (QString fileName)
 save to a file as ESRI ASC raster grid (relative to project file) More...
 
bool load (QString fileName)
 load from a file (ESRI ASC raster grid), relative to project root. More...
 
void apply (QString expression)
 apply a function on the values of the grid, thus modifiying the grid (see the copy() function). More...
 
void combine (QString expression, QJSValue grid_object)
 combine multiple grids, and calculate the result of 'expression' More...
 
QJSValue resample (QJSValue grid_object)
 resamples the grid to the extent/cellsize given by the grid 'grid_object' Resampling is "brute-force", every cell of the new grid gets the cell value of the cell center returns the object itself. More...
 
void aggregate (int factor)
 
double sum (QString expression)
 apply the expression "expression" on all pixels of the grid and return the sum of the values More...
 
void sumTrees (QString expression, QString filter)
 loop over all trees and create a sum of 'expression' for each cell. Filter trees with 'filter' More...
 
double value (int x, int y) const
 access values of the grid More...
 
void setValue (int x, int y, double value) const
 write values to the grid More...
 
double valueAt (double x, double y) const
 access value of the grid in metric coordinates More...
 
void setValueAt (double x, double y, double value) const
 write values to the grid at metric coordinates x and y. More...
 
double metricX (int indexx) const
 convert a cellindex in x-direction to a metric value (x) representing the center of the cell More...
 
double metricY (int indexy) const
 convert a cellindex in y-direction to a metric value (y) representing the center of the cell More...
 
int indexX (double meterx) const
 convert a metric value (x-axis) to an index for the x-axis (see also isIndexValid(), isCoordValid() ) More...
 
int indexY (double metery) const
 convert a metric value (y-axis) to an index for the y-axis (see also isIndexValid(), isCoordValid() ) More...
 
bool isIndexValid (int x, int y) const
 check if a given pair of indices (x/y) is valid for the grid More...
 
bool isCoordValid (double x, double y) const
 check if a given pair of metric coordinates (x/y) is valid for the grid More...
 

Public Member Functions

Q_INVOKABLE ScriptGrid (QObject *parent=nullptr)
 
Q_INVOKABLE ScriptGrid (QString fileName)
 
 ScriptGrid (Grid< double > *grid)
 
void setGrid (Grid< double > *grid)
 
void setOwnership (bool should_delete)
 
 ~ScriptGrid ()
 
QString name () const
 
Grid< double > * grid ()
 
int width () const
 
int height () const
 
int count () const
 
int cellsize () const
 
bool isValid () const
 

Static Public Member Functions

static QJSValue createGrid (Grid< double > *grid, QString name=QString())
 
static void addToScriptEngine (QJSEngine *engine)
 

Properties

QString name
 
int width
 
int height
 
int count
 
int cellsize
 
bool isValid
 

Constructor & Destructor Documentation

◆ ScriptGrid() [1/3]

ScriptGrid::ScriptGrid ( QObject *  parent = nullptr)

◆ ScriptGrid() [2/3]

Q_INVOKABLE ScriptGrid::ScriptGrid ( QString  fileName)
inline

◆ ScriptGrid() [3/3]

ScriptGrid::ScriptGrid ( Grid< double > *  grid)
inlineexplicit

◆ ~ScriptGrid()

ScriptGrid::~ScriptGrid ( )

Member Function Documentation

◆ addToScriptEngine()

void ScriptGrid::addToScriptEngine ( QJSEngine *  engine)
static

◆ aggregate

void ScriptGrid::aggregate ( int  factor)
slot

◆ apply

void ScriptGrid::apply ( QString  expression)
slot

apply a function on the values of the grid, thus modifiying the grid (see the copy() function).

The function is given as an Expression and is run for each cell of the grid.

◆ cellsize()

int ScriptGrid::cellsize ( ) const
inline

◆ clear

void ScriptGrid::clear ( )
slot

fill the grid with 0-values

◆ combine

void ScriptGrid::combine ( QString  expression,
QJSValue  grid_object 
)
slot

combine multiple grids, and calculate the result of 'expression'

◆ copy

QJSValue ScriptGrid::copy ( )
slot

create a copy of the current grid and return a new script object

◆ count()

int ScriptGrid::count ( ) const
inline

◆ create

bool ScriptGrid::create ( int  awidth,
int  aheight,
int  acellsize 
)
slot

creates a grid with cellsize / width / height the offset of the grid (lower left corner) is given by coordx/coordy

◆ createGrid()

QJSValue ScriptGrid::createGrid ( Grid< double > *  grid,
QString  name = QString() 
)
static

◆ grid()

Grid< double > * ScriptGrid::grid ( )
inline

◆ height()

int ScriptGrid::height ( ) const
inline

◆ indexX

int ScriptGrid::indexX ( double  meterx) const
inlineslot

convert a metric value (x-axis) to an index for the x-axis (see also isIndexValid(), isCoordValid() )

◆ indexY

int ScriptGrid::indexY ( double  metery) const
inlineslot

convert a metric value (y-axis) to an index for the y-axis (see also isIndexValid(), isCoordValid() )

◆ info

QString ScriptGrid::info ( )
slot

◆ isCoordValid

bool ScriptGrid::isCoordValid ( double  x,
double  y 
) const
inlineslot

check if a given pair of metric coordinates (x/y) is valid for the grid

◆ isIndexValid

bool ScriptGrid::isIndexValid ( int  x,
int  y 
) const
inlineslot

check if a given pair of indices (x/y) is valid for the grid

◆ isValid()

bool ScriptGrid::isValid ( ) const
inline

◆ load

bool ScriptGrid::load ( QString  fileName)
slot

load from a file (ESRI ASC raster grid), relative to project root.

return true on success.

◆ metricX

double ScriptGrid::metricX ( int  indexx) const
inlineslot

convert a cellindex in x-direction to a metric value (x) representing the center of the cell

◆ metricY

double ScriptGrid::metricY ( int  indexy) const
inlineslot

convert a cellindex in y-direction to a metric value (y) representing the center of the cell

◆ name()

QString ScriptGrid::name ( ) const
inline

◆ paint

void ScriptGrid::paint ( double  min_val,
double  max_val 
)
slot

draw the map

◆ resample

QJSValue ScriptGrid::resample ( QJSValue  grid_object)
slot

resamples the grid to the extent/cellsize given by the grid 'grid_object' Resampling is "brute-force", every cell of the new grid gets the cell value of the cell center returns the object itself.

◆ save

void ScriptGrid::save ( QString  fileName)
slot

save to a file as ESRI ASC raster grid (relative to project file)

◆ setGrid()

void ScriptGrid::setGrid ( Grid< double > *  grid)
inline

◆ setName

void ScriptGrid::setName ( QString  arg)
inlineslot

◆ setOrigin

void ScriptGrid::setOrigin ( double  x,
double  y 
)
slot

set the origin of the grid (iLand coordiantes).

the width/height of the grid are not altered, the grid is just moved to the new coordiantes.

◆ setOwnership()

void ScriptGrid::setOwnership ( bool  should_delete)
inline

◆ setValue

void ScriptGrid::setValue ( int  x,
int  y,
double  value 
) const
inlineslot

write values to the grid

◆ setValueAt

void ScriptGrid::setValueAt ( double  x,
double  y,
double  value 
) const
inlineslot

write values to the grid at metric coordinates x and y.

◆ sum

double ScriptGrid::sum ( QString  expression)
slot

apply the expression "expression" on all pixels of the grid and return the sum of the values

◆ sumTrees

void ScriptGrid::sumTrees ( QString  expression,
QString  filter 
)
slot

loop over all trees and create a sum of 'expression' for each cell. Filter trees with 'filter'

◆ value

double ScriptGrid::value ( int  x,
int  y 
) const
inlineslot

access values of the grid

◆ valueAt

double ScriptGrid::valueAt ( double  x,
double  y 
) const
inlineslot

access value of the grid in metric coordinates

◆ width()

int ScriptGrid::width ( ) const
inline

Property Documentation

◆ cellsize

int ScriptGrid::cellsize
read

◆ count

int ScriptGrid::count
read

◆ height

int ScriptGrid::height
read

◆ isValid

bool ScriptGrid::isValid
read

◆ name

QString ScriptGrid::name
readwrite

◆ width

int ScriptGrid::width
read

The documentation for this class was generated from the following files: