Viewshed 6.1.0
A C++ library for calculation of viewshed, inverse viewshed and visibility indices for both of those analyses.
Loading...
Searching...
No Matches
abstractlos.h
1#pragma once
2#include "viewshed_export.h"
3
4#include <algorithm>
5#include <memory>
6#include <vector>
7
8#include "enums.h"
9#include "losnode.h"
10#include "visibility.h"
11
13
14namespace viewshed
15{
16 class CellEvent;
17 class LoSNode;
18
24 class DLL_API AbstractLoS : public std::vector<LoSNode>
25 {
26 public:
27 virtual ~AbstractLoS() = default;
28
34 void setViewPoint( std::shared_ptr<Point> vp );
41 void setViewPoint( std::shared_ptr<LoSNode> poi, double observerOffset = 0 );
47 void setTargetPoint( std::shared_ptr<Point> tp );
54 void setTargetPoint( std::shared_ptr<LoSNode> poi, double targetOffset = 0 );
60 void setAngle( double angle );
61
67 virtual void prepareForCalculation() = 0;
68
75 double gradient( std::size_t i );
76
83 double distance( std::size_t i );
84
91 double elevation( std::size_t i );
92
93 virtual bool isValid() = 0;
94
100 virtual int numberOfNodes() = 0;
101
107 virtual int targetPointIndex() = 0;
108
114 virtual int resultRow() = 0;
115
121 virtual int resultCol() = 0;
122
129 virtual LoSNode nodeAt( std::size_t i ) = 0;
130
136 double horizontalAngle();
137
143 int targetRow();
144
150 int targetCol();
151
157 double targetDistance();
158
164 double targetGradient();
165
171 double targetElevation();
172
178 std::shared_ptr<Point> vp();
179
187 void applyCurvatureCorrections( bool apply, double refractionCoeff, double earthDiameter )
188 {
189 mCurvatureCorrections = apply;
190 mRefractionCoefficient = refractionCoeff;
191 mEarthDiameter = earthDiameter;
192 };
193
199 void applyCurvatureCorrections( bool apply ) { mCurvatureCorrections = apply; };
200
206 void setRefractionCoeficient( double refractionCoeff ) { mRefractionCoefficient = refractionCoeff; };
207
213 void setEarthDiameter( double earthDiameter ) { mEarthDiameter = earthDiameter; };
214
220 int targetIndex() { return mTargetIndex; }
221
227 double viewPointElevation();
228
234 double viewPointTotalElevation();
235
241 virtual void setCurrentLoSNode( std::size_t i );
242
249 double currentDistance();
250
257 double currentGradient();
258
265 double currentElevation();
266
267 protected:
268 AbstractLoS();
269
274 virtual void findTargetPointIndex() = 0;
275
281
286 double mPointDistance = 0;
287
292 std::shared_ptr<Point> mVp = std::make_shared<Point>();
293
298 std::shared_ptr<Point> mTp = std::make_shared<Point>();
299
304 int mTargetIndex = -1;
305
311
316 double mEarthDiameter = EARTH_DIAMETER;
317
322 double mRefractionCoefficient = REFRACTION_COEFFICIENT;
323
328 virtual void sort() = 0;
329
335
342 double curvatureCorrectionsFix( const double distance );
343 };
344
345} // namespace viewshed
void setTargetPoint(std::shared_ptr< Point > tp)
Set the Target Point object directly from Point with offset specified as part of this object.
Definition abstractlos.cpp:29
void setAngle(double angle)
Set the horizontal angle for extracting elevations, distances and gradients from line-of-sight.
Definition abstractlos.cpp:44
void setViewPoint(std::shared_ptr< Point > vp)
Set the View Point object directly from Point with offset specified as part of this object.
Definition abstractlos.cpp:13
std::shared_ptr< Point > vp()
View point for this line-of-sight.
Definition abstractlos.cpp:50
Abstract class that represent line-of-sight (LoS). Consists of LoSNodes, view point and target point ...
Definition abstractlos.h:25
double targetDistance()
Distance of target.
Definition abstractlos.cpp:20
void setRefractionCoeficient(double refractionCoeff)
Set the Refraction Coeficient for curvature corrections.
Definition abstractlos.h:206
double curvatureCorrectionsFix(const double distance)
Elevation changes using currently set curvature corrections for specific distance.
Definition abstractlos.cpp:68
virtual int targetPointIndex()=0
Index of target point in the line-of-sight.
int targetIndex()
Get index of target point in the current LoS.
Definition abstractlos.h:220
virtual int resultRow()=0
Row number where the outcome of LoS analysis should be stored.
double mEarthDiameter
Earth diameter for curvature corrections.
Definition abstractlos.h:316
double targetElevation()
Elevation of target.
Definition abstractlos.cpp:27
int targetRow()
Row number for the target of LoS.
Definition abstractlos.cpp:48
double mRefractionCoefficient
Refraction coefficient for curvature corrections.
Definition abstractlos.h:322
double mPointDistance
Distance between observer and target point.
Definition abstractlos.h:286
virtual LoSNode nodeAt(std::size_t i)=0
LoSNode at specific index.
void applyCurvatureCorrections(bool apply)
Set curvature corrections on/off.
Definition abstractlos.h:199
double horizontalAngle()
Horizontal angle for this line-of-sight.
Definition abstractlos.cpp:42
virtual void findTargetPointIndex()=0
Retrieve index of target point in this LoS.
virtual void sort()=0
Sort LoSNodes by distance from View point.
LoSNode mCurrentLoSNode
Currently solved LoS Node.
Definition abstractlos.h:334
int targetCol()
Column number for the target of LoS.
Definition abstractlos.cpp:46
virtual int resultCol()=0
Column number where the outcome of LoS analysis should be stored.
void setEarthDiameter(double earthDiameter)
Set the Earth Diameter for curvature corrections.
Definition abstractlos.h:213
std::shared_ptr< Point > mTp
Target point.
Definition abstractlos.h:298
double targetGradient()
Gradient of target.
Definition abstractlos.cpp:22
bool mCurvatureCorrections
Use curvature corrections for this LoS.
Definition abstractlos.h:310
double mAngleHorizontal
Horizontal angle between view point and target point.
Definition abstractlos.h:280
virtual int numberOfNodes()=0
Number of LoSNodes in this line-of-sight.
std::shared_ptr< Point > mVp
View point.
Definition abstractlos.h:292
virtual void prepareForCalculation()=0
Prepare line-of-sight for calculation. For example inverse LoS needs some preprocessing before being ...
double elevation(std::size_t i)
Extract elevation for line-of-sight LoSNode at position i.
Definition abstractlos.cpp:78
void applyCurvatureCorrections(bool apply, double refractionCoeff, double earthDiameter)
Specify curvature corrections settings.
Definition abstractlos.h:187
int mTargetIndex
Index of target point.
Definition abstractlos.h:304
std::shared_ptr< Point > vp()
View point for this line-of-sight.
Definition abstractlos.cpp:50
double gradient(std::size_t i)
Extract gradient value for line-of-sight LoSNode at position i.
Definition abstractlos.cpp:100
double distance(std::size_t i)
Extract distance for line-of-sight LoSNode at position i.
Definition abstractlos.cpp:95
Class representing cell events for Van Kreveld's plane sweep algorithm. Stores cell position (row and...
Definition cellevent.h:17
Representation of single cell that creates a point on LoS.
Definition losnode.h:19