A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/qt/cpp/sample-code/hillshade-renderer/ below:

Hillshade renderer | ArcGIS Maps SDK for Qt

View on GitHub Sample viewer app

Apply a hillshade renderer to a raster.

Use case

An environmental agency may track coastal erosion by comparing images of an area taken over a a longer period of time with hillshade renderers applied.

How to use the sample

Choose and adjust the settings to update the hillshade renderer on the raster layer. The sample allows you to change the Altitude, Azimuth, and Slope Type.

How it works
  1. Create a Raster from a grayscale raster file.
  2. Create a RasterLayer from the raster.
  3. Create a Basemap from the raster layer and set it to the map.
  4. Create a HillshadeRenderer, specifying the slope type and other properties, new HillshadeRenderer(Altitude, Azimuth, ZFactor, SlopeType, PixelSizeFactor, PixelSizePower, OutputBitDepth).
  5. Set the hillshade renderer to be used on the raster layer with rasterLayer::setRenderer(renderer).
Relevant API Offline Data

Read more about how to set up the sample's offline data here.

Link Local Location Hillshade raster <userhome>/ArcGIS/Runtime/Data/raster/srtm.tiff

altitude, angle, azimuth, raster, slope, visualization

Sample Code

Hillshade_Renderer.cpp Hillshade_Renderer.cpp Hillshade_Renderer.h HillshadeSettings.qml HillshadeSlopeTypeModel.qml Hillshade_Renderer.qml

Use dark colors for code blocks Copy

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// [WriteFile Name=Hillshade_Renderer, Category=Layers]
// [Legal]
// Copyright 2016 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]

#ifdef PCH_BUILD
#include "pch.hpp"
#endif // PCH_BUILD

// sample headers
#include "Hillshade_Renderer.h"

// ArcGIS Maps SDK headers
#include "Basemap.h"
#include "HillshadeRenderer.h"
#include "Map.h"
#include "MapQuickView.h"
#include "MapTypes.h"
#include "MapViewTypes.h"
#include "Raster.h"
#include "RasterLayer.h"
#include "RasterTypes.h"

// Qt headers
#include <QFuture>
#include <QStandardPaths>
#include <QUrl>
#include <QtCore/qglobal.h>

using namespace Esri::ArcGISRuntime;

// helper method to get cross platform data path
namespace
{
QString defaultDataPath()
{
  QString dataPath;

#ifdef Q_OS_IOS
  dataPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#else
  dataPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#endif

  return dataPath;
}
} // namespace

Hillshade_Renderer::Hillshade_Renderer(QQuickItem* parent /* = nullptr */):
  QQuickItem(parent)
{
}

Hillshade_Renderer::~Hillshade_Renderer() = default;

void Hillshade_Renderer::init()
{
  qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
  qmlRegisterType<Hillshade_Renderer>("Esri.Samples", 1, 0, "Hillshade_RendererSample");
}

void Hillshade_Renderer::componentComplete()
{
  QQuickItem::componentComplete();

  // find QML MapView component
  m_mapView = findChild<MapQuickView*>("mapView");
  m_mapView->setWrapAroundMode(WrapAroundMode::Disabled);

  // Create the raster and raster layer
  const QString dataPath = defaultDataPath() + "/ArcGIS/Runtime/Data/raster";
  Raster* raster = new Raster(dataPath + "/srtm.tiff", this);
  m_rasterLayer = new RasterLayer(raster, this);

  // Add the raster to the map
  Basemap* basemap = new Basemap(m_rasterLayer, this);
  Map* map = new Map(basemap, this);

  // zoom to the new layer once loaded
  connect(map, &Map::loadStatusChanged, this, [this](LoadStatus loadStatus)
  {
    if (loadStatus == LoadStatus::Loaded)
    {
      m_mapView->setViewpointScaleAsync(754479);
    }
  });
  m_mapView->setMap(map);

  //! [HillshadeRenderer apply to layer snippet]
  // Apply the hillshade renderer to the raster layer
  constexpr double altitude = 45.0;
  constexpr double azimuth = 315.0;
  constexpr double zFactor = 0.000016;
  constexpr SlopeType slopeType = SlopeType::None;
  constexpr double pixelSizeFactor = 1.0;
  constexpr double pixelSizePower = 1.0;
  constexpr int outputBitDepth = 8;
  HillshadeRenderer* hillshadeRenderer = new HillshadeRenderer(altitude, azimuth, zFactor, slopeType, pixelSizeFactor, pixelSizePower, outputBitDepth, this);
  m_rasterLayer->setRenderer(hillshadeRenderer);
  //! [HillshadeRenderer apply to layer snippet]
}

void Hillshade_Renderer::applyHillshadeRenderer(double altitude, double azimuth, int slope)
{
  // create the new renderer
  SlopeType slopeType = static_cast<SlopeType>(slope);
  HillshadeRenderer* hillshadeRenderer = new HillshadeRenderer(altitude, azimuth, 0.000016, slopeType, 1.0, 1.0, 8, this);

  // set the renderer on the layer
  m_rasterLayer->setRenderer(hillshadeRenderer);
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4