Line of sight (geoelement)

View inQMLC++
View on GitHub
Sample viewer app

Show a line of sight between two moving objects.

screenshot

Use case

A line of sight between GeoElements (i.e. observer and target) will not remain constant whilst one or both are on the move.

A GeoElementLineOfSight is therefore useful in cases where visibility between two GeoElements requires monitoring over a period of time in a partially obstructed field of view (such as buildings in a city).

How to use the sample

A line of sight will display between a point on the Empire State Building (observer) and a taxi (target). The taxi will drive around a block and the line of sight should automatically update. The taxi will be highlighted when it is visible. You can change the observer height with the slider to see how it affects the target's visibility.

How it works

  1. Instantiate an AnalysisOverlay and add it to the SceneView's analysis overlays collection.
  2. Instantiate a GeoElementLineOfSight, passing in observer and target GeoElements (features or graphics). Add the line of sight to the analysis overlay's analyses collection.
  3. To get the target visibility when it changes, react to the target visibility changing on the GeoElementLineOfSight instance.

Relevant API

  • AnalysisOverlay
  • GeoElementLineOfSight
  • LineOfSight::targetVisibility

Offline data

Link Local Location
Taxi CAD <userhome>/ArcGIS/Runtime/Data/3D/dolmus\_3ds/dolmus.zip

Tags

3D, line of sight, visibility, visibility analysis

Sample Code

LineOfSightGeoElement.qmlLineOfSightGeoElement.cppLineOfSightGeoElement.h
                                                              
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// [WriteFile Name=LineOfSightGeoElement, Category=Analysis]
// [Legal]
// Copyright 2019 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0

Item {
    SceneView {
        id: view
        anchors.fill: parent

        Rectangle {
            anchors {
                margins: 5
                left: parent.left
                top: parent.top
                bottom: view.attributionTop
            }
            color: Qt.rgba(0.7, 0.7, 0.7, 0.7);
            radius: 10
            width: childrenRect.width

            Slider {
                id: heightSlider

                anchors {
                    top: parent.top
                    bottom: parent.bottom
                    margins: 5
                }
                from: 150
                to: 300
                stepSize: 10
                value: model.heightZ
                orientation: Qt.Vertical
                onMoved: {
                    model.heightZ = value;
                }
            }
        }
    }

    // Declare the C++ instance which creates the scene etc. and supply the view
    LineOfSightGeoElementSample {
        id: model
        sceneView: view
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.