gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.47k stars 772 forks source link

GDALImageLayer - doesn't work in Debug configuration #2554

Closed gfyrtuwcv closed 2 months ago

gfyrtuwcv commented 2 months ago

I built with the latest version of osgearth, and when I use GDALImageLayer or read simple.earth, the earth is represented as white

I use the code

osg::ref_ptrbaselayer = new `osgEarth::GDALImageLayer(); baselayer->setURL("world.tif"); map->addLayer(baselayer);

The result is something like this image

But loading other layers like ArcGISServerImageLayer or WMSImageLayer is no problem,How do I solve this problem?

The following is part DEBUG_INFO:

[osgearth info] [Map] Map profile is: [srs=WGS84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [osgearth info] [Map] [no cache] [osgearth debug] [ElevationPool] Refreshing EP index [osgearth debug] Creating Profile from source's geographic SRS: WGS 84 [osgearth debug] [GDAL] Geo extents: -180, -90 -> 180, 90 [osgearth info] [GDAL] Resolution= 0.175781x0.175781 max=0.175781 [osgearth info] [GDAL] world.tif max Data Level: 3 [osgearth debug] [GDAL] GeoExtent = SW=-180,-90 NE=180,90, SRS=WGS 84 [osgearth debug] [GDAL] Set Profile to [srs=WGS 84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [osgearth info] [GDALImageLayer] "[GDALImageLayer]" [srs=WGS 84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [no cache] [osgearth debug] [Earth Plugin] Forced load: osgEarthOSGEARTH_LIBRARY_POSTFIX.dll [osgearth debug] [Earth Plugin] No valid earth file version; assuming version='2' [osgearth info] [Map] Map profile is: [srs=WGS84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [osgearth info] [Map] [no cache] [osgearth debug] [ElevationPool] Refreshing EP index [osgearth debug] Creating Profile from source's geographic SRS: WGS 84 [osgearth debug] [GDAL] Geo extents: -180, -90 -> 180, 90 [osgearth info] [GDAL] Resolution= 0.175781x0.175781 max=0.175781 [osgearth info] [GDAL] E:/source/testcs/out/build/x64-debug/world.tif max Data Level: 3 [osgearth debug] [GDAL] GeoExtent = SW=-180,-90 NE=180,90, SRS=WGS 84 [osgearth debug] [GDAL] Set Profile to [srs=WGS 84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [osgearth info] [GDALImageLayer] "World GeoTIFF" [srs=WGS 84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [no cache] [osgearth debug] [EarthManip] setViewpoint: [osgearth debug] from x=0, y=90, z=-6.35675e+06, h=0, p=-90, d=1m, xo=0, yo=0, zo=0 [osgearth debug] to x=-90, y=0, z=0, h=0, p=-89, d=1.91344e+07m, xo=0, yo=0, zo=0 [osgearth debug] [EarthManip] setViewpoint: [osgearth debug] from x=-90, y=0, z=-9.31323e-10, h=0, p=-89, d=1.91344e+07m, xo=0, yo=0, zo=0 [osgearth debug] to x=-90, y=0, z=0, h=0, p=-89, d=1.91344e+07m, xo=0, yo=0, zo=0 [osgearth info] [engine_rex] Activated! [osgearth info] [TerrainResources] Texture unit 1 reserved for Terrain Color [osgearth info] [TerrainResources] Texture unit 2 reserved for Terrain Elevation [osgearth info] [TerrainResources] Texture unit 3 reserved for Terrain Normals [osgearth info] [TerrainResources] Texture unit 4 reserved for Terrain Parent Color [osgearth info] [TerrainResources] Texture unit 5 reserved for Terrain Land Cover [osgearth debug] [RexTerrainEngineNode] Render Bindings: [osgearth debug] [RexTerrainEngineNode] > Bound "oe_layer_tex" to unit 1 [osgearth debug] [RexTerrainEngineNode] > Bound "oe_layer_texParent" to unit 4 [osgearth debug] [RexTerrainEngineNode] > Bound "oe_tile_elevationTex" to unit 2 [osgearth debug] [RexTerrainEngineNode] > Bound "oe_tile_normalTex" to unit 3 [osgearth debug] [RexTerrainEngineNode] > Bound "oe_tile_landCoverTex" to unit 5 [osgearth info] [RexTerrainEngineNode] Creating 2 root keys. [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 0/0/0 [osgearth debug] - 1/2 : 0/0/0 [osgearth debug] - 1/2 : 0/0/0 [osgearth debug] [GDALImageLayer] "World GeoTIFF" create image for "0/0/0", ext= SW=-180,-90 NE=0,90, SRS=WGS84 [osgearth debug] [GDALImageLayer] "World GeoTIFF" 0/0/0result INVALID [osgearth debug] [ElevationPool] Refreshing EP index [osgearth debug] [ElevationPool] Refreshing EP index [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 0/1/0 [osgearth debug] - 2/2 : 0/1/0 [osgearth debug] - 2/2 : 0/1/0 [osgearth debug] [GDALImageLayer] "World GeoTIFF" 0/1/0result INVALID [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] getShader, mask = 11, location = 2 [osgearth debug] getShader, mask = 11, location = 2 [osgearth debug] getShader, mask = 11, location = 2 [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 1/0/0 [osgearth debug] [TileNode] notify (create) key 1/1/0 [osgearth debug] [TileNode] notify (create) key 1/0/1 [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 2/0/0 [osgearth debug] [TileNode] notify (create) key 2/0/0 [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [TileNode] notify (create) key 2/1/0 [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] [TileNode] notify (create) key 2/0/1 [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 2/1/1 [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [TileNode] notify (create) key 2/2/0 [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 2/2/1 [osgearth debug] [TileNode] notify (create) key 2/3/1 [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [GDALImageLayer] "World GeoTIFF" 1/0/0result INVALID [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [GDALImageLayer] "World GeoTIFF" 1/1/0result INVALID [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/1/0result INVALID [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/0/1result INVALID [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/1/1result INVALID [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] [GDALImageLayer] "World GeoTIFF" create image for "2/2/1", ext= SW=-90,0 NE=-45,45, SRS=WGS84 [osgearth debug] [GDALImageLayer] "World GeoTIFF" create image for "2/3/1", ext= GDALImageLayerSW=-45,0 NE=0,45, SRS=WGS84World GeoTIFF" create image for " [osgearth debug] /2/0", ext= [osgearth debug] [GDALImageLayer] "World GeoTIFF" create image for "2/3/1", ext= GDALImageLayerSW=-45,0 NE=0,45, SRS=WGS84World GeoTIFF" create image for " [osgearth debug] /2/0", ext= [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/2/1result INVALID [osgearth debug] [GDALImageLayer] "World GeoTIFF" create image for "2/3/1", ext= GDALImageLayerSW=-45,0 NE=0,45, SRS=WGS84World GeoTIFF" create image for " [osgearth debug] /2/0", ext= [osgearth debug] [GDALImageLayer] "World GeoTIFF" create image for "2/3/1", ext= GDALImageLayerSW=-45,0 NE=0,45, SRS=WGS84World GeoTIFF" create image for " [osgearth debug] /2/0", ext= [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 2/0/2 [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/3/1result INVALID [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/3/0result INVALID [osgearth debug] [GDALImageLayer] "World GeoTIFF" 2/2/0result INVALID [osgearth debug] [TileNode] notify (create) key 2/0/2 [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [TileNode] notify (create) key 2/1/2 [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [TileNode] notify (create) key 2/0/3 [osgearth debug] [TileNode] notify (create) key 2/1/3 [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [TileNode] notify (create) key 2/3/2 [osgearth debug] [TileNode] notify (create) key 2/2/3 [osgearth debug] [TileNode] notify (create) key 2/2/3 [osgearth debug] [TileNode] notify (create) key 2/2/3 [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [TileNode] notify (create) key 2/3/3 [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Layer] [StyleSheet]" ~Layer [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] [Duktape] Loaded duktape JavaScript engine [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] Loaded ScriptEngine driver "javascript" OK [osgearth debug] [StateSetCache] Pruned 0 attributes, 0 statesets [osgearth debug] [GDALImageLayer] "World GeoTIFF" 1/0/1result INVALID [osgearth debug] [GDALImageLayer] "World GeoTIFF" 1/1/1result INVALID

gwaldron commented 2 months ago

It looks like GDAL is failing to read the image. I can't reproduce the problem here. What is the output of osgearth_version --caps ?

gfyrtuwcv commented 2 months ago

This is the output of osgearth_version --caps

[osgearth info] Hello, world. [osgearth info] [Registry] Note: GDAL_DATA environment variable is not set Error reading file C:/WINDOWS/fonts\CascadiaCode.ttf: file not handled [osgearth info] [Capabilities] osgEarth Version: 3.5.0 build 154 [osgearth info] [Capabilities] GDAL Version: 3.8.5 [osgearth info] [Capabilities] OSG Version: 3.6.5 [osgearth info] [Capabilities] OSG GL3 Features: yes [osgearth info] [Capabilities] OSG FFP Available: no [osgearth info] [Capabilities] CPU Cores: 8 [osgearth info] [Capabilities] GL_VENDOR: NVIDIA Corporation [osgearth info] [Capabilities] GL_RENDERER: Quadro K2200/PCIe/SSE2 [osgearth info] [Capabilities] GL_VERSION: 3.3.0 NVIDIA 516.94 [osgearth info] [Capabilities] GL CORE Profile: yes [osgearth info] Goodbye.

gfyrtuwcv commented 2 months ago

Since I installed gdal using vcpkg, I unpacked vcpkg/downloads/ osgeo-gdal-v3.8.5.tar.gz, set GDAL_DATA to the data file inside, and run osgearth again, but the gdal layer still failed to load

gwaldron commented 2 months ago

GDAL_DATA should point at the folder vcpkg_installed/x64-windows/share/gdal or something similar. It's a folder that includes a ton of data files including "epsg.wkt". But...I doubt that's the problem.

gfyrtuwcv commented 2 months ago

I modified GDAL_DATA, and then I found the problem, when I built osgearth with release, the GDALImageLayer layer was successfully displayed! But when I switch back to build osgearth in Debug mode, the white earth still appears. I configured GDAL_LIBRARY_DEBUG and GDAL_LIBRARY_RELEASE with cmakegui, but it didn't work.

gwaldron commented 2 months ago

OK thanks. I have edited the title to reflect the issue. @plevy can try to reproduce please?

gwaldron commented 2 months ago

I believe this is fixed now in b6262bf5. Let us know :)

gfyrtuwcv commented 2 months ago

Yes, I rebuilt it and it worked out!Thank you, gwaldron.