kaktus40 / Cesium-GeoserverTerrainProvider

plug in to use geoserver as terrain provider
Other
360 stars 141 forks source link

blocky terrain question #38

Closed mortac8 closed 4 years ago

mortac8 commented 4 years ago

Attached is a comparison of cgiar srtm 90m from http://srtm.csi.cgiar.org/download with Cesium World Terrain. Is there a way to reduce the blockiness of the terrain? Or is this just a result of using only 90m terrain resolution?

I configured my GeoserverTerrainProvider.js to use the 'mySLD.xml option' with WMTS. Thanks for your time! @kaktus40

image

kaktus40 commented 4 years ago

Hello

from what I see, it seems you don't use a good configuration of the bil/dds plugin. Did you try different configurations? What is your process to generate your tiff files?

mortac8 commented 4 years ago

I am not using the bil/dds plugin. I just loaded 90m terrain files from http://srtm.csi.cgiar.org/download into an ImageMosaic in GeoServer then I simply configured my layer to use the mySLD.xml style from this project's github.

What is the best way? Is it the bil/dds plugin or maybe the GeotiffTranslate script?

var terrainProvider = new Cesium.GeoserverTerrainProvider({
    service : "WMTS",
    url : "http://localhost:8080/geoserver/gwc/service/wmts",
    layerName: "cite:srtm90",
    styleName: "mySLD",
    waterMask: true
});
kaktus40 commented 4 years ago

You should check the README.md. There is a comparison for each type and some hints for processing your data.

mortac8 commented 4 years ago

Ok I got it to work for WMS in GeoServer 2.17 and Cesium 1.70.1 by doing the following:

Thank you!

What is the way to get the best performance? Use service:"WMS" providing a gwc wms endpoint?

var terrainProvider = new Cesium.GeoserverTerrainProvider({
    service: "WMS",
    url : "http://localhost:8080/geoserver/cite/wms",
    layerName: "srtm90",
    heightMapWidth: 64,
    heightMapHeight: 64,
    offset: 0,
    highest: 12000,
    lowest: -500,
    styleName: "mySLD",
    hasStyledImage: true,
    waterMask: true,
    maxLevel: 11,
    formatImage: {format : "image/png",extension: "png"},
    formatArray: {
        format : "image/bil",
        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;
        }
    }
});
kaktus40 commented 4 years ago

For a best performance, I should use WMTS (cached tiles!)

Le 12/06/2020 à 23:39, mortac8 a écrit :

Ok I got it to work for WMS by:

*

installing dds plugin from
https://docs.geoserver.org/latest/en/user/community/dds/index.html
via https://build.geoserver.org/geoserver/2.17.x/community-latest/

*

using your example at
https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/blob/master/WMSParameters.md

Thank you!

What is the way to get the best performance? Use service:"WMS" providing a gwc wms endpoint?

|var terrainProvider = new Cesium.GeoserverTerrainProvider({ service: "WMS", url : "http://localhost:8080/geoserver/cite/wms", layerName: "srtm90", //service: "WMTS", //url : "http://localhost:8080/geoserver/gwc/service/wmts", //layerName: "cite:srtm90", heightMapWidth: 64, heightMapHeight: 64, offset: 0, highest: 12000, lowest: -500, styleName: "mySLD", hasStyledImage: true, waterMask: true, maxLevel: 11, formatImage: {format : "image/png",extension: "png"}, formatArray: { format : "image/bil", 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; } } }); |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/issues/38#issuecomment-643493824, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOQ47FSDQAGWV4LZMET3L3RWKN7RANCNFSM4N4TU5JQ.

mortac8 commented 4 years ago

Does GeoServer/GeoWebCache WMTS support .bil?
Whenever I try to use WMTS I get either blocky or spiky terrain using GeoserverTerrainProvider.js as it's just using .png or .jpeg and doesn't seem to go through the more accurate .bil pipeline.

kaktus40 commented 4 years ago

Unfortunately WMTS doesn't support .bil. So you need to convert your tiff with the GeotiffTranslate script. It change elevation data into tiff files into colors (Red, Green, Blue information contains the elevation data).

With it you can use WMTS and you should use png type and not jpeg which is not a lossless format...

Le 13/06/2020 à 00:25, mortac8 a écrit :

Does GeoServer/GeoWebCache WMTS support .bil? Whenever I try to use WMTS I get either blocky or spiky terrain using GeoserverTerrainProvider.js as it's just using .png or .jpeg and doesn't seem to go through the more accurate .bil pipeline.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/issues/38#issuecomment-643506751, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOQ47CBXVPQPT2YCGWMRE3RWKTPPANCNFSM4N4TU5JQ.

mortac8 commented 4 years ago

I ran the GeotiffTranslate on the srtm4.1 dataset (90m). It looks decent but the .bil solution seems to have more accurate terrain especially when viewing near street level. By this I mean, visually the .bil solution looks better. Has this been your experience?

kaktus40 commented 4 years ago

Well done, that is normal. Is it now ok for you?

Le 14/06/2020 à 07:55, mortac8 a écrit :

I ran the GeotiffTranslate onthe srtm4.1 dataset (90m). It looks close but the .bil solution seems to have more accurate terrain. Visually the .bil solution looks better. Has this been your experience?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/issues/38#issuecomment-643722834, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOQ47GETGSR7YE4A4RK2VLRWRQ4HANCNFSM4N4TU5JQ.

mortac8 commented 4 years ago

Do you believe the best solution could be this?

gdalbuildvrt mosaic.vrt c:\srtm90\*.tif

gdal_retile -ps 2048 2048 -overlap 0 -levels 6 -s_srs EPSG:4326 -r cubicspline -ot Int16 -co TILED=YES -co COMPRESS=DEFLATE -targetDir srtm90pyramid mosaic.vrt

The deploy srtm90pyramid as an ImagePyramid in GeoServer and use image/bil method?

kaktus40 commented 4 years ago

For me it's the optimal solution for the best rendering. Nevertheless, you should be aware that Cesium use 2 rendering modes. I use the HeightmapTerrainData version and Cesium use QuantizedMeshTerrainData that is smoother in high zoom. You should see the other issues for that!

Le 14/06/2020 à 08:12, mortac8 a écrit :

Do you believe the best solution could be as follows?

|gdalbuildvrt mosaic.vrt c:\srtm90*.tif gdal_retile -ps 2048 2048 -overlap 0 -levels 6 -s_srs EPSG:4326 -r cubicspline -ot Int16 -co TILED=YES -co COMPRESS=DEFLATE -targetDir srtm90pyramid mosaic.vrt |

The deploy srtm90pyramid as an ImagePyramid in GeoServer and use image/bil method?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/issues/38#issuecomment-643724024, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOQ47BA5HE6YI2BDW7TR4TRWRS6BANCNFSM4N4TU5JQ.

mortac8 commented 4 years ago

I'm good with closing this Issue. Thanks for your advice!