Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After using plugin only half of the world map is rendered/wrapped around cesium globe #7

Closed
bagminer opened this issue Mar 24, 2015 · 22 comments

Comments

@bagminer
Copy link

I have to render a terrain tile of particular area on the cesium globe. For that, I have used srtm data in geotiff format and used gdal utility 'gdal_retilepy' to create tiles and then added in Geoserver through imagepyramid plugin. I have inserted mySLD.xml (styled geotiff format), as mentioned in readme.md. I am using bing map as base layer.
I am getting following issues with the plugin -

  1. On rendering I am getting only half of the globe ( the half where my tile lies).
  2. All lat lon informations are wrong. I am getting random values.
  3. Elevation values are negative and too small (eg. -2.045453453e-9)

But I can view the draped terrain on the area (rendering is possible).

@kaktus40
Copy link
Owner

Hello,
my answers:

  1. It's an identified "issue". A terrain provider must implements a
    function named getTileDataAvailable which returns a boolean indicating
    if a tile is available. With this function Cesium draws only the
    availables tiles beginning by the biggest tiles to end with smallest
    tile (if nexessary). Also there is two solutions:
    a) change the code of the plug in order to always return true!
    b) add some tiles of the other hemisphere as resource!
  2. & 3. Could you send me a gdalinformation of a tiff used as resource?
    I fear your geotiff wasn't generated with the good format (integer 16)

On 24/03/2015 08:24, bik20 wrote:

I have to render a terrain tile of particular area on the cesium
globe. For that, I have used srtm data in geotiff format and used gdal
utility 'gdal_retilepy' to create tiles and then added in Geoserver
through imagepyramid plugin. I have inserted mySLD.xml (styled geotiff
format), as mentioned in readme.md. I am using bing map as base layer.
I am getting following issues with the plugin -

  1. On rendering I am getting only half of the globe ( the half where
    my tile lies).
  2. All lat lon informations are wrong. I am getting random values.
  3. Elevation values are negative and too small (eg. -2.045453453e-9)


Reply to this email directly or view it on GitHub
#7.

@bagminer
Copy link
Author

Here is the gdalinformation for srtm_52_10.tif (which was used as resource to create tiles through gdal_retile.py) -

