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
InverseViewshed Class Reference
Inheritance diagram for InverseViewshed:
Collaboration diagram for InverseViewshed:

Public Member Functions

 InverseViewshed (std::shared_ptr< Point > targetPoint, double observerOffset, std::shared_ptr< ProjectedSquareCellRaster > dem, std::shared_ptr< ViewshedAlgorithms > visibilityIndices, bool applyCurvatureCorrections=true, double earthDiameter=EARTH_DIAMETER, double refractionCoeff=REFRACTION_COEFFICIENT, double minimalAngle=std::numeric_limits< double >::quiet_NaN(), double maximalAngle=std::numeric_limits< double >::quiet_NaN())
void calculate (std::function< void(std::string, double)> stepsTimingCallback=[](std::string text, double time) { std::cout<< text<< time<< std::endl;}, std::function< void(int, int)> progressCallback=[](int, int) {}) override
 Calculate the viewshed. Covers all the steps - create list of events, sort list of events, parse list of events.
std::shared_ptr< InverseLoSgetLoS (OGRPoint point, bool onlyToPoint=false)
void submitToThreadpool (const CellEvent &e) override
void addEventsFromCell (int &row, int &column, const double &pixelValue, bool &solveCell) override
 Function that creates events for event list from given cell.
void calculateVisibilityRaster () override
 Calculate visibility mask of areas which are visible from point (visibility), or from which the points is visible (inverse visibility). The visibility raster is calculated using fast algorithm, significantly faster than algorithms with visibility indices.
Public Member Functions inherited from viewshed::AbstractViewshed
void initEventList ()
 Create event list for line sweep algorithm from input raster.
void sortEventList ()
 Sort event list for parsing.
void parseEventList (std::function< void(int, int)> progressCallback=[](int, int) {})
 Parse event list by individual events.
bool extractValuesFromEventList (std::shared_ptr< ProjectedSquareCellRaster > dem_, std::string fileName, std::function< double(LoSNode)> func)
 Extract values from event list into a raster and save it to file.
bool isInsideAngles (const double &eventEnterAngle, const double &eventExitAngle)
 Checks if cell with these enter and exit angles falls inside the angle limit.
void setMaximalDistance (double distance)
 Set the Maximal Distance limit value. Limits event list creation to cells within this distance limit. Value is in the same units as CRS of input raster.
void setAngles (double minAngle, double maxAngle)
 Set horizontal angle limits for viewshed calculation. 0.
void setMaxConcurentTasks (int maxTasks)
 Set the number of maximum Concurent Taks that can be prepared in thread pool for processing.
void setMaxThreads (int threads)
 Set the maximal number of threads that can be used for calculation.
void prepareMemoryRasters ()
 Initialized output rasters in memory.
virtual void submitToThreadpool (const CellEvent &e)=0
 Submit LoS with this CellEvent to threadpool for solving.
std::shared_ptr< SingleBandRaster > resultRaster (int index=0)
 Extract individual result raster.
bool saveResults (std::string location, std::string fileNamePrefix="")
 Save all result rasters into the folder, optionally using name prefix.
LoSNode statusNodeFromPoint (OGRPoint point)
 Create LoSNode from OGRPoint.
OGRPoint point (int row, int col)
 Create OGRPoint with coordinates of given row and column in the raster.
void setDefaultResultDataType (GDALDataType dataType)
 Set the Default Result Data Type to use in output rasters.
long numberOfValidCells ()
 Number of valid cells in raster - cells not containing no data.
long numberOfCellEvents ()
 Number of events in event list.
bool isValid ()
 Check if the viewshed is valid, meaning that the important point is valid.
bool hasError ()
 Check if an error occurred during calculation (e.g. in one of the worker threads).
std::string errorMessage ()
 Message of the first error that occurred during calculation, empty string if there was none.
void setVisibilityMask (std::shared_ptr< ProjectedSquareCellRaster > mask)
 Set the Visibility Mask for viewshed calculation.
long long totalCountOfLoSNodes ()
 Overall number of solved LoSNodes in all evaluated LoS.
long long sizeOfEvents ()
 Size of cell event list in bytes.
long long totalSizeOfLoS ()
 Overall size of all solved LoS in bytes.
long long meanSizeOfLoS ()
 Mean size of solved LoS in bytes.
double initLastedSeconds ()
 Number of seconds the creation of event list lasted.
double sortLastedSeconds ()
 Number of seconds the sort of event list lasted.
double parseLastedSeconds ()
 Number of seconds the parsing of event list lasted.
double processingLastedSeconds ()
 Number of seconds the calculation of viewshed indexes lasted.
long long sizeOfOutputRaster ()
 Size in bytes that one output raster takes.
