22#include <QtCore/QHash>
37 MapGrid(
const QString &fileName,
const bool create_index=
true) {
loadFromFile(fileName, create_index); }
38 bool loadFromFile(
const QString &fileName,
const bool create_index=
true);
44 const QString &
name()
const {
return mName; }
45 bool isValid()
const {
return !mGrid.isEmpty(); }
48 int count()
const {
return mRectIndex.size(); }
51 bool isValid(
const int id)
const {
return mRectIndex.contains(
id); }
53 double area(
const int id)
const {
return isValid(
id)?mRectIndex[id].second : 0.;}
58 QList<QPair<ResourceUnit*, double> >
resourceUnitAreas(
const int id)
const {
return mRUIndex.values(
id); }
60 QList<Tree*>
trees(
const int id)
const;
62 int loadTrees(
const int id, QVector<QPair<Tree *, double> > &rList,
const QString filter=QString(),
int n_estimate=0)
const;
68 const QMultiHash<int, int>
neighborList()
const {
return mNeighborList; }
72 inline bool hasValue(
const int id,
const QPoint &lif_grid_coords)
const {
return mGrid.constValueAtIndex(lif_grid_coords.x()/
cPxPerHeight, lif_grid_coords.y()/
cPxPerHeight) == id; }
79 QHash<int, QPair<QRectF,double> > mRectIndex;
80 QMultiHash<int, QPair<ResourceUnit*, double> > mRUIndex;
81 QMultiHash<int, int> mNeighborList;
GisGrid encapsulates a simple grid of values based on GIS data.
Definition: gisgrid.h:68
Grid class (template).
Definition: grid.h:44
QList< ResourceUnit * > resourceUnits(const int id) const
returns the list of resource units with at least one pixel within the area designated by 'id'
Definition: mapgrid.cpp:246
MapGrid()
Definition: mapgrid.cpp:110
QList< int > neighborsOf(const int index) const
retrieve a list of saplings on a given stand polygon.
Definition: mapgrid.cpp:352
QList< int > gridIndices(const int id) const
return a list of grid-indices of a given stand-id
Definition: mapgrid.cpp:320
void createIndex()
(re-)creates the internal index (mRUIndex, mRectIndex, ...)
Definition: mapgrid.cpp:170
QList< QPair< ResourceUnit *, double > > resourceUnitAreas(const int id) const
returns a list with resource units and area factors per 'id'.
Definition: mapgrid.h:58
bool isValid() const
Definition: mapgrid.h:45
MapGrid(const QString &fileName, const bool create_index=true)
Definition: mapgrid.h:37
static void freeLocksForStand(const int id)
free locks for a given stand
Definition: mapgrid.cpp:311
QList< Tree * > trees(const int id) const
return a list of all living trees on the area 'id'
Definition: mapgrid.cpp:256
const Grid< int > & grid() const
Definition: mapgrid.h:46
QRectF boundingBox(const int id) const
returns the bounding box of a polygon
Definition: mapgrid.h:52
bool loadFromFile(const QString &fileName, const bool create_index=true)
load ESRI style text file
Definition: mapgrid.cpp:234
void updateNeighborList()
scan the map and fill the mNeighborList
Definition: mapgrid.cpp:362
int loadTrees(const int id, QVector< QPair< Tree *, double > > &rList, const QString filter=QString(), int n_estimate=0) const
load trees and store in list 'rList'. If 'filter'<>"", then the filter criterion is applied
Definition: mapgrid.cpp:271
MapGrid(const GisGrid &source_grid)
create a MapGrid. the optional parameter "create_index" indicates if a spatial index (e....
Definition: mapgrid.h:36
int standIDFromLIFCoord(const QPoint &lif_grid_coords) const
return the stand-ID at the coordinates from the LIF-Grid (i.e., 2m grid).
Definition: mapgrid.h:74
bool hasValue(const int id, const QPoint &lif_grid_coords) const
return true, if the point 'lif_grid_coords' (x/y integer key within the LIF-Grid)
Definition: mapgrid.h:72
const QMultiHash< int, int > neighborList() const
extract a list of neighborhood relationships between all the polygons of the grid
Definition: mapgrid.h:68
bool isValid(const int id) const
returns true, if 'id' is a valid id in the grid, false otherwise.
Definition: mapgrid.h:51
const QString & name() const
Definition: mapgrid.h:44
int count() const
number of stands stored in the index
Definition: mapgrid.h:48
double area(const int id) const
return the area (m2) covered by the polygon
Definition: mapgrid.h:53
void createEmptyGrid()
create an empty grid with the size of the height grid of iLand (all values are 0, no index is created...
Definition: mapgrid.cpp:149
bool loadFromGrid(const GisGrid &source_grid, const bool create_index=true)
load from an already present GisGrid
Definition: mapgrid.cpp:114
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
The class contains data available at ResourceUnit x Species scale.
Definition: resourceunitspecies.h:34
SaplingTreeOld holds information of a sapling (which represents N trees). Emphasis is on efficient st...
Definition: sapling.h:29
A tree is the basic simulation entity of iLand and represents a single tree.
Definition: tree.h:44
const int cPxPerHeight
Definition: globalsettings.h:9