#Example
var terrainProvider = new Cesium.GeoserverTerrainProvider({
service: "WMS",
url : "http://localhost:8080/geoserver/elevation/wms",
layerName: "SRTM90",
xml: xmlGetCapabilities,
proxy: proxy,
heightMapWidth: 64,
heightMapHeight: 64,
offset: 0,
highest: 12000,
lowest: -500,
styleName: "grayToColor",
hasStyledImage: true,
waterMask: true,
maxLevel: 11,
formatImage: {format : "image/png",extension: "png"},
formatArray: {
format : "image/bil",
/**
* bufferIn : buffer to process (switch byte order and check the data limitations)
* size: defines the dimension of the array (size.height* size.width cells)
* highest: defines the highest altitude (without offset) of the data.
* lowest: defines the lowest altitude (without offset) of the data.
* offset: defines the offset of the data in order to adjust the limitations
*/
postProcessArray : function(bufferIn, size,highest,lowest,offset) {
var resultat;
var viewerIn = new DataView(bufferIn);
var littleEndianBuffer = new ArrayBuffer(size.height * size.width * 2);
var viewerOut = new DataView(littleEndianBuffer);
if (littleEndianBuffer.byteLength === bufferIn.byteLength) {
// time to switch bytes!!
var temp, goodCell = 0, somme = 0;
for (var i = 0; i < littleEndianBuffer.byteLength; i += 2) {
temp = viewerIn.getInt16(i, false)-offset;
if (temp > lowest && temp < highest) {
viewerOut.setInt16(i, temp, true);
somme += temp;
goodCell++;
} else {
var val = (goodCell == 0 ? 1 : somme / goodCell);
viewerOut.setInt16(i, val, true);
}
}
resultat = new Int16Array(littleEndianBuffer);
}
return resultat;
}
}
});
#Details For the example the workspace in geoserver is "elevation", the layer name is "SRTM90", the url of geoserver is "geoURL" and the name of style is "grayToColor".
parameter | mandatory | type | default value | geoserver example | geoWebCache example | comments |
---|---|---|---|---|---|---|
service | NO | String | "WMS" | "WMS" | "WMS" | indicates type of service |
layerName | YES | String | undefined | "SRTM90" | "elevation:SRTM90" | name of the layer to use |
url | NO (see comments) | String | undefined | "geoURL/elevation/wms" | "geoURL/gwc/service/wms" | URL to acces to getCapabilities document (and ressources of the layer!!). Either xml (see below) and url must be defined |
xml | NO (see comments) | XMLDocument | undefined | XMLDocument of geoURL/elevation/wms?SERVICE=WMS&REQUEST=GetCapabilities&tiled=true | XMLDocument of geoURL/gwc/service/wms?SERVICE=WMS&REQUEST=GetCapabilities&tiled=true | xml that defines the metadata of the layer. Either url (see above) and xml must be defined |
proxy | NO | Cesium.DefaultProxy | undefined | new Cesium.DefaultProxy(urlProxy) | new Cesium.DefaultProxy(urlProxy) | a proxy to get data from geoserver |
heightMapWidth | NO | Integer | 65 | 128 | defines width of tile. It seems that Cesium can't work with tile bigger than a certain size (between 129 and 256). | |
heightMapHeight | NO | Integer | 65 | 128 | defines height tile. It seems that Cesium can't work with tile bigger than a certain size (between 129 and 256). | |
offset | NO | Number | 0 | 300 | 400 | offset of the data in meters. It's positive to decrease the altitude of data received and it's negative to increase the altitude of data received |
highest | NO | Number | 12000 | 9000 | 9000 | define highest altitude of the layer. If an elevation data is higher, it will be balanced with data of the same sample. |
lowest | NO | Number | -500 | -800 | -800 | define lowest altitude of the layer. If an elevation data is lower, it will be balanced with data of the same sample. |
styleName | NO | String | undefined | "mySLD" | "mySLD" | Name of style to use for GeoserverTerrainProvider when it works with BILL/DDS or styled images (required in both case). In case of converted images, this parameter must be undefined or parameter hasStyledImage must be false (see below) |
hasStyledImage | NO | Boolean | true if styleName is defined, otherwise it's false | false | true | indicates if image type is styled or converted. see comments of styleName parameter above |
waterMask | NO | Boolean | false | false | true | Experimental. Indicates if GeoserverTerrainProvider should generate a water mask |
maxLevel | NO | Integer | 11 | 10 | 14 | Level maximum to request for the layer. For indication, with a 90 meters (or 3 seconds arc) precision data, level 11 is enough; with a 30 meters (or 1 second arc) precision data, level 13 should be enough. |
formatImage | NO | Object with members:
|
undefined | {format : "image/jpeg",extension: "jpg"} | {format : "image/png",extension: "png"} | indicates the type of image to use. If BIL/DDS was added to geoserver, in order to use converted images instead of BILL/DDS, this parameter must be defined. To use styled images without BILL/DDS, formatImage must be defined,and either hasStyledImage is defined to true or styleName must be defined. If BIL/DDS plugin is not inserted in geoserver, GeoserverTerrainProvider will use available image format |
formatArray | NO | Object with members:
|
undefined | see example | see example | Format array to use instead of default format array. This format is defined only if BIL/DDS is available in geoserver (image/bil MIME). If formatImage is an undefined parameter and image/bil MIME is available, GeoserverTerrain provider will use the default formatArray. |