diff --git a/data/scene/debugglobe/map_service_configs/TERRAIN.wms b/data/scene/debugglobe/map_service_configs/TERRAIN.wms new file mode 100644 index 0000000000..d755d1371a --- /dev/null +++ b/data/scene/debugglobe/map_service_configs/TERRAIN.wms @@ -0,0 +1,6 @@ + + + http://198.102.45.23/arcgis/rest/services/worldelevation3d/terrain3d? + GCS_Elevation + + diff --git a/data/scene/debugglobe/map_service_configs/TERRA_CR_B143_2016-04-12.wms b/data/scene/debugglobe/map_service_configs/TERRA_CR_B143_2016-04-12.wms index 974c7da85f..125c9b7c60 100644 --- a/data/scene/debugglobe/map_service_configs/TERRA_CR_B143_2016-04-12.wms +++ b/data/scene/debugglobe/map_service_configs/TERRA_CR_B143_2016-04-12.wms @@ -2,7 +2,14 @@ http://map1.vis.earthdata.nasa.gov/twms-geo/twms.cgi? MODIS TERRA tileset - 2016-04-12 + 2016-04-27 + + -180.0 + 90.0 + 180.0 + -90.0 + bottom + 20 diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index a9386099ef..4399b49c6b 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -72,6 +72,7 @@ namespace openspace { //addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary, _ellipsoid)), 1e9); addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary, _ellipsoid)), 1e9); addSwitchValue(std::shared_ptr(new GlobeMesh(dictionary)), 1e10); + } RenderableGlobe::~RenderableGlobe() { diff --git a/modules/globebrowsing/other/gdaldataconverter.cpp b/modules/globebrowsing/other/gdaldataconverter.cpp index b986833071..1c84e2075a 100644 --- a/modules/globebrowsing/other/gdaldataconverter.cpp +++ b/modules/globebrowsing/other/gdaldataconverter.cpp @@ -43,12 +43,21 @@ namespace openspace { std::shared_ptr GdalDataConverter::convertToOpenGLTexture(GDALDataset* dataSet) { - int nCols = dataSet->GetRasterBand(1)->GetXSize(); - int nRows = dataSet->GetRasterBand(1)->GetYSize(); + //int nCols = dataSet->GetRasterBand(1)->GetXSize(); + //int nRows = dataSet->GetRasterBand(1)->GetYSize(); + + //int nLayers = dataSet->GetLayerCount(); + //int nRasters = dataSet->GetRasterCount(); + + int overviewCount = dataSet->GetRasterBand(1)->GetOverviewCount(); + + GDALRasterBand* redBand = dataSet->GetRasterBand(1)->GetOverview(overviewCount - 4); + GDALRasterBand* greenBand = dataSet->GetRasterBand(2)->GetOverview(overviewCount - 4); + GDALRasterBand* blueBand = dataSet->GetRasterBand(3)->GetOverview(overviewCount - 4); + + int nCols = redBand->GetXSize(); + int nRows = redBand->GetYSize(); - GDALRasterBand* redBand = dataSet->GetRasterBand(1); - GDALRasterBand* greenBand = dataSet->GetRasterBand(2); - GDALRasterBand* blueBand = dataSet->GetRasterBand(3); int blockSizeX; int blockSizeY; @@ -59,17 +68,78 @@ namespace openspace { int nBlocksY = nRows / blockSizeY; // A block where data is copied - GByte* blockR = (GByte*)CPLMalloc(sizeof(GByte) * blockSizeX * blockSizeY); - GByte* blockG = (GByte*)CPLMalloc(sizeof(GByte) * blockSizeX * blockSizeY); - GByte* blockB = (GByte*)CPLMalloc(sizeof(GByte) * blockSizeX * blockSizeY); + GByte* blockR = (GByte*)CPLMalloc(sizeof(GByte) * nCols * nRows); + GByte* blockG = (GByte*)CPLMalloc(sizeof(GByte) * nCols * nRows); + GByte* blockB = (GByte*)CPLMalloc(sizeof(GByte) * nCols * nRows); // The data that the texture should use GLubyte* imageData = (GLubyte*)CPLMalloc(sizeof(GLubyte) * nCols * nRows * 4); + redBand->RasterIO( + GF_Read, + 0, + 0, + nCols, + nRows, + blockR, + nCols, + nRows, + GDT_Byte, + 0, + 0); + + greenBand->RasterIO( + GF_Read, + 0, + 0, + nCols, + nRows, + blockG, + nCols, + nRows, + GDT_Byte, + 0, + 0); + + blueBand->RasterIO( + GF_Read, + 0, + 0, + nCols, + nRows, + blockB, + nCols, + nRows, + GDT_Byte, + 0, + 0); + + + // For each pixel + for (size_t y = 0; y < nRows; y++) + { + for (size_t x = 0; x < nCols; x++) + { + size_t pixelIndexInBlock = x + y * nCols; + size_t globalPixelIndex = (x + y * nCols) * 4; + + GLubyte pixelR = blockR[pixelIndexInBlock]; + GLubyte pixelG = blockG[pixelIndexInBlock]; + GLubyte pixelB = blockB[pixelIndexInBlock]; + + imageData[globalPixelIndex + 0] = pixelR; + imageData[globalPixelIndex + 1] = pixelG; + imageData[globalPixelIndex + 2] = pixelB; + imageData[globalPixelIndex + 3] = 255; + } + } + + /* // For each block for (size_t blockY = 0; blockY < nBlocksY; blockY++) { for (size_t blockX = 0; blockX < nBlocksX; blockX++) { + redBand->ReadBlock(blockX, blockY, blockR); greenBand->ReadBlock(blockX, blockY, blockG); blueBand->ReadBlock(blockX, blockY, blockB); @@ -100,7 +170,7 @@ namespace openspace { } } } - + */ // The texture should take ownership of the data std::shared_ptr texture = std::shared_ptr(new Texture( static_cast(imageData), diff --git a/modules/globebrowsing/other/texturetileset.cpp b/modules/globebrowsing/other/texturetileset.cpp index 89c371ec9f..8e1548307f 100644 --- a/modules/globebrowsing/other/texturetileset.cpp +++ b/modules/globebrowsing/other/texturetileset.cpp @@ -56,10 +56,12 @@ namespace openspace { // Read using GDAL - /* + std::string testFile = absPath("map_service_configs/TERRA_CR_B143_2016-04-12.wms"); + + GDALDataset *poDataset; GDALAllRegister(); - poDataset = (GDALDataset *)GDALOpen(absPath("textures/earth_bluemarble.jpg").c_str(), GA_ReadOnly); + poDataset = (GDALDataset *)GDALOpen(testFile.c_str(), GA_ReadOnly); assert(poDataset != NULL); GdalDataConverter conv; @@ -67,8 +69,8 @@ namespace openspace { _testTexture->uploadTexture(); _testTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); - */ - + + /* // Set e texture to test std::string fileName = "textures/earth_bluemarble.jpg"; @@ -85,7 +87,7 @@ namespace openspace { //_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); _testTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); } - + */ } TextureTileSet::~TextureTileSet(){ diff --git a/modules/globebrowsing/shaders/simple_fs.glsl b/modules/globebrowsing/shaders/simple_fs.glsl index dd6dfbe913..0e063e3554 100644 --- a/modules/globebrowsing/shaders/simple_fs.glsl +++ b/modules/globebrowsing/shaders/simple_fs.glsl @@ -51,9 +51,9 @@ Fragment getFragment() { Fragment frag; frag.color = texture(textureSampler, vec2(uvTransformPatchToTile * vec3(vs_uv.s, vs_uv.t, 1))); - frag.color = frag.color * 0.5 + 0.999*texture(textureSampler, vs_uv); + //frag.color = frag.color * 0.5 + 0.999*texture(textureSampler, vs_uv); - vec4 uvColor = vec4(fract(vs_uv * segmentsPerPatch / 10), 0.4,1); + vec4 uvColor = vec4(fract(vs_uv * segmentsPerPatch), 0.4,1); frag.color = frag.color.a < 0.1 ? uvColor * 0.5 : frag.color; frag.depth = pscDepth(vs_position); diff --git a/tests/test_gdalwms.inl b/tests/test_gdalwms.inl index 80d522a963..ff1ce5c12d 100644 --- a/tests/test_gdalwms.inl +++ b/tests/test_gdalwms.inl @@ -33,6 +33,8 @@ #include "cpl_conv.h" #include "cpl_string.h" +#include + // Error: cannot open source file "wms/wmsdriver.h" //#include "wms/wmsdriver.h" @@ -56,5 +58,4 @@ TEST_F(GdalWmsTest, Simple) { // This assertion fails ASSERT_NE(poDataset, nullptr) << "Failed to load testFile"; - }