-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
328 lines (279 loc) · 12.5 KB
/
index.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8" />
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<script src="http://40.117.232.169:8080/3d/libs/Cesium-1.85/Build/Cesium/Cesium.js"></script>
<script src="http://40.117.232.169:8080/3d/libs/Cesium-1.85/Apps/Sandcastle/Sandcastle-header.js"></script>
<title>Cesium Viewer</title>
</head>
<style>
@import url(http://40.117.232.169:8080/3d/libs/Cesium-1.85/Apps/Sandcastle/CesiumSandcastle.css);
@import url(http://40.117.232.169:8080/3d/libs/Cesium-1.85/Apps/Sandcastle/templates/bucket.css);
</style>
<body>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay">
<h1>Loading...</h1>
</div>
<div id="toolbar"></div>
<script type="text/javascript">
var viewer = new Cesium.Viewer("cesiumContainer",{
Geocoder: false,
Animation: true,
CreditsDisplay: false,
Timeline: false,
FullscreenButton: false
});
viewer.scene.primitives.add(Cesium.createOsmBuildings());
// Add a WMS imagery layer
var imageryLayers = viewer.imageryLayers;
/*imageryLayers.addImageryProvider(
new Cesium.WebMapServiceImageryProvider({
url:"http://40.117.232.169:8080/geoserver/wms",
layers: "topp:states",
parameters: {
transparent: true,
format: "image/png",
},
})
);*/
imageryLayers.addImageryProvider(
new Cesium.WebMapServiceImageryProvider({
url: "http://40.117.232.169:8080/geoserver/wms",
layers: "india:india_state",
parameters: {
transparent: true,
format: "image/png",
},
})
);
// Start off looking at USA.
viewer.camera.setView({
destination: Cesium.Rectangle.fromDegrees(
-125.77,
49.83,
-62.00,
23.00
),
});
Sandcastle.addToolbarMenu(
[{
text: "Select Layer",
onselect: function() {
}
},
{
text: "USA Population-Simple Style",
onselect: function() {
viewer.dataSources.add(
Cesium.GeoJsonDataSource.load(
"http://40.117.232.169:8080/geoserver/topp/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=topp%3Astates&outputFormat=application%2Fjson"
)
);
/* viewer.camera.lookAt(
Cesium.Cartesian3.fromDegrees(-98.0, 40.0),
new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0)
);*/
var rectangle = Cesium.Rectangle.fromDegrees(-126.6, 21.76, -65.44, 52.64);
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(-97.98, 18.55, 4300000),
orientation: {
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-65.0),
roll: 0.0,
},
});
},
},
{
text: "USA Population- Extrude",
onselect: function() {
Cesium.Math.setRandomNumberSeed(0);
var usa = Cesium.GeoJsonDataSource.load(
"http://40.117.232.169:8080/geoserver/topp/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=topp%3Astates&outputFormat=application%2Fjson"
);
usa
.then(function(dataSource) {
viewer.dataSources.add(dataSource);
//Get the array of entities
var entities = dataSource.entities.values;
var colorHash = {};
for (var i = 0; i < entities.length; i++) {
//For each entity, create a random color based on the state name.
//Some states have multiple entities, so we store the color in a
//hash so that we use the same color for the entire state.
var entity = entities[i];
var name = entity.name;
var color = colorHash[name];
if (!color) {
color = Cesium.Color.fromRandom({
alpha: 1.0,
});
colorHash[name] = color;
}
//Set the polygon material to our random color.
entity.polygon.material = color;
//Remove the outlines.
entity.polygon.outline = false;
//Extrude the polygon based on the state's population. Each entity
//stores the properties for the GeoJSON feature it was created from
//Since the population is a huge number, we divide by 50.
entity.polygon.extrudedHeight =
entity.properties.PERSONS / 50.0;
}
})
.otherwise(function(error) {
//Display any errrors encountered while loading.
window.alert(error);
});
var rectangle = Cesium.Rectangle.fromDegrees(-126.6, 21.76, -65.44, 52.64);
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(-97.98, 18.55, 4300000),
orientation: {
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-65.0),
roll: 0.0,
},
easingFunction: Cesium.EasingFunction.QUADRATIC_IN_OUT,
duration: 5
});
}
},
{
text: "Buildings",
onselect: function() {
Cesium.Math.setRandomNumberSeed(0);
var promise = Cesium.GeoJsonDataSource.load(
"building.geojson"
);
promise
.then(function(dataSource) {
viewer.dataSources.add(dataSource);
//Get the array of entities
var entities = dataSource.entities.values;
var colorHash = {};
for (var i = 0; i < entities.length; i++) {
//For each entity, create a random color based on the state name.
//Some states have multiple entities, so we store the color in a
//hash so that we use the same color for the entire state.
var entity = entities[i];
var name = entity.id;
var color = colorHash[name];
if (!color) {
color = Cesium.Color.fromRandom({
alpha: 1.0,
});
colorHash[name] = color;
}
//Set the polygon material to our random color.
entity.polygon.material = color;
//Remove the outlines.
entity.polygon.outline = false;
//Extrude the polygon based on the state's population. Each entity
//stores the properties for the GeoJSON feature it was created from
//Since the population is a huge number, we divide by 50.
entity.polygon.extrudedHeight =
entity.properties.height;
}
})
.otherwise(function(error) {
//Display any errrors encountered while loading.
window.alert(error);
});
/* viewer.camera.lookAt(
Cesium.Cartesian3.fromDegrees(77.369,28.6321),
new Cesium.Cartesian3(0.0, -1000, 1500)
);*/
var rectangle = Cesium.Rectangle.fromDegrees(77.365, 28.628, 77.3739, 28.636);
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(77.37021, 28.61397, 1500.0),
orientation: {
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-35.0),
roll: 0.0,
},
easingFunction: Cesium.EasingFunction.QUADRATIC_IN_OUT,
duration: 5
});
}
},
{
text: "India",
onselect: function() {
Cesium.Math.setRandomNumberSeed(0);
var promise = Cesium.GeoJsonDataSource.load(
"http://40.117.232.169:8080/geoserver/india/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=india%3Aindia_state&outputFormat=application%2Fjson"
);
promise
.then(function(dataSource) {
viewer.dataSources.add(dataSource);
//Get the array of entities
var entities = dataSource.entities.values;
var colorHash = {};
for (var i = 0; i < entities.length; i++) {
//For each entity, create a random color based on the state name.
//Some states have multiple entities, so we store the color in a
//hash so that we use the same color for the entire state.
var entity = entities[i];
var name = entity.name;
var color = colorHash[name];
if (!color) {
color = Cesium.Color.fromRandom({
alpha: 1.0,
});
colorHash[name] = color;
}
//Set the polygon material to our random color.
entity.polygon.material = color;
//Remove the outlines.
entity.polygon.outline = false;
//Extrude the polygon based on the state's population. Each entity
//stores the properties for the GeoJSON feature it was created from
//Since the population is a huge number, we divide by 50.
entity.polygon.extrudedHeight =
entity.properties.gid * 5000;
}
})
.otherwise(function(error) {
//Display any errrors encountered while loading.
window.alert(error);
});
/* viewer.camera.lookAt(
Cesium.Cartesian3.fromDegrees(82.0,26.0),
new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0)
);*/
var rectangle = Cesium.Rectangle.fromDegrees(77.365, 28.628, 77.3739, 28.636);
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(78.59, 3.16, 4930000.0),
orientation: {
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-65.0),
roll: 0.0,
},
});
}
},
{
text: "Remove All",
onselect: function() {
viewer.dataSources.removeAll();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
}
}
],
"toolbar"
);
Sandcastle.reset = function() {
viewer.dataSources.removeAll();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
};
</script>
</body>
</html>