Hello! I use GeoserverTerrainProvider version 1.0 and geoserver version 2.5.2.
To create elevation data I downloaded srtm_01_02.tif
and converted it: gdal_retile.py -s_srs EPSG:4326-v-r bilinear-levels 8-ps 64 64-co "TILED=YES" -co "COMPRESS=DEFLATE" -co ZLEVEL=4" -targetDir bmpyramid ./srtm_01_02.tif.
After I published in Geoserver, received http://photoshare.ru/photo11901698.html
and http://photoshare.ru/office/image.php?id=11901696
Wrote a program HelloWorld.html:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8">
<!-- Tell IE to use the latest, best version (or Chrome Frame if pre-IE11). -->
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Hello World!</title>
<script src="../Build/Cesium/Cesium.js"></script>
<script src="../Cesium-GeoserverTerrainProvider/GeoserverTerrainProvider.js"></script>
<style>
@import url(../Build/Cesium/Widgets/widgets.css);
#cesiumContainer {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
margin: 0;
overflow: hidden;
padding: 0;
font-family: sans-serif;
}
html {
height: 100%;
}
body {
padding: 0;
margin: 0;
overflow: hidden;
height: 100%;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
var widget = new Cesium.Viewer('cesiumContainer');
var scene = widget.scene;
var camera = scene.camera;
var primitives = scene.primitives;
var terrainProvider = new Cesium.GeoserverTerrainProvider({
url : "http://127.0.0.1:8080/geoserver/elevation/wms",
layerName: "bmpyramid",
heightmapWidth:64,
styleName:"mySLD",
waterMask:true
});
scene.globe.terrainProvider = terrainProvider;
var canvas = scene.canvas;
var hand = new Cesium.ScreenSpaceEventHandler(canvas);
// return altitude with double click in console.log!!
hand.setInputAction(
function (movement) {
if(movement.position != null) {
var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
if (cartesian) {
var cartographic = ellipsoid.cartesianToCartographic(cartesian);
cartographic.height=globe.getHeight(cartographic);
console.log("lat= "+(cartographic.latitude*180/Math.PI)+"°; long="+(cartographic.longitude*180/Math.PI)+"°; altitude="+cartographic.height+" meters")
}
}
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
</script>
</body>
</html>
The program is not working http://photoshare.ru/photo11901697.html .
Please help me!