-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.html
157 lines (133 loc) · 4.63 KB
/
Mesh.html
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Geoprocessing - Viewshed - 4.1</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#paneDiv {
position: absolute;
top: 18px;
right: 18px;
padding: 12px;
background-color: rgba(0, 0, 0, 0.5);
color: white;
width: 200px;
}
</style>
<link rel="stylesheet" href="https://140.175.104.210/arcgis_js_api/library/4.1/4.1/esri/css/main.css">
<script src="https://140.175.104.210/arcgis_js_api/library/4.1/4.1/init.js"></script>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/layers/GraphicsLayer",
"esri/Graphic",
"esri/geometry/Point",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/tasks/Geoprocessor",
"esri/tasks/support/LinearUnit",
"esri/tasks/support/FeatureSet",
"dojo/domReady!"
],
function(Map, SceneView, GraphicsLayer, Graphic, Point,
SimpleMarkerSymbol, SimpleFillSymbol, Geoprocessor,
LinearUnit, FeatureSet) {
var gpUrl =
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed";
var map = new Map({
basemap: "hybrid",
ground: "world-elevation"
});
var view = new SceneView({
container: "viewDiv",
map: map,
camera: { // autocasts as new Camera()
position: [7.59564, 46.06595, 5184],
tilt: 70
}
});
var graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);
var markerSymbol = new SimpleMarkerSymbol({
color: [255, 0, 0],
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255],
width: 2
}
});
var fillSymbol = new SimpleFillSymbol({
color: [226, 119, 40, 0.75],
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255],
width: 1
}
});
var gp = new Geoprocessor(gpUrl);
gp.outSpatialReference = { // autocasts as new SpatialReference()
wkid: 102100
};
view.on("click", computeViewshed);
function computeViewshed(event) {
graphicsLayer.removeAll();
var point = new Point({
longitude: event.mapPoint.longitude,
latitude: event.mapPoint.latitude
});
var inputGraphic = new Graphic({
geometry: point,
symbol: markerSymbol
});
graphicsLayer.add(inputGraphic);
var inputGraphicContainer = [];
inputGraphicContainer.push(inputGraphic);
var featureSet = new FeatureSet();
featureSet.features = inputGraphicContainer;
var vsDistance = new LinearUnit();
vsDistance.distance = 5;
vsDistance.units = "miles";
var params = {
"Input_Observation_Point": featureSet,
"Viewshed_Distance": vsDistance
};
gp.execute(params).then(drawResultData);
}
function drawResultData(result) {
var resultFeatures = result.results[0].value.features;
// Assign each resulting graphic a symbol
var viewshedGraphics = resultFeatures.map(function(feature) {
feature.symbol = fillSymbol;
return feature;
});
// Add the resulting graphics to the graphics layer
graphicsLayer.addMany(viewshedGraphics);
/********************************************************************
* Animate to the result. This is a temporary workaround
* for animating to an array of graphics in a SceneView. In a future
* release, you will be able to replicate this behavior by passing
* the graphics directly to the goTo function, like the following:
*
* view.goTo(viewshedGraphics);
********************************************************************/
view.goTo({
target: viewshedGraphics,
tilt: 0
});
}
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<div id="paneDiv">Click on map to execute ViewShed GP Task</div>
</body>
</html>