mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-09 23:08:49 -05:00
resolved merge conflict (and installed gdal locally)
This commit is contained in:
6
data/scene/debugglobe/map_service_configs/TERRAIN.wms
Normal file
6
data/scene/debugglobe/map_service_configs/TERRAIN.wms
Normal file
@@ -0,0 +1,6 @@
|
||||
<GDAL_WMS>
|
||||
<Service name="TiledWMS">
|
||||
<ServerUrl>http://198.102.45.23/arcgis/rest/services/worldelevation3d/terrain3d?</ServerUrl>
|
||||
<TiledGroupName>GCS_Elevation</TiledGroupName>
|
||||
</Service>
|
||||
</GDAL_WMS>
|
||||
@@ -2,7 +2,14 @@
|
||||
<Service name="TiledWMS">
|
||||
<ServerUrl>http://map1.vis.earthdata.nasa.gov/twms-geo/twms.cgi?</ServerUrl>
|
||||
<TiledGroupName>MODIS TERRA tileset</TiledGroupName>
|
||||
<Change key="${time}">2016-04-12</Change>
|
||||
<Change key="${time}">2016-04-27</Change>
|
||||
</Service>
|
||||
<DataWindow>
|
||||
<UpperLeftX>-180.0</UpperLeftX>
|
||||
<UpperLeftY>90.0</UpperLeftY>
|
||||
<LowerRightX>180.0</LowerRightX>
|
||||
<LowerRightY>-90.0</LowerRightY>
|
||||
<YOrigin>bottom</YOrigin>
|
||||
</DataWindow>
|
||||
<MaxConnections>20</MaxConnections>
|
||||
</GDAL_WMS>
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace openspace {
|
||||
//addSwitchValue(std::shared_ptr<ClipMapGlobe>(new ClipMapGlobe(dictionary, _ellipsoid)), 1e9);
|
||||
addSwitchValue(std::shared_ptr<ChunkLodGlobe>(new ChunkLodGlobe(dictionary, _ellipsoid)), 1e9);
|
||||
addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh(dictionary)), 1e10);
|
||||
|
||||
}
|
||||
|
||||
RenderableGlobe::~RenderableGlobe() {
|
||||
|
||||
@@ -43,12 +43,21 @@ namespace openspace {
|
||||
|
||||
std::shared_ptr<Texture> 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> texture = std::shared_ptr<Texture>(new Texture(
|
||||
static_cast<void*>(imageData),
|
||||
|
||||
@@ -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(){
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "cpl_conv.h"
|
||||
#include "cpl_string.h"
|
||||
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
|
||||
// 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";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user