int numberOfResultRasters ()
 Number of output rasters. Equals number of input algorithms.
long long sizeOfOutputRasters ()
 Size in bytes that all output raster takes.
CellEvent cellEvent (size_t i)
 Extract individual cell event from cell events.
bool saveVisibilityRaster (std::string filePath)
 Save visibility raster to file.
void calculateVisibilityMask ()
 Calculate visibility mask raster.

Additional Inherited Members

Protected Member Functions inherited from viewshed::AbstractViewshed
void recordTaskError (const std::string &message)
 Store error message from a calculation task, keeping only the first one recorded.
std::vector< LoSNodeprepareLoSWithPoint (OGRPoint point)
bool validAngles ()
Protected Attributes inherited from viewshed::AbstractViewshed
std::vector< LoSNodemLosNodes
 LoSNodes in currently solved LoS while parsing event list.
std::vector< CellEventmCellEvents
 Event list. All cell events for the input raster.
std::shared_ptr< ProjectedSquareCellRaster > mInputDsm
 Input raster with digital surface model.
std::shared_ptr< ProjectedSquareCellRaster > mVisibilityMask = nullptr
 Input raster with visibility calculation mask.
std::shared_ptr< PointmPoint
 Important point for visibility calculation. Either viewpoint (normal viewshed) or target point (inverse viewshed).
std::shared_ptr< ViewshedAlgorithms > mVisibilityIndices
 Visibility indexes to calculate while calculating this viewshed. As AbstractViewshedAlgorithm.
GDALDataType mDataType = OUTPUT_RASTER_DATA_TYPE
 Data type of output rasters.
int mDefaultBand = 1
 Default band to read from rasters.
long mValidCells = 0
long mTotalLosNodesCount = 0
long mNumberOfLos = 0
bool mInverseViewshed = false
double mMaxDistance = std::numeric_limits<double>::max()
double mMinAngle = std::numeric_limits<double>::quiet_NaN()
double mMaxAngle = std::numeric_limits<double>::quiet_NaN()
int mMaxNumberOfTasks = 100
 Maximal number of LoS to solve, that can be stored in threadpool.
double mCellSize = 0
bool mValid = false
std::mutex mTaskErrorMutex
 Guards access to mTaskError, which can be written from worker threads.
std::string mTaskError
 First error that occurred during calculation, empty if there was none.
bool mCurvatureCorrections = false
double mEarthDiameter = EARTH_DIAMETER
double mRefractionCoefficient = REFRACTION_COEFFICIENT
LoSNode mLosNodePoint
BS::thread_pool mThreadPool
 Threadpool that takes care of preparing individual threads with LoS to be solved.
std::shared_ptr< ResultRasters > mResults = std::make_shared<ResultRasters>()
std::shared_ptr< ProjectedSquareCellRaster > mVisibilityRaster = nullptr
std::chrono::nanoseconds mTimeInit
std::chrono::nanoseconds mTimeSort
std::chrono::nanoseconds mTimeParse
double mCellElevs [3]
double mAngleCenter
double mAngleEnter
double mAngleExit
double mEventDistance
CellEvent mEventCenter
CellEvent mEventEnter
CellEvent mEventExit = CellEvent()
CellEvent mEventEnterOpposite
CellEvent mEventExitOpposite = CellEvent()
double mOppositeAngleEnter
double mOppositeAngleExit
LoSNode mLoSNodeTemp = LoSNode()

Member Function Documentation

◆ addEventsFromCell()

void InverseViewshed::addEventsFromCell ( int & row,
int & column,
const double & pixelValue,
bool & solveCell )
overridevirtual

Function that creates events for event list from given cell.

Parameters
row
column
pixelValue
rasterBlock
solveCellBased on mask value, information whether center event for this cell should be created.

Implements viewshed::AbstractViewshed.

◆ calculate()

void InverseViewshed::calculate ( std::function< void(std::string, double)> stepsTimingCallback = [](std::string text, double time) { std::cout<< text<< time<< std::endl;},
std::function< void(int, int)> progressCallback = [](int, int) {} )
overridevirtual

Calculate the viewshed. Covers all the steps - create list of events, sort list of events, parse list of events.

Parameters
stepsTimingCallbackCallback function outputing message how long individual step takes.
progressCallbackCallback function outputing processes part of event list.

Implements viewshed::AbstractViewshed.

◆ calculateVisibilityRaster()

Calculate visibility mask of areas which are visible from point (visibility), or from which the points is visible (inverse visibility). The visibility raster is calculated using fast algorithm, significantly faster than algorithms with visibility indices.

Implements viewshed::AbstractViewshed.


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