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
viewshedutils.h
1#pragma once
2#include "viewshed_export.h"
3
4#include <limits>
5#include <memory>
6#include <string>
7
8#include "viewshedtypes.h"
9
10class OGRSpatialReference;
11class SingleBandRaster;
12
13using viewshed::ViewshedAlgorithms;
14
15namespace viewshed
16{
18 class AbstractLoS;
19 class LoSNode;
20
26 struct DLL_API DataTriplet
27 {
28 DataTriplet( double f, double s, bool t )
29 {
30 first = f;
31 second = s;
32 third = t;
33 };
34
35 double first;
36 double second;
37 bool third;
38 };
39
44 class DLL_API ViewshedUtils
45 {
46 public:
54 static void saveToCsv( std::vector<DataTriplet> data, std::string header, std::string fileName );
55
63 static void saveToCsv( std::vector<std::string> rows, std::string header, std::string fileName );
64
71 static std::vector<DataTriplet> distanceElevation( std::shared_ptr<AbstractLoS> los );
72
73 static std::vector<std::pair<double, double>> rasterCoordinates( std::shared_ptr<std::vector<LoSNode>> los,
74 LoSNode poi );
75
82 static double earthDiameter( OGRSpatialReference crs );
83
92 static bool validateRaster( std::shared_ptr<SingleBandRaster> r1, std::string &error );
93
104 static bool compareRasters( std::shared_ptr<SingleBandRaster> r1, std::shared_ptr<SingleBandRaster> r2,
105 std::string &error );
106
113 static std::shared_ptr<ViewshedAlgorithms> allAlgorithms();
114
122 static std::shared_ptr<ViewshedAlgorithms> allAlgorithms( double invisibleValue );
123
124 static bool doubleEqual( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
125 };
126} // namespace viewshed
Abstract class that represent line-of-sight (LoS). Consists of LoSNodes, view point and target point ...
Definition abstractlos.h:25
Base class for all Viewshed Algorithms.
Definition abstractviewshedalgorithm.h:19
Representation of single cell that creates a point on LoS.
Definition losnode.h:19
Class that contains mostly static helper functions.
Definition viewshedutils.h:45
static void saveToCsv(std::vector< DataTriplet > data, std::string header, std::string fileName)
Save data vector of DataTriplets as CSV file.
Definition viewshedutils.cpp:42
static double earthDiameter(OGRSpatialReference crs)
Extract Earth's diameter from ellipsoid associated with provided coordinate reference system.
Definition viewshedutils.cpp:107
static bool compareRasters(std::shared_ptr< SingleBandRaster > r1, std::shared_ptr< SingleBandRaster > r2, std::string &error)
Checks if the two rasters have the same properties and that one can be used visibility calculation ma...
Definition viewshedutils.cpp:122
static std::shared_ptr< ViewshedAlgorithms > allAlgorithms()
Returns list of all implemented viewshed indices as algorithms to be used in viewshed of inverse view...
Definition viewshedutils.cpp:195
static bool validateRaster(std::shared_ptr< SingleBandRaster > r1, std::string &error)
Validate the raster for viewshed calculation, checks if it fulfills all the requirements.
Definition viewshedutils.cpp:160
static std::vector< DataTriplet > distanceElevation(std::shared_ptr< AbstractLoS > los)
Extracts triplets of distance, elevation and target point (boolean) from provided LoS.
Definition viewshedutils.cpp:72