C:> gdalinfo srtm_52_10.tif
Driver: GTiff/GeoTIFF
Files: srtm_52_10.tif
srtm_52_10.tfw
Size is 6001, 6001
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (74.999583696539048,15.000416884586059)
Pixel Size = (0.000833333333333,-0.000833333333333)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 74.9995837, 15.0004169) ( 74d59'58.50"E, 15d 0' 1.50"N)
Lower Left ( 74.9995837, 9.9995836) ( 74d59'58.50"E, 9d59'58.50"N)
Upper Right ( 80.0004170, 15.0004169) ( 80d 0' 1.50"E, 15d 0' 1.50"N)
Lower Right ( 80.0004170, 9.9995836) ( 80d 0' 1.50"E, 9d59'58.50"N)
Center ( 77.5000004, 12.5000002) ( 77d30' 0.00"E, 12d30' 0.00"N)
Band 1 Block=6001x1 Type=Int16, ColorInterp=Gray
NoData Value=-32768
/* END*/
Should this tiff file be in integer16 or in some other format for proper results ?

For issue 1, I'll try to resolve by using for suggested solutions.
Thanks !

@kaktus40
Copy link
Owner

Ok for the original resource but could you give me the result of the command for the generated tif with gdal_retile (one file is suffisant)

@bagminer
Copy link
Author

This is the gdalinfo -
C:>gdalinfo srtm_52_10_1_1.tif

Driver: GTiff/GeoTIFF
Files: srtm_52_10_1_1.tif
srtm_52_10_1_1.tif.ovr
srtm_52_10_1_1.tif.aux.xml
Size is 2048, 2048
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (74.999583999999999,15.000417000000001)
Pixel Size = (0.000833333333333,-0.000833333333333)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 74.9995840, 15.0004170) ( 74d59'58.50"E, 15d 0' 1.50"N)
Lower Left ( 74.9995840, 13.2937503) ( 74d59'58.50"E, 13d17'37.50"N)
Upper Right ( 76.7062507, 15.0004170) ( 76d42'22.50"E, 15d 0' 1.50"N)
Lower Right ( 76.7062507, 13.2937503) ( 76d42'22.50"E, 13d17'37.50"N)
Center ( 75.8529173, 14.1470837) ( 75d51'10.50"E, 14d 8'49.50"N)
Band 1 Block=256x256 Type=Int16, ColorInterp=Gray
Overviews: 1024x1024, 512x512, 256x256, 128x128

/* END */

Is there any problem with corner coordinates ? In other tiles' gdalinfo what I checked over internet, I observed that the corner coordinates were from 0.0-90.0, 0.0-0.0, 90.0-90.0,90.0-0.0,45.0-45.0, for first tile.

@kaktus40
Copy link
Owner

No for the corner it's OK,
I don't find any issue. Could you use the translate tools in order to
convert your resource?

On 24/03/2015 12:16, bik20 wrote:

This is the gdalinfo -
C:>gdalinfo srtm_52_10_1_1.tif

Driver: GTiff/GeoTIFF
Files: srtm_52_10_1_1.tif
srtm_52_10_1_1.tif.ovr
srtm_52_10_1_1.tif.aux.xml
Size is 2048, 2048
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (74.999583999999999,15.000417000000001)
Pixel Size = (0.000833333333333,-0.000833333333333)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 74.9995840, 15.0004170) ( 74d59'58.50"E, 15d 0' 1.50"N)
Lower Left ( 74.9995840, 13.2937503) ( 74d59'58.50"E, 13d17'37.50"N)
Upper Right ( 76.7062507, 15.0004170) ( 76d42'22.50"E, 15d 0' 1.50"N)
Lower Right ( 76.7062507, 13.2937503) ( 76d42'22.50"E, 13d17'37.50"N)
Center ( 75.8529173, 14.1470837) ( 75d51'10.50"E, 14d 8'49.50"N)
Band 1 Block=256x256 Type=Int16, ColorInterp=Gray
Overviews: 1024x1024, 512x512, 256x256, 128x128

/* END */

Is there any problem with corner coordinates ? In other tiles'
gdalinfo what I checked over internet, I observed that the corner
coordinates were from 0.0-90.0, 0.0-0.0, 90.0-90.0,90.0-0.0,45.0-45.0,
for first tile.


Reply to this email directly or view it on GitHub
#7 (comment).

@bagminer
Copy link
Author

Ok, thanks I will try to use gdal_translate and gdal2tiles for converting srtm tiff file into tiles .

@kaktus40
Copy link
Owner

No I meant to use
https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/blob/master/GeotiffTranslate.zip
with your original geotiff. See
https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/blob/master/GeotiffTranslate.md
.

In fact which server do you use? geoserver?

On 24/03/2015 13:29, bik20 wrote:

Ok, thanks I will try to use gdal_translate and gdal2tiles for
converting srtm tiff file into tiles .


Reply to this email directly or view it on GitHub
#7 (comment).

@bagminer
Copy link
Author

Oh... my mistake, I will give it a try.
Yes I am using Geoserver.

@kaktus40
Copy link
Owner

Did you insert bil/dds plug in in geoserver?

On 24/03/2015 17:06, bik20 wrote:

Oh... my mistake, I will give it a try.
Yes I am using Geoserver.


Reply to this email directly or view it on GitHub
#7 (comment).

@bagminer
Copy link
Author

Yes I insterted bil/dds plugin in geoserver and than provided the format type and other parameters of image/bil. What parameters I gave were similar as given in WMSparamters.md.
I tried both the methods, bil/dds plugin and styled format.

@bagminer
Copy link
Author

Thanks for the help. I resolved first issue (getting only half of the globe) by making getTileDataAvailable as always true, and the terrain is successfully draped aldo, but still I am getting wrong lat, lon and elevation values. Still I am facing this issue.
This time I am getting altitude as undefined, and lat-lon some random location value such as
lat= 30.789288932601426°; long=-123.70412384131085°; altitude=undefined meters
Here lat should be almost 13° and lon should be almost 73°,

The code what I am using is - ( In geoserver, geotifftransformed image is saved in store by adding raster data source as Geotiff)

var viewer = new Cesium.Viewer('cesiumContainer');
var scene =new Cesium.Scene(viewer);
var globe =new Cesium.Globe(Cesium.Ellipsoid.WGS84);
scene.globe=globe;
var ellipsoid = scene.globe.ellipsoid;

var terrainProvider = new Cesium.GeoserverTerrainProvider({
url : "http://localhost:8080/geoserver/bik20/wms",
layerName : "geotiff_image" // This is the Geotifftransformed image.
});
viewer.terrainProvider =terrainProvider;

var hand = new Cesium.ScreenSpaceEventHandler(scene.canvas);

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_CLICK);

@kaktus40
Copy link
Owner

Ok now to force the plug in to use the translated geotif, you must
declare an image format in the parameters:

terrainProvider = new Cesium.GeoserverTerrainProvider({
url : "http://localhost:8080/geoserver/bik20/wms",
layerName: "geotiff_image",
formatImage:{format : "image/png",extension: "png"},
service: "WMS"
});

On 24/03/2015 21:08, bik20 wrote:

Thanks for the help. I resolved first issue (getting only half of the
globe) by making getTileDataAvailable as always true, and the terrain
is successfully draped aldo, but still I am getting wrong lat, lon and
elevation values. Still I am facing this issue.

The code what I am using is - ( In geoserver, geotifftransformed image
is saved in store by adding raster data source as Geotiff)

var viewer = new Cesium.Viewer('cesiumContainer');
var scene =new Cesium.Scene(viewer);
var globe =new Cesium.Globe(Cesium.Ellipsoid.WGS84);
scene.globe=globe;
var ellipsoid = scene.globe.ellipsoid;

var terrainProvider = new Cesium.GeoserverTerrainProvider({
url : "http://localhost:8080/geoserver/bik20/wms",
layerName : "geotiff_image" // This is the Geotifftransformed image.
});
viewer.terrainProvider =terrainProvider;

var hand = new Cesium.ScreenSpaceEventHandler(scene.canvas);

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_CLICK);


Reply to this email directly or view it on GitHub
#7 (comment).

@bagminer
Copy link
Author

Still I am getting same problem with lat, lon and elevation. Infact at some locations over the terrain area on mouse click event I am not getting any values in console. I tried both ways, I created tiles after using Geotifftranslate.jar utility, then also I am getting same problem and I directly stored the translated tif in the Geoserver as Geotiff raster source. Is there any problem with my code itself.

@kaktus40
Copy link
Owner

You should use Geotifftranslate.jar on your original geotiff, generate a
pyramid with gdal_retile (don't forget to create a 0 folder for the root
geotiff) and declare a format image in geoserverTerrainProvider. Can
you send me the getCapabilities document of geoserver (in the first page
of geoserver on the right)

On 25/03/2015 06:18, bik20 wrote:

Still I am getting same problem with lat, lon and elevation. Do I have
to create tiles after using Geotifftranslate.jar utility or directly I
have to store in the Geoserver as Geotiff raster source after
translating; or is there any problem with my code itself. I have used
offset as 0 while using Geotifftranslate.jar.


Reply to this email directly or view it on GitHub
#7 (comment).

@bagminer
Copy link
Author

The issue with wrong lat and lon and elevation is resolved, there was some error with the conversion of cartesian and cartographic coordinates. I changed the example code, which I was took from readme.md of plugin, for elevation.
I changed this following code :

if (cartesian) {
var cartographic = ellipsoid.cartesianToCartographic(cartesian);
cartographic.height=globe.getHeight(cartographic);
console.log(altitude="+cartographic.height+" meters")
}

to

 if (cartesian) {
                        var cartographic = ellipsoid.cartesianToCartographic(cartesian);
                        cartographic.height=globe.getHeight(cartographic);
                        var lon = Cesium.Math.toDegrees(cartographic.longitude);
                        var lat = Cesium.Math.toDegrees(cartographic.latitude);
                        var positions=[ Cesium.Cartographic.fromDegrees(lon, lat)];
                        var promise = Cesium.sampleTerrain(terrainProvider, 12, positions);  
                        Cesium.when(promise, function(updatedPositions) {
                            console.log('Elevation is' +position[0].height);
                        });

And I removed if(movement.position != null) { , for solving the problem of not displaying any information at some click events.

Thanks for the help ! 👍 👍 👍

@kaktus40
Copy link
Owner

Ok I see what is the problem:
When you use globe.getHeight(cartographic), you have the height that Cesium knows on the cartographic position. This knowledge depends of the tiles those were downloaded. For example if only the level 0 tiles were downloaded for a position A you will have 400 meters. Once Cesium downloaded the level 12 tiles, the same request will return 150 meters.
When you use sampleTerrain, it request the tiles at the level you wished (here 12).

@bagminer
Copy link
Author

Just one more issue, the terrain tiles what I am getting is having flat surface at the peak, not pointed. Can you give me the reason behind this ?
capture

@kaktus40
Copy link
Owner

for the flat surface on peak, you gave a too high level in parameter. For SRTM that have a precision of 90 meters for each pixel, level 11 should be a max. And you could use the bil/DDS plugin

@bagminer
Copy link
Author

Thanks, just for verification, I inserted bil/DDS plugin and I am using -

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;
                }
            }

I am not getting any option for BIL format setting in Geoserver. So I am directly using. Is this procedure OK ? Or what should I do to get the settings back in Geoserver.

@kaktus40
Copy link
Owner

By default the plug in use BIL/DDS format if it's available. So You don't need to explicit formatArray or formatImage

@bagminer
Copy link
Author

Thanks again for solving the issues! 👍

@ohadmanor
Copy link

bik20 Hi,

can you help me, where did you put the getTileDataAvailable to return always true?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants