1 /**********************************************************************************************
2     Copyright (C) 2014 Oliver Eichler <oliver.eichler@gmx.de>
3 
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 
17 **********************************************************************************************/
18 
19 #include "CMainWindow.h"
20 #include "dem/CDemDraw.h"
21 #include "gis/CGisDraw.h"
22 #include "gis/IGisLine.h"
23 
24 
resetElevation()25 void IGisLine::point_t::resetElevation()
26 {
27     ele = NOINT;
28     for(int i = 0; i < subpts.size(); i++)
29     {
30         subpts[i].ele = NOINT;
31     }
32 }
33 
SGisLine(const QPolygonF & line)34 SGisLine::SGisLine(const QPolygonF& line)
35 {
36     for(const QPointF& pt : line)
37     {
38         append(IGisLine::point_t(pt));
39     }
40 
41     CMainWindow::self().getElevationAt(*this);
42 }
43 
updateElevation(CDemDraw * dem)44 void SGisLine::updateElevation(CDemDraw* dem)
45 {
46     for(int i = 0; i < size(); i++)
47     {
48         IGisLine::point_t& pt = (*this)[i];
49         qreal ele = dem->getElevationAt(pt.coord);
50         pt.ele = (ele == NOFLOAT) ? NOINT : qRound(ele);
51 
52         for(int n = 0; n < pt.subpts.size(); n++)
53         {
54             IGisLine::subpt_t& sub = pt.subpts[n];
55             qreal ele = dem->getElevationAt(sub.coord);
56             sub.ele = (ele == NOFLOAT) ? NOINT : qRound(ele);
57         }
58     }
59 }
60 
61 
updatePixel(CGisDraw * gis)62 void SGisLine::updatePixel(CGisDraw* gis)
63 {
64     for(int i = 0; i < size(); i++)
65     {
66         IGisLine::point_t& pt = (*this)[i];
67 
68         pt.pixel = pt.coord;
69         gis->convertRad2Px(pt.pixel);
70 
71         for(int n = 0; n < pt.subpts.size(); n++)
72         {
73             IGisLine::subpt_t& sub = pt.subpts[n];
74 
75             sub.pixel = sub.coord;
76             gis->convertRad2Px(sub.pixel);
77         }
78     }
79 }
80 
81