Subversion Repositories public iLand

Rev

Rev 400 | Rev 429 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 400 Rev 401
Line 9... Line 9...
9
const int StampContainer::cBHDclassCount = 70; ///< class count, see getKey(): for lower dbhs classes are smaller
9
const int StampContainer::cBHDclassCount = 70; ///< class count, see getKey(): for lower dbhs classes are smaller
10
const int StampContainer::cHDclassWidth=10;
10
const int StampContainer::cHDclassWidth=10;
11
const int StampContainer::cHDclassLow = 35; ///< hd classes offset is 35: class 0 = 35-45, class 1 = 45-55
11
const int StampContainer::cHDclassLow = 35; ///< hd classes offset is 35: class 0 = 35-45, class 1 = 45-55
12
const int StampContainer::cHDclassCount = 16; ///< class count. highest class:  185-195
12
const int StampContainer::cHDclassCount = 16; ///< class count. highest class:  185-195
13
13
-
 
14
// static values
-
 
15
Grid<float> StampContainer::m_distance;
14
16
15
StampContainer::StampContainer()
17
StampContainer::StampContainer()
16
{
18
{
17
    //
19
    //
18
    m_lookup.setup(1., // cellsize
20
    m_lookup.setup(1., // cellsize
Line 55... Line 57...
55
{
57
{
56
    if (!m_useLookup)
58
    if (!m_useLookup)
57
        return;
59
        return;
58
    Stamp *s;
60
    Stamp *s;
59
    int h;
61
    int h;
-
 
62
    int max_size=0;
60
    for (int b=0;b<cBHDclassCount;b++) {
63
    for (int b=0;b<cBHDclassCount;b++) {
61
        // find lowest value...
64
        // find lowest value...
62
        for (h=0;h<cHDclassCount;h++) {
65
        for (h=0;h<cHDclassCount;h++) {
63
            s=m_lookup.valueAtIndex(b,h);
66
            s=m_lookup.valueAtIndex(b,h);
64
            if (s) {
67
            if (s) {
Line 76... Line 79...
76
        }
79
        }
77
        // fill up the rest...
80
        // fill up the rest...
78
        for (;h<cHDclassCount;h++) {
81
        for (;h<cHDclassCount;h++) {
79
            m_lookup.valueAtIndex(b,h)=s;
82
            m_lookup.valueAtIndex(b,h)=s;
80
        }
83
        }
81
-
 
-
 
84
        if(s)
-
 
85
            max_size = std::max(max_size, s->dataSize());
-
 
86
    }
-
 
87
    // distance grid
-
 
88
    if (m_distance.sizeX()<max_size) {
-
 
89
        setupDistanceGrid(max_size);
82
    }
90
    }
83
    //if (GlobalSettings::instance()->settings().paramValueBool("debugDumpStamps", false) )
91
    //if (GlobalSettings::instance()->settings().paramValueBool("debugDumpStamps", false) )
84
    //    qDebug() << dump();
92
    //    qDebug() << dump();
85
}
93
}
86
94
-
 
95
void StampContainer::setupDistanceGrid(const int size)
-
 
96
{
-
 
97
    const float px_size = cPxSize;
-
 
98
    m_distance.setup(px_size, size, size);
-
 
99
    float *p=m_distance.begin();
-
 
100
    QPoint idx;
-
 
101
    for (;p!=m_distance.end();++p) {
-
 
102
        idx = m_distance.indexOf(p);
-
 
103
        *p = sqrt(double(idx.x()*idx.x()) + double(idx.y()*idx.y()))*px_size;
-
 
104
    }
-
 
105
}
87
106
88
 void StampContainer::addStamp(Stamp* stamp, const int cls_dbh, const int cls_hd, const float crown_radius_m, const float dbh, const float hd_value)
107
 void StampContainer::addStamp(Stamp* stamp, const int cls_dbh, const int cls_hd, const float crown_radius_m, const float dbh, const float hd_value)
89
 {
108
 {
90
    if (m_useLookup) {
109
    if (m_useLookup) {
91
        if (cls_dbh<0 || cls_dbh>=cBHDclassCount || cls_hd<0 || cls_hd>=cHDclassCount)
110
        if (cls_dbh<0 || cls_dbh>=cBHDclassCount || cls_hd<0 || cls_hd>=cHDclassCount)