gwaldron / osgearth

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

Unable to Programmatically Open TMS Elevation Layers #2514

Closed emminizer closed 4 months ago

emminizer commented 4 months ago

Describe the bug TMSElevationLayer::open() fails programmatically. URL property does not carry forward to the TMS Image Layer under the hood.

To Reproduce Run the following code block:

    TMSImageLayer* tmsImage = new TMSImageLayer();
    tmsImage->setURL("http://readymap.org/readymap/tiles/1.0.0/116/");
    auto imageStatus = tmsImage->open();
    // 0: <empty>
    std::cout << imageStatus.code() << ": " << imageStatus.message() << "\n";

    TMSElevationLayer* tmsElev = new TMSElevationLayer();
    tmsElev->setURL("http://readymap.org/readymap/tiles/1.0.0/116/");
    auto elevStatus = tmsElev->open();
    // 3: TMS driver requires a valid "url" property
    std::cout << elevStatus.code() << ": " << elevStatus.message() << "\n";

I pasted this code into osgearth_map.cpp and saw the bad behavior when running it.

Notice that the elevation layer fails, although it was configured identically to the image layer. Debugging, it seems that the URL property from the TMS Elevation Layer does not carry into the TMS Image Layer that it creates in TMSElevationLayer::openImplementation(). I would have expected that after the new TMSImageLayer in this function that the URL would be set properly, but it is not.

This was noticed because in the last month or two we noticed that the TMS elevation layers in SIMDIS no longer load with osgEarth master, but they appear to be loading properly in https://github.com/gwaldron/osgearth/commit/9f2581a45 -- so it appears to have broken between then and now.

Expected behavior Expect in the code above that tmsElev->open() returns success.

Screenshots N/A, all code driven

Desktop (please complete the following information): Release and debug on MSVC 2022

Additional context If URL does not copy over, perhaps there are other fields specific to TMS that also do not copy over when initializing the image layer. So I did not attempt to fix myself with a targeted fix on URL.

It appears to be working if you load through a .earth file however. Perhaps this is due to the XML configuration being filled out when you go to create the TMS image layer.

gwaldron commented 4 months ago

Thanks Dan - I had fixed this bug but not yet pushed it :) Should be working as of 3001bb5f9.

emminizer commented 4 months ago

Confirmed, that fixed it, thanks!