![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
This data layer provides a simple interface to the terrain viewshed API and the ability to visualise a viewshed within a drawing surface.
The results of the viewshed calculation will be displayed as a single raster. This raster will have the feature name 'ViewShed', and may be manipulated in the same fashion as any other MapLink feature on the display.
This layer allows the use of custom input objects (TSLTerrainVSInput), allows access to the raw viewshed output, and allows all viewshed parameters to be set for the calculation.
To load data into this layer call the loadData method. This layer may load:
Multiple DTED files may be loaded into the layer using appendData.
By default this layer will perform all viewshed calculations asynchronously.
By default all viewshed calculations will use multiple threads to improve performance. This behaviour may be controlled using TSLTerrainVSAlgorithm::maxThreads.
Classes | |
struct | Observer |
class | Visualisation |
This class specifies how the viewshed output should be visualised. More... | |
class | VisualisationVisibility |
Public Member Functions | |
TSLViewShedDataLayer () | |
bool | valid () |
bool | appendData (const char *fileName) |
unsigned int | numObservers () const |
unsigned int | size () const |
TSLViewShedDataLayer::Observer & | observerAt (unsigned int index) |
TSLViewShedDataLayer::Observer & | operator[] (unsigned int index) |
void | addObserver (const TSLViewShedDataLayer::Observer &observer) |
bool | updateObserver (unsigned int index, const TSLViewShedDataLayer::Observer &observer) |
bool | removeObserver (unsigned int index) |
void | removeAllObservers () |
Remove all Observers from the layer. | |
void | visualisation (const TSLViewShedDataLayer::Visualisation *vis) |
bool | setDisplayParameters (const TSLMUExtent &displayExtent, unsigned int displayWidth, unsigned int displayHeight) |
bool | getSynchronousLoading () const |
void | setSynchronousLoading (bool synchronous) |
void | setCallbacks (TSLViewShedDataLayerCallbacks *callbacks) |
bool | calculateViewShed () |
TSLTerrainVSAlgorithmRFVS::LOSResult | calculateLineOfSight (double startX, double startY, double startZ, double endX, double endY, double endZ, double &blockedX, double &blockedY, double &blockedZ, bool ignoreNull=true) |
TSLTerrainDatabase * | terrainDatabase () const |
void | viewShedInputCacheLimit (unsigned int limit) |
TSLTerrainVSInput * | viewShedInput () const |
bool | viewShedInput (TSLTerrainVSInput *input) |
void | enableRawOutput (bool enable) |
TSLTerrainVSOutputArray * | rawViewShedOutput () |
bool | earthCurvatureCorrectionEnabled () const |
void | earthCurvatureCorrectionEnabled (bool enable) |
TSLTerrainVSInputEarthCurvature::LOSType | earthCurvatureCorrectionType () const |
void | earthCurvatureCorrectionType (TSLTerrainVSInputEarthCurvature::LOSType correctionType) |
unsigned int | maxOutputSize () const |
void | maxOutputSize (unsigned int maxSize) |
const TSLRenderingAttributes & | borderRendering () const |
Get the rendering attributes for viewshed borders. | |
const TSLRenderingAttributes & | observerLocationRendering () const |
Get the rendering attributes for observer locations. | |
void | borderRendering (const TSLRenderingAttributes &renderingAttributes) |
void | observerLocationRendering (const TSLRenderingAttributes &renderingAttributes) |
bool | showBorders () const |
Returns true if the viewshed borders are drawn. | |
bool | showObserverLocations () const |
Returns true if the viewshed observer locations are drawn. | |
void | showBorders (bool show) |
void | showObserverLocations (bool show) |
void * | operator new (size_t size) TSL_NO_THROW |
Allocation override for API redirection. | |
void * | operator new (size_t size, char *filename, int line) |
![]() | |
void | addDrawingCallback (TSLDataLayerDrawingCallback *drawingCallback) |
bool | addFeatureRendering (const char *featureName, TSLFeatureID featureID) |
bool | addLoader (TSLFileLoader *loader, TSLLoaderAppCallback callback, void *arg, TSLAllLoadedCallback allLoadedCallback=0, void *arg2=0) |
bool | addPathList (const TSLPathList *path_list) |
void | cancelFlashback () |
bool | clearFeatureRendering (const char *featureName, TSLFeatureID featureID) |
TSLDataHandler * | createDataHandler (const char *config_file=0) |
TSLHistoryVersion | currentVersion () const |
TSLDataHandler * | dataHandler () |
const TSLDataHandler * | dataHandler () const |
void | destroy () |
bool | entityIsVisible (const TSLEntity *entity, const TSLDrawingSurface *drawingSurface) const |
const TSLFeatureClassList * | featureList () const |
const TSLFeatureClassList * | featureList (const char *detailLayerName) const |
bool | fileModificationTime (const char *filename, TSLTimeType &lastModificationTime) |
TSLEntity * | findEntity (TSLTMC x, TSLTMC y, TSLTMC aperture, int depth, const char *featureName=0, int drawingSurfaceID=-1) |
bool | findFile (const char *filename, TSLSimpleString &foundPath) const |
void | flashbackToTimestamp (TSLHistoryTimestamp timestamp, TSLLayerArchiveCallback archiveCallback, void *arg=0) |
void | flashbackToTimestamp (TSLHistoryTimestamp timestamp, TSLLayerArchiveTileCallback archiveTileCallback, void *arg=0) |
void | flashbackToVersion (TSLHistoryVersion version, TSLLayerArchiveCallback archiveCallback, void *arg=0) |
void | flashbackToVersion (TSLHistoryVersion version, TSLLayerArchiveTileCallback archiveTileCallback, void *arg=0) |
bool | getActiveLayerName (const TSLEnvelope &extent, double screenResolution, TSLSimpleString &activeLayerName) const |
TSLEntityIterator * | getEntityIterator (const char *detailLayer, TSLSelector *selector=NULL, TSLEnvelope *extent=NULL, bool splitOptimisedPrimitives=true) |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeInt attribute, int *result) const |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeDouble attribute, double *result) const |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeBool attribute, bool *result) const |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributes *result) const |
TSLFileLoader * | getLoader () |
bool | getMUExtent (double *x1, double *y1, double *x2, double *y2, int drawingSurfaceID=-1) const |
bool | getTMCExtent (TSLTMC *x1, TSLTMC *y1, TSLTMC *x2, TSLTMC *y2, int drawingSurfaceID=-1) const |
bool | getUUExtent (double *x1, double *y1, double *x2, double *y2, const TSLDrawingSurface *drawingSurface) const |
bool | importHistory (TSLHistoryVersion mapVersion, TSLHistoryTimestamp timestamp, TSLHistoryImportSet *historySet) |
bool | latLongToTMC (double latitude, double longitude, TSLTMC *x, TSLTMC *y, bool local=false) const |
bool | latLongToTMC (int num, double *latitudes, double *longitudes, TSLTMC *xs, TSLTMC *ys, bool local=false) const |
TSLDataLayerTypeEnum | layerType () const |
bool | loadData (const char *filename) |
bool | loadRendering (const char *filename) |
void | notifyChanged (bool changed=true) |
TSLMapQuery * | query (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2, int depth=-1, const char *featureName=NULL, int drawingSurfaceID=-1) const |
TSLMapQuery * | query (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2, TSLSelector *selector, int drawingSurfaceID=-1) const |
const TSLCoordinateSystem * | getCoordinateSystem () const |
bool | queryVersionHistory (const TSLEnvelope &extent, TSLVersionHistorySet &history) |
void | refreshFlashback () |
bool | removeData () |
void | releaseResources (int surfaceID) |
bool | saveRendering (const char *filename, TSLMapLinkVersion ver=TSL_CURRENT_MAPLINK_VERSION) |
bool | setCoordinateSystem (const TSLCoordinateSystem *coordinateSystem) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeInt attribute, int value) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeDouble attribute, double value) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeBool attribute, bool value) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributes *value) |
bool | TMCToLatLong (TSLTMC x, TSLTMC y, double *latitude, double *longitude, bool local=false, bool boundCheck=true) const |
bool | TMCToLatLong (int num, TSLTMC *xs, TSLTMC *ys, double *latitudes, double *longitudes, bool local=false) const |
const TSLVersionHistorySet * | versionHistory () const |
TSLViewShedDataLayer::TSLViewShedDataLayer | ( | ) |
Constructor
Before viewshed calculations can be performed the application must call loadData with a terrain database/dted file or call viewShedInput to use a custom data source for viewshed calculations.
void TSLViewShedDataLayer::addObserver | ( | const TSLViewShedDataLayer::Observer & | observer | ) |
bool TSLViewShedDataLayer::appendData | ( | const char * | fileName | ) |
Load data into the layer without removing any existing input data.
This method may be used to load multiple DMED/DTED files into the data layer when using a TSLDTEDTerrainDatabase as the input.
If a custom TSLTerrainVSInput object has been provided to the layer or if a MapLink Terrain Database (.tdf) file has been loaded this method will return false.
fileName | The DTED or DMED file to add. |
const TSLRenderingAttributes & TSLViewShedDataLayer::borderRendering | ( | ) | const |
Get the rendering attributes for viewshed borders.
void TSLViewShedDataLayer::borderRendering | ( | const TSLRenderingAttributes & | renderingAttributes | ) |
Set the rendering attributes for viewshed borders.
The border is drawn as an ellipse, so it's rendering rules are the same as TSLEllipse rendering rules. showBorders(true) must be called for these rendering attributes to have any effect. Default rendering is applied if this method is not called.
renderingAttributes | The rendering attributes for the viewshed borders. |
TSLTerrainVSAlgorithmRFVS::LOSResult TSLViewShedDataLayer::calculateLineOfSight | ( | double | startX, |
double | startY, | ||
double | startZ, | ||
double | endX, | ||
double | endY, | ||
double | endZ, | ||
double & | blockedX, | ||
double & | blockedY, | ||
double & | blockedZ, | ||
bool | ignoreNull = true ) |
Perform a line of sight calculation, between 2 points. If the end point is not visible from the start point then the 'blocked' point will be calculated. This is the point on the terrain which blocks the line of sight between the start and end points.
startX | The X coordinate of the start point, in map units. |
startY | The Y coordinate of the start point, in map units. |
startZ | The height of the start point. This height value is absolute, and not relative to the ground. |
endX | The X coordinate of the end point, in map units. |
endY | The Y coordinate of the end point, in map units. |
endZ | The height of the end point. This height value is absolute, and not relative to the ground. |
blockedX | Populated with the X coordinate of the 'blocked' point. |
blockedY | Populated with the Y coordinate of the 'blocked' point. |
blockedZ | Populated with the height of the 'blocked' point. |
ignoreNull | If true, the algorithm will ignore nulls in the input data. If false, the calculation will terminate if a null is encountered. |
bool TSLViewShedDataLayer::calculateViewShed | ( | ) |
Perform the viewshed calculation(s)
This method must be called in order for the layer to display any data:
The resulting viewshed will be displayed by the layer when the drawing surface is redrawn, and is affected by:
bool TSLViewShedDataLayer::earthCurvatureCorrectionEnabled | ( | ) | const |
Query whether earth curvature correction is enabled.
void TSLViewShedDataLayer::earthCurvatureCorrectionEnabled | ( | bool | enable | ) |
Set whether earth curvature correction is enabled.
Enabling earth curvature corrections can have a large impact on the performance of viewshed calculations.
The correction type may be set via earthCurvatureCorrectionType.
enable | If true earth curvature corrections will be performed. |
TSLTerrainVSInputEarthCurvature::LOSType TSLViewShedDataLayer::earthCurvatureCorrectionType | ( | ) | const |
Query the type of earth curvature correction used by the layer.
void TSLViewShedDataLayer::earthCurvatureCorrectionType | ( | TSLTerrainVSInputEarthCurvature::LOSType | correctionType | ) |
Set the type of earth curvature correction to use.
The application must call earthCurvatureCorrectionEnabled to enable curvature corrections.
The default correction type is TSLTerrainVSInputEarthCurvature::LOSTypeVisual.
correctionType | The type of correction to apply. |
void TSLViewShedDataLayer::enableRawOutput | ( | bool | enable | ) |
Enable access to the raw viewshed output.
By default raw output is disabled to improve viewshed performance.
enable | If true the application may query the raw output of future viewshed operations using rawViewShedOutput(). |
bool TSLViewShedDataLayer::getSynchronousLoading | ( | ) | const |
Query whether the layer will perform calculations synchronously.
unsigned int TSLViewShedDataLayer::maxOutputSize | ( | ) | const |
Query the maximum calculation width/height in pixels.
The default value is 16,384.
void TSLViewShedDataLayer::maxOutputSize | ( | unsigned int | maxSize | ) |
Set the maximum calculation width/height in pixels.
The default value is 16,384.
Increasing this limit will have a large effect on viewshed performance and on the display performance of the data layer.
maxSize | The maximum width or height for the viewshed calculation. |
unsigned int TSLViewShedDataLayer::numObservers | ( | ) | const |
Get the number of Observers in the layer.
TSLViewShedDataLayer::Observer & TSLViewShedDataLayer::observerAt | ( | unsigned int | index | ) |
const TSLRenderingAttributes & TSLViewShedDataLayer::observerLocationRendering | ( | ) | const |
Get the rendering attributes for observer locations.
void TSLViewShedDataLayer::observerLocationRendering | ( | const TSLRenderingAttributes & | renderingAttributes | ) |
Set the rendering attributes for viewshed observer locations.
The location is drawn as a symbol, so it's rendering rules are the same as TSLSymbol rendering rules. showObserverLocations(true) must be called for these rendering attributes to have any effect. Default rendering is applied if this method is not called.
renderingAttributes | The rendering attributes for the viewshed observer locations. |
void * TSLViewShedDataLayer::operator new | ( | size_t | size | ) |
Allocation override for API redirection.
void * TSLViewShedDataLayer::operator new | ( | size_t | size, |
char * | filename, | ||
int | line ) |
When included in an MFC application in debug mode, the debug new expects this to be here. Override it and return the same as the normal one. The library must include it when compiled in release mode, since the user's application may be in debug mode.
TSLViewShedDataLayer::Observer & TSLViewShedDataLayer::operator[] | ( | unsigned int | index | ) |
TSLTerrainVSOutputArray * TSLViewShedDataLayer::rawViewShedOutput | ( | ) |
Access the raw output information from the last viewshed operation.
The returned object is reference counted. The application must call TSLTerrainVSOutput::dec() in order to delete it. As such this object may be retained by the application, even after performing another viewshed calculation.
void TSLViewShedDataLayer::removeAllObservers | ( | ) |
Remove all Observers from the layer.
bool TSLViewShedDataLayer::removeObserver | ( | unsigned int | index | ) |
void TSLViewShedDataLayer::setCallbacks | ( | TSLViewShedDataLayerCallbacks * | callbacks | ) |
Set the callback object for viewshed calculations.
This callback will be called to inform the application of viewshed progress. This callback is optional. This callback must not be deleted before the datalayer, or before calling setCallbacks(NULL).
callbacks | The callback object to use. NULL will clear the callback object. |
bool TSLViewShedDataLayer::setDisplayParameters | ( | const TSLMUExtent & | displayExtent, |
unsigned int | displayWidth, | ||
unsigned int | displayHeight ) |
This information affects which resolution of data is selected from the terrain database. The input object (by default a terrain database) may use this information to select an appropriate level of detail to perform an efficient viewshed calculation at all zoom levels.
This method should be called before each viewshed calculation.
This method will return false if a viewshed calculation is currently being performed.
displayExtent | drawing surface extent in Map Units. |
displayWidth | width of the display in pixels. |
displayHeight | height of the display in pixels. |
void TSLViewShedDataLayer::setSynchronousLoading | ( | bool | synchronous | ) |
Set whether viewshed calculations should be performed synchronously.
By default all calculations will be performed in a background thread. The application will be notified via TSLViewShedDataLayerCallbacks::onViewShedComplete when a calculation has been performed.
If true is passed to this method calculateViewShed will block the calling thread until the calculation has completed. If false is passed to this method calcualteViewShed will return immediately. The application should call pass an implementation of TSLViewShedDataLayerCallbacks to setCallbacks in order to receive notifications from the datalayer.
synchronous | true if calculations should be synchronous, false otherwise. |
bool TSLViewShedDataLayer::showBorders | ( | ) | const |
Returns true if the viewshed borders are drawn.
void TSLViewShedDataLayer::showBorders | ( | bool | show | ) |
Control whether the viewshed borders are drawn.
If show is true, an ellipse will be drawn encircling each observer's viewshed. The rendering of these ellipses is specified with the borderRendering() method.
show | The viewshed borders will be shown if show is true. |
bool TSLViewShedDataLayer::showObserverLocations | ( | ) | const |
Returns true if the viewshed observer locations are drawn.
void TSLViewShedDataLayer::showObserverLocations | ( | bool | show | ) |
Control whether the viewshed obsrever locations are drawn.
If show is true, points will be drawn at each observer's location. The rendering of these points is specified with the observerLocationRendering() method.
show | The viewshed observer locations will be shown if show is true. |
unsigned int TSLViewShedDataLayer::size | ( | ) | const |
Get the number of Observers in the layer.
TSLTerrainDatabase * TSLViewShedDataLayer::terrainDatabase | ( | ) | const |
Query the terrain database used by the layer.
If a custom input object has been provided to the layer this method will return NULL.
bool TSLViewShedDataLayer::updateObserver | ( | unsigned int | index, |
const TSLViewShedDataLayer::Observer & | observer ) |
bool TSLViewShedDataLayer::valid | ( | ) |
Query whether the layer is valid.
The layer is considered valid if data has been loaded, and at least one Observer has been added.
TSLTerrainVSInput * TSLViewShedDataLayer::viewShedInput | ( | ) | const |
Query the viewshed input object.
If a terrain database has been loaded by the layer this will return a TSLTerrainVSInputTerrainDatabase instance.
bool TSLViewShedDataLayer::viewShedInput | ( | TSLTerrainVSInput * | input | ) |
Set the viewshed input object.
This will replace any existing input object or loaded terrain database. This method will fail if a calculation is currently being performed.
input | The input object to use. |
void TSLViewShedDataLayer::viewShedInputCacheLimit | ( | unsigned int | limit | ) |
Set the cache size limit for viewshed calculations.
This cache size will be set on TSLTerrainVSInputTerrainDatabase during calculations. If a custom input object has been provided to the layer this setting will be ignored.
The default value is 64MB.
limit | The cache size limit in MB. |
void TSLViewShedDataLayer::visualisation | ( | const TSLViewShedDataLayer::Visualisation * | vis | ) |
Set the visualisation specification for viewshed calculations.
This object specifies:
The default visualisation is TSLViewShedDataLayer::VisualisationVisibility which will display whether or not each point in the calculation is visible from one or more Observers.
vis | The Visualisation to use for viewshed calculations. |