forked from PHerzig/EarthServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_BGS.html
163 lines (137 loc) · 8.65 KB
/
example_BGS.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
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Earth Demo</title>
<link rel="stylesheet" type="text/css" href="css/x3dom.css" />
<link rel="stylesheet" type="text/css" href="css/earthservergenericclient.css" />
<link rel="stylesheet" type="text/css" href="js-ext/jquery-ui/themes/base/jquery-ui.css">
<script type="text/javascript" src="js-ext/x3dom-full.js"></script>
<script type="text/javascript" src="js-ext/jquery-ui/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js-ext/jquery-ui/ui/jquery-ui.js"></script>
<script type="text/javascript" src="js/EarthServerClient.js"></script>
<script type="text/javascript">
// basic setup:
EarthServerGenericClient.MainScene.setTimeLog(false);//TimeLogging: outputs time of loading and building the models to the console
EarthServerGenericClient.MainScene.addLightToScene(true);//Adds a light into the scene
// background of the render window
EarthServerGenericClient.MainScene.setBackground("0.8 0.8 0.95 0.4 0.5 0.85 0.3 0.5 0.85 0.31 0.52 0.85","0.9 1.5 1.57","0.8 0.8 0.95 0.4 0.5 0.85 0.3 0.5 0.85 0.31 0.52 0.85","0.9 1.5 1.57");
// custom viewpoints:
//"Name","Position","orientation"
EarthServerGenericClient.MainScene.addCustomViewPoint("VP1","2055.40031 1493.57514 1595.16861","-0.50542 0.84759 0.16166 1.02493" );
EarthServerGenericClient.MainScene.addCustomViewPoint("VP2","-1591.06055 1190.31804 -2247.59188","0.00992 0.97582 0.21834 3.72105");
/* Add custom key mapping: "command","key"
* "ViewPointX": While x is a number between 1-6. Goes to viewpoint x.
* "ShowViewPoint": Prompts the current viewpoint.
* "LightDown"/"LightUp": changes the intensity of the light source.
* "ElevationDown"/ElevationUp": changes the global elevation.
*/
EarthServerGenericClient.MainScene.setShortCut("Viewpoint1","1"); // change to viewpoint 1 with "1"
EarthServerGenericClient.MainScene.setShortCut("ShowViewPoint","b"); // gives an info window with the current viewpoint
// Onclick function example
EarthServerGenericClient.MainScene.OnClickFunction = function(modelIndex,hitPoint)
{
var height = EarthServerGenericClient.MainScene.getDemValueAt3DPosition(modelIndex,hitPoint[0],hitPoint[2]);
console.log("Height at clicked position: ",height);
};
// create the models:
$(document).ready(function()
{
var BGS = new EarthServerGenericClient.Model_WCPSDemWCPS();
BGS.setName("BGS 2x WCPS");
BGS.setURLs("http://earthserver.bgs.ac.uk/petascope");
BGS.setCoverages("bgs_rs", "os_dtm");
BGS.setAreaOfInterest(400000,500000,450000,550000);
BGS.setResolution(500,500);
BGS.setOffset(0,0.2,0);
BGS.setScale(1,0.3,1);
BGS.setCoordinateReferenceSystem("http://www.opengis.net/def/crs/EPSG/0/27700");
BGS.setSidePanels(true);
var BGS_LOW = new EarthServerGenericClient.Model_WCPSDemAlpha();
BGS_LOW.setName("BGS Low Resolution");
BGS_LOW.setURL("http://earthserver.bgs.ac.uk/petascope");
BGS_LOW.setCoverages("bgs_rs", "os_dtm");// can be referenced as "$CI" and "$CD" in the WCPS Query
BGS_LOW.setAreaOfInterest(400000,500000,450000,550000);
BGS_LOW.setCoordinateReferenceSystem("http://www.opengis.net/def/crs/EPSG/0/27700");
BGS_LOW.setScale(1.0,0.2,1.0);
BGS_LOW.setOffset(0,0.8,0);
BGS_LOW.setResolution(200,200);
BGS_LOW.setWCPSForChannelRED('scale(trim($CI.red, {x:$CRS($MINX:$MAXX), y:$CRS($MINY:$MAXY) }), {x:"CRS:1"(0:$RESX), y:"CRS:1"(0:$RESZ)}, {});');
BGS_LOW.setWCPSForChannelGREEN('scale(trim($CI.green, {x:$CRS($MINX:$MAXX), y:$CRS($MINY:$MAXY) }), {x:"CRS:1"(0:$RESX), y:"CRS:1"(0:$RESZ)}, {});');
BGS_LOW.setWCPSForChannelBLUE('scale(trim($CI.blue, {x:$CRS($MINX:$MAXX), y:$CRS($MINY:$MAXY) }), {x:"CRS:1"(0:$RESX), y:"CRS:1"(0:$RESZ)}, {});');
BGS_LOW.setWCPSForChannelALPHA('(char) (((scale(trim($CD , {x:$CRS($MINX:$MAXX), y:$CRS($MINY:$MAXY)}), {x:"CRS:1"(0:$RESX), y:"CRS:1"(0:$RESZ)}, {})) / 1349) * 255)');
var Bedrock = new EarthServerGenericClient.Model_WMSDemWCPS();
Bedrock.setName("Bedrock geology on ground surface");
Bedrock.setURLs("http://ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms", "http://earthserver.bgs.ac.uk/petascope");
Bedrock.setCoverages("GBR_BGS_625k_BLS", "os_dtm");
Bedrock.setAreaOfInterest(254750.0,659824.9,265250.0,670024.9);
Bedrock.setWMSCoordinateReferenceSystem("CRS","EPSG:27700");
Bedrock.setWCPSCoordinateReferenceSystem("http://www.opengis.net/def/crs/EPSG/0/27700");
Bedrock.setScale(1.0,0.3,1.0);// Size within the cube 100%width, 30%height and 100%length
Bedrock.setOffset(0,1.0,0);
Bedrock.setResolution(256,256);// Resolution of the model
var glasgow_witi_t = new EarthServerGenericClient.Model_WCPSDemWCPS();
glasgow_witi_t.setName("Wilderness Till Formation");
glasgow_witi_t.setURLs("http://earthserver.bgs.ac.uk/petascope", "http://earthserver.bgs.ac.uk/petascope");
glasgow_witi_t.setCoverages("glasgow_witi_t", "glasgow_witi_t");
glasgow_witi_t.setAreaOfInterest(254750.0,659824.9,265250.0,670024.9);
glasgow_witi_t.setCoordinateReferenceSystem("http://www.opengis.net/def/crs/EPSG/0/27700");
glasgow_witi_t.setScale(1.0,0.3,1.0);// Size within the cube 100%width, 30%height and 100%length
glasgow_witi_t.setOffset(0,0.4,0);
glasgow_witi_t.setResolution(105,102);// Resolution of the model
// This value will be considered as NODATA in the DEM. Vertices with that value will not be used and gaps are left.
glasgow_witi_t.setDemNoDataValue(0);
// The user can set the height of the model manually to make sure multiple models have the same scaling.
// Per default this value will be determined by the difference between the dems's min and max values.
glasgow_witi_t.setHeightResolution(100);
var query = 'for i in ( $CI ) ';
query += 'return encode( ';
query += '{ ';
query += 'red: (char) 0; ';
query += 'green: (char) scale((i != -340282346638528859811704183484516925440.0) * 240, {x:"CRS:1"(0:$RESX), y:"CRS:1"(0:$RESZ)}, {}); ';
query += 'blue: (char) 0 ';
query += '} ';
query += ', "png", "nodata=0,0,0")';
glasgow_witi_t.setWCPSImageQuery(query);
demquery = 'for i in ( glasgow_witi_t ) ';
demquery += 'return encode( ';
demquery += ' scale((i != -340282346638528859811704183484516925440.0) * i, {x:"CRS:1"(0:$RESX), y:"CRS:1"(0:$RESZ)}, {}) ';
demquery += ', "csv" )';
glasgow_witi_t.setWCPSDemQuery(demquery);
// add models to the scene
EarthServerGenericClient.MainScene.addModel(BGS);
EarthServerGenericClient.MainScene.addModel(BGS_LOW);
EarthServerGenericClient.MainScene.addModel(glasgow_witi_t);
EarthServerGenericClient.MainScene.addModel(Bedrock);
// create the scene: Cube has 60% height compared to width and length
EarthServerGenericClient.MainScene.createScene('x3dScene','theScene',1,0.6,1 );
EarthServerGenericClient.MainScene.createAxisLabels("Latitude","Height","Longitude");
});
document.onload = function()
{
// register a progressbar (you can register your own or just delete this lines)
var pb = new EarthServerGenericClient.createProgressBar("progressbar");
EarthServerGenericClient.MainScene.setProgressCallback(pb.updateValue);
// create the UI
EarthServerGenericClient.MainScene.createUI('x3domUI');
// starts loading and creating the models
// here the function starts as soon as the html page is fully loaded
// you can map this function to e.g. a button
EarthServerGenericClient.MainScene.createModels();
};
</script>
</head>
<body id="body">
<div id="x3dom">
<div id="progressbar"></div>
<X3D id="x3d" showlog="false" showstat="false">
<scene id="x3dScene">
<group id="root">
<group id="theScene" DEF='theScene'></group>
</group>
</scene>
</X3D>
<div id='x3domUI'></div>
</div>
</body>
</html>