Merge branch 'feature/globebrowsing' of github.com:OpenSpace/OpenSpace-Development into feature/globebrowsing

This commit is contained in:
Kalle Bladin
2016-06-06 17:40:34 -04:00
15 changed files with 255 additions and 153 deletions
+14 -2
View File
@@ -10,8 +10,20 @@ return {
Textures = {
ColorTextures = {
{
Name = "VIIRS_SNPP_CorrectedReflectance_TrueColor",
FilePath = "map_service_configs/VIIRS_SNPP_CorrectedReflectance_TrueColor.xml"
Name = "OpenStreetMap",
FilePath = "map_service_configs/OpenStreetMap.xml"
},
{
Name = "Temporal VIIRS SNPP",
FilePath = "map_service_configs/Temporal_VIIRS_SNPP_CorrectedReflectance_TrueColor.xml"
},
{
Name = "Temporal MODIS Aqua CorrectedRecflectance TrueColor",
FilePath = "map_service_configs/Temporal_MODIS_Aqua_CorrectedReflectance_TrueColor.xml"
},
{
Name = "Temporal Aqua Orbit Asc",
FilePath = "map_service_configs/Temporal_Aqua_Orbit_Asc.xml"
},
{
Name = "MODIS_Terra_CorrectedReflectance_TrueColor",
@@ -0,0 +1,36 @@
<OpenSpaceTemporalGDALDataset>
<OpenSpaceTimeStart>2012-05-08</OpenSpaceTimeStart>
<OpenSpaceTimeEnd></OpenSpaceTimeEnd>
<OpenSpaceTimeResolution>1d</OpenSpaceTimeResolution>
<OpenSpaceTimeIdFormat>YYYY-MM-DD</OpenSpaceTimeIdFormat>
<GDAL_WMS>
<Service name="WMS">
<Version>1.1.1</Version>
<ServerUrl>http://map2.vis.earthdata.nasa.gov/wms/wms.php?TIME=${OpenSpaceTimeId}</ServerUrl>
<SRS>EPSG:4326</SRS>
<ImageFormat>image/png</ImageFormat>
<Transparent>TRUE</Transparent>
<Layers>Aqua_Orbit_Asc</Layers>
</Service>
<DataWindow>
<UpperLeftX>-180.0</UpperLeftX>
<UpperLeftY>90</UpperLeftY>
<LowerRightX>396.0</LowerRightX>
<LowerRightY>-198</LowerRightY>
<TileLevel>8</TileLevel>
<TileCountX>2</TileCountX>
<TileCountY>1</TileCountY>
<YOrigin>top</YOrigin>
</DataWindow>
<Projection>EPSG:4326</Projection>
<BlockSizeX>512</BlockSizeX>
<BlockSizeY>512</BlockSizeY>
<BandsCount>3</BandsCount>
</GDAL_WMS>
</OpenSpaceTemporalGDALDataset>
<!--
https://map2.vis.earthdata.nasa.gov/wms/wms.php?TIME=2014-07-17&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Aqua_Orbit_Asc&WIDTH=512&HEIGHT=512&SRS=EPSG%3A4326&STYLES=&BBOX=46.125%2C48.375%2C46.6875%2C48.9375
https://map2.vis.earthdata.nasa.gov/wms/wms.php?TIME=2015-11-23&service=WMS&request=GetMap&version=1.1.1&layers=Aqua_Orbit_Asc&styles=&srs=EPSG:4326&transparent=FALSE&format=image/png&width=512&height=512&bbox=-180.00000000,18.00000000,-108.00000000,90.00000000
-->
@@ -0,0 +1,25 @@
<OpenSpaceTemporalGDALDataset>
<OpenSpaceTimeStart>2012-05-08</OpenSpaceTimeStart>
<OpenSpaceTimeEnd></OpenSpaceTimeEnd>
<OpenSpaceTimeResolution>1d</OpenSpaceTimeResolution>
<OpenSpaceTimeIdFormat>YYYY-MM-DD</OpenSpaceTimeIdFormat>
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://map1.vis.earthdata.nasa.gov/wmts-geo/MODIS_Aqua_CorrectedReflectance_TrueColor/default/${OpenSpaceTimeId}/EPSG4326_250m/${z}/${y}/${x}.jpg</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-180.0</UpperLeftX>
<UpperLeftY>90</UpperLeftY>
<LowerRightX>396.0</LowerRightX>
<LowerRightY>-198</LowerRightY>
<TileLevel>8</TileLevel>
<TileCountX>2</TileCountX>
<TileCountY>1</TileCountY>
<YOrigin>top</YOrigin>
</DataWindow>
<Projection>EPSG:4326</Projection>
<BlockSizeX>512</BlockSizeX>
<BlockSizeY>512</BlockSizeY>
<BandsCount>3</BandsCount>
</GDAL_WMS>
</OpenSpaceTemporalGDALDataset>
+28 -108
View File
@@ -53,8 +53,7 @@ namespace openspace {
RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
: _tileProviderManager(std::shared_ptr<TileProviderManager>(new TileProviderManager))
, _saveOrThrowCamera(properties::BoolProperty("saveOrThrowCamera", "saveOrThrowCamera"))
: _saveOrThrowCamera(properties::BoolProperty("saveOrThrowCamera", "saveOrThrowCamera"))
, doFrustumCulling(properties::BoolProperty("doFrustumCulling", "doFrustumCulling"))
, doHorizonCulling(properties::BoolProperty("doHorizonCulling", "doHorizonCulling"))
, mergeInvisible(properties::BoolProperty("mergeInvisible", "mergeInvisible", true))
@@ -89,121 +88,27 @@ namespace openspace {
// Read the radii in to its own dictionary
Vec3 radii;
double patchSegmentsd;
dictionary.getValue(keyRadii, radii);
_ellipsoid = Ellipsoid(radii);
setBoundingSphere(pss(_ellipsoid.averageRadius(), 0.0));
// Ghoul can't read ints from lua dictionaries
double patchSegmentsd;
dictionary.getValue(keySegmentsPerPatch, patchSegmentsd);
int patchSegments = patchSegmentsd;
_ellipsoid = Ellipsoid(radii);
setBoundingSphere(pss(_ellipsoid.averageRadius(), 0.0));
// Init tile provider manager
ghoul::Dictionary texturesDictionary;
dictionary.getValue(keyTextures, texturesDictionary);
_tileProviderManager = std::shared_ptr<TileProviderManager>(
new TileProviderManager(texturesDictionary));
ghoul::Dictionary colorTexturesDictionary;
texturesDictionary.getValue(keyColorTextures, colorTexturesDictionary);
auto colorProviders = _tileProviderManager->colorTextureProviders();
auto heightProviders = _tileProviderManager->heightMapProviders();
int minimumTextureSize = 1024;
int frameUntilFlushRequestQueue = 60;
int cacheSize = 5000;
addToggleLayerProperties(colorProviders, _activeColorLayers);
addToggleLayerProperties(heightProviders, _activeHeightMapLayers);
// manually add a temporal tile provider for testing
std::string filename = "map_service_configs/VIIRS_SNPP_CorrectedReflectance_TrueColor_temporal.xml";
TileProviderInitData initData;
initData.minimumPixelSize = minimumTextureSize;
initData.threads = 1;
initData.cacheSize = 50;
initData.framesUntilRequestQueueFlush = 60;
std::shared_ptr<TileProvider> colorTextureProvider = std::shared_ptr<TemporalTileProvider>(
new TemporalTileProvider(filename, initData));
std::string name = "Temporal VIIRS SNPP";
_tileProviderManager->addColorTexture(name, colorTextureProvider, true);
_activeColorLayers.push_back(properties::BoolProperty(name, name, true));
// Create TileProviders for all color textures
for (size_t i = 0; i < colorTexturesDictionary.size(); i++)
{
std::string name, path;
std::string dictionaryKey = std::to_string(i + 1);
ghoul::Dictionary colorTextureDictionary =
colorTexturesDictionary.value<ghoul::Dictionary>(dictionaryKey);
colorTextureDictionary.getValue("Name", name);
colorTextureDictionary.getValue("FilePath", path);
std::shared_ptr<TileDataset> tileDataset = std::shared_ptr<TileDataset>(
new TileDataset(path, minimumTextureSize));
std::shared_ptr<ThreadPool> threadPool = std::shared_ptr<ThreadPool>(
new ThreadPool(1));
std::shared_ptr<AsyncTileDataProvider> tileReader = std::shared_ptr<AsyncTileDataProvider>(
new AsyncTileDataProvider(tileDataset, threadPool));
std::shared_ptr<TileProvider> colorTextureProvider = std::shared_ptr<TileProvider>(
new CachingTileProvider(tileReader, cacheSize, frameUntilFlushRequestQueue));
_tileProviderManager->addColorTexture(name, colorTextureProvider, true);
// Create property for this tile provider
bool enabled = _activeColorLayers.size() == 0; // Only enable first layer
_activeColorLayers.push_back(properties::BoolProperty(name, name, enabled));
}
ghoul::Dictionary heightMapsDictionary;
texturesDictionary.getValue(keyHeightMaps, heightMapsDictionary);
// Create TileProviders for all height maps
for (size_t i = 0; i < heightMapsDictionary.size(); i++)
{
std::string name, path;
std::string dictionaryKey = std::to_string(i + 1);
ghoul::Dictionary heightMapDictionary =
heightMapsDictionary.value<ghoul::Dictionary>(dictionaryKey);
heightMapDictionary.getValue("Name", name);
heightMapDictionary.getValue("FilePath", path);
std::shared_ptr<TileDataset> tileDataset = std::shared_ptr<TileDataset>(
new TileDataset(path, patchSegments));
std::shared_ptr<ThreadPool> threadPool = std::shared_ptr<ThreadPool>(
new ThreadPool(1));
std::shared_ptr<AsyncTileDataProvider> tileReader = std::shared_ptr<AsyncTileDataProvider>(
new AsyncTileDataProvider(tileDataset, threadPool));
std::shared_ptr<TileProvider> heightMapProvider = std::shared_ptr<TileProvider>(
new CachingTileProvider(tileReader, cacheSize, frameUntilFlushRequestQueue));
_tileProviderManager->addHeightMap(name, heightMapProvider, true);
// Create property for this tile provider
bool enabled = _activeHeightMapLayers.size() == 0; // Only enable first layer
_activeHeightMapLayers.push_back(properties::BoolProperty(name, name, enabled));
}
// Add properties for the tile providers
for (auto it = _activeColorLayers.begin(); it != _activeColorLayers.end(); it++) {
addProperty(*it);
}
for (auto it = _activeHeightMapLayers.begin(); it != _activeHeightMapLayers.end(); it++) {
addProperty(*it);
}
_chunkedLodGlobe = std::shared_ptr<ChunkedLodGlobe>(
new ChunkedLodGlobe(_ellipsoid, patchSegments, _tileProviderManager));
@@ -214,7 +119,21 @@ namespace openspace {
}
void RenderableGlobe::addToggleLayerProperties(
std::vector<TileProviderManager::TileProviderWithName>& tileProviders,
std::vector<properties::BoolProperty>& dest)
{
for (size_t i = 0; i < tileProviders.size(); i++) {
bool enabled = i == 0; // Only enable first layer
std::string name = tileProviders[i].name;
dest.push_back(properties::BoolProperty(name, name, enabled));
}
auto it = dest.begin();
auto end = dest.end();
while (it != end) {
addProperty(*(it++));
}
}
bool RenderableGlobe::initialize() {
return _distanceSwitch.initialize();
@@ -266,6 +185,7 @@ namespace openspace {
std::vector<TileProviderManager::TileProviderWithName>& heightMapProviders =
_tileProviderManager->heightMapProviders();
for (size_t i = 0; i < colorTextureProviders.size(); i++) {
colorTextureProviders[i].isActive = _activeColorLayers[i].value();
}
@@ -82,6 +82,11 @@ public:
private:
void addToggleLayerProperties(
std::vector<TileProviderManager::TileProviderWithName>&,
std::vector<properties::BoolProperty>& dest
);
double _time;
Ellipsoid _ellipsoid;
@@ -119,6 +119,7 @@ bool TriangleSoup::updateDataInGPU() {
}
}
// First VAO setup
glBindVertexArray(_vaoID);
@@ -158,6 +159,9 @@ bool TriangleSoup::updateDataInGPU() {
GL_STATIC_DRAW);
glBindVertexArray(0);
_gpuDataNeedUpdate = false;
return true;
}
@@ -25,37 +25,99 @@
#include <modules/globebrowsing/other/tileprovidermanager.h>
#include <ghoul/logging/logmanager.h>
#include "cpl_minixml.h"
namespace {
const std::string _loggerCat = "TileProviderManager";
const std::string keyColorTextures = "ColorTextures";
const std::string keyHeightMaps = "HeightMaps";
}
namespace openspace {
ThreadPool TileProviderManager::tileRequestThreadPool(1);
TileProviderManager::TileProviderManager()
{
TileProviderManager::TileProviderManager(const ghoul::Dictionary& texDict){
ghoul::Dictionary colorTexturesDict;
texDict.getValue(keyColorTextures, colorTexturesDict);
TileProviderInitData colorInitData;
colorInitData.minimumPixelSize = 1024;
colorInitData.threads = 1;
colorInitData.cacheSize = 500;
colorInitData.framesUntilRequestQueueFlush = 60;
initTexures(_colorTextureProviders, colorTexturesDict, colorInitData);
ghoul::Dictionary heightTexturesDict;
texDict.getValue(keyHeightMaps, heightTexturesDict);
TileProviderInitData heightInitData;
heightInitData.minimumPixelSize = 64;
heightInitData.threads = 1;
heightInitData.cacheSize = 500;
heightInitData.framesUntilRequestQueueFlush = 60;
initTexures(_heightMapProviders, heightTexturesDict, heightInitData);
}
TileProviderManager::~TileProviderManager()
{
}
void TileProviderManager::addHeightMap(
std::string name,
std::shared_ptr<TileProvider> tileProvider,
bool isActive)
void TileProviderManager::initTexures(std::vector<TileProviderWithName>& dest,
const ghoul::Dictionary& texturesDict, const TileProviderInitData& initData)
{
_heightMapProviders.push_back({ name , tileProvider, isActive});
// Create TileProviders for all color textures
for (size_t i = 0; i < texturesDict.size(); i++) {
std::string name, path;
std::string dictKey = std::to_string(i + 1);
ghoul::Dictionary texDict = texturesDict.value<ghoul::Dictionary>(dictKey);
texDict.getValue("Name", name);
texDict.getValue("FilePath", path);
std::shared_ptr<TileProvider> tileProvider = initProvider(path, initData);
bool enabled = dest.size() == 0; // Only enable first layer
dest.push_back({ name, tileProvider, enabled });
}
}
void TileProviderManager::addColorTexture(
std::string name,
std::shared_ptr<TileProvider> tileProvider,
bool isActive)
std::shared_ptr<TileProvider> TileProviderManager::initProvider(const std::string& file,
const TileProviderInitData& initData)
{
_colorTextureProviders.push_back({ name , tileProvider, isActive });
std::shared_ptr<TileProvider> tileProvider;
CPLXMLNode * node = CPLParseXMLFile(file.c_str());
if (std::string(node->pszValue) == "OpenSpaceTemporalGDALDataset") {
tileProvider = std::shared_ptr<TileProvider>(
new TemporalTileProvider(file, initData));
return tileProvider;
}
std::shared_ptr<TileDataset> tileDataset = std::shared_ptr<TileDataset>(
new TileDataset(file, initData.minimumPixelSize));
std::shared_ptr<ThreadPool> threadPool = std::shared_ptr<ThreadPool>(
new ThreadPool(1));
std::shared_ptr<AsyncTileDataProvider> tileReader = std::shared_ptr<AsyncTileDataProvider>(
new AsyncTileDataProvider(tileDataset, threadPool));
std::shared_ptr<TileCache> tileCache = std::shared_ptr<TileCache>(new TileCache(initData.cacheSize));
tileProvider = std::shared_ptr<TileProvider>(
new CachingTileProvider(tileReader, tileCache, initData.framesUntilRequestQueueFlush));
return tileProvider;
}
std::vector<TileProviderManager::TileProviderWithName>&
@@ -70,6 +132,21 @@ namespace openspace {
return _colorTextureProviders;
}
void TileProviderManager::prerender() {
for (auto it = _colorTextureProviders.begin(); it != _colorTextureProviders.end(); it++) {
if (it->isActive) {
it->tileProvider->prerender();
}
}
for (auto it = _heightMapProviders.begin(); it != _heightMapProviders.end(); it++){
if (it->isActive) {
it->tileProvider->prerender();
}
}
}
const std::vector<std::shared_ptr<TileProvider> >
TileProviderManager::getActiveHeightMapProviders()
{
@@ -25,9 +25,14 @@
#ifndef __TILE_PROVIDER_MANAGER_H__
#define __TILE_PROVIDER_MANAGER_H__
#include "modules/globebrowsing/other/tileprovider.h"
#include <modules/globebrowsing/other/temporaltileprovider.h>
#include <modules/globebrowsing/other/tileprovider.h>
#include <modules/globebrowsing/other/threadpool.h>
#include <ghoul/misc/dictionary.h>
#include <memory>
#include <vector>
#include <string>
@@ -43,30 +48,26 @@ namespace openspace {
bool isActive;
};
TileProviderManager();
TileProviderManager(const ghoul::Dictionary& dict);
~TileProviderManager();
static ThreadPool tileRequestThreadPool;
void addHeightMap(
std::string name,
std::shared_ptr<TileProvider> tileProvider,
bool isActive);
void addColorTexture(
std::string name,
std::shared_ptr<TileProvider> tileProvider,
bool isActive);
/*
std::shared_ptr<CachingTileProvider> getHeightMap(std::string name);
std::shared_ptr<CachingTileProvider> getColorTexture(std::string name);
*/
const std::vector<std::shared_ptr<TileProvider> > getActiveHeightMapProviders();
const std::vector<std::shared_ptr<TileProvider> > getActiveColorTextureProviders();
std::vector<TileProviderWithName>& heightMapProviders();
std::vector<TileProviderWithName>& colorTextureProviders();
void prerender();
private:
static void initTexures(std::vector<TileProviderWithName>& destination,
const ghoul::Dictionary& dict, const TileProviderInitData& initData);
static std::shared_ptr<TileProvider> initProvider(const std::string& file,
const TileProviderInitData& initData);
std::vector<TileProviderWithName> _heightMapProviders;
std::vector<TileProviderWithName> _colorTextureProviders;
};
@@ -93,15 +93,26 @@ namespace openspace {
}
Tile TemporalTileProvider::getHighestResolutionTile(ChunkIndex chunkIndex, int parents) {
return getTileProvider()->getHighestResolutionTile(chunkIndex, parents);
if (_currentTileProvider == nullptr) {
LDEBUG("Warning: had to call prerender from getHighestResolutionTile()");
prerender();
}
return _currentTileProvider->getHighestResolutionTile(chunkIndex, parents);
}
TileDepthTransform TemporalTileProvider::depthTransform() {
return getTileProvider()->depthTransform();
if (_currentTileProvider == nullptr) {
LDEBUG("Warning: had to call prerender from depthTransform()");
prerender();
}
return _currentTileProvider->depthTransform();
}
void TemporalTileProvider::prerender() {
return getTileProvider()->prerender();
_currentTileProvider = getTileProvider();
_currentTileProvider->prerender();
}
@@ -140,10 +151,11 @@ namespace openspace {
std::shared_ptr<AsyncTileDataProvider> tileReader = std::shared_ptr<AsyncTileDataProvider>(
new AsyncTileDataProvider(tileDataset, threadPool));
std::shared_ptr<TileCache> tileCache = std::shared_ptr<TileCache>(new TileCache(_tileProviderInitData.cacheSize));
std::shared_ptr<CachingTileProvider> tileProvider= std::shared_ptr<CachingTileProvider>(
new CachingTileProvider(tileReader,
_tileProviderInitData.cacheSize,
_tileProviderInitData.framesUntilRequestQueueFlush));
new CachingTileProvider(tileReader, tileCache,
_tileProviderInitData.framesUntilRequestQueueFlush));
return tileProvider;
}
@@ -153,6 +153,8 @@ namespace openspace {
std::unordered_map<TimeKey, std::shared_ptr<CachingTileProvider> > _tileProviderMap;
TileProviderInitData _tileProviderInitData;
std::shared_ptr<TileProvider> _currentTileProvider;
TimeFormat * _timeFormat;
TimeQuantizer _timeQuantizer;
};
+9 -8
View File
@@ -46,10 +46,11 @@ namespace {
namespace openspace {
CachingTileProvider::CachingTileProvider(std::shared_ptr<AsyncTileDataProvider> tileReader, int tileCacheSize,
CachingTileProvider::CachingTileProvider(std::shared_ptr<AsyncTileDataProvider> tileReader,
std::shared_ptr<TileCache> tileCache,
int framesUntilFlushRequestQueue)
: _asyncTextureDataProvider(tileReader)
, _tileCache(tileCacheSize)
, _tileCache(tileCache)
, _framesSinceLastRequestFlush(0)
{
@@ -107,8 +108,8 @@ namespace openspace {
HashKey key = chunkIndex.hashKey();
if (_tileCache.exist(key) && _tileCache.get(key).ioError == CPLErr::CE_None) {
return { _tileCache.get(key).texture, uvTransform };
if (_tileCache->exist(key) && _tileCache->get(key).ioError == CPLErr::CE_None) {
return { _tileCache->get(key).texture, uvTransform };
}
else if (chunkIndex.level < 1) {
return { nullptr, uvTransform };
@@ -146,8 +147,8 @@ namespace openspace {
std::shared_ptr<Texture> CachingTileProvider::getOrStartFetchingTile(ChunkIndex chunkIndex) {
HashKey hashkey = chunkIndex.hashKey();
if (_tileCache.exist(hashkey)) {
return _tileCache.get(hashkey).texture;
if (_tileCache->exist(hashkey)) {
return _tileCache->get(hashkey).texture;
}
else {
_asyncTextureDataProvider->enqueueTextureData(chunkIndex);
@@ -179,9 +180,9 @@ namespace openspace {
texture->uploadTexture();
MetaTexture metaTexture = { texture, tileIOResult->error };
TextureAndStatus metaTexture = { texture, tileIOResult->error };
_tileCache.put(key, metaTexture);
_tileCache->put(key, metaTexture);
}
+7 -3
View File
@@ -58,7 +58,7 @@ namespace openspace {
TileUvTransform uvTransform;
};
struct MetaTexture {
struct TextureAndStatus {
std::shared_ptr<Texture> texture;
CPLErr ioError;
};
@@ -75,6 +75,7 @@ namespace openspace {
};
typedef LRUCache<HashKey, TextureAndStatus> TileCache;
/**
@@ -84,7 +85,10 @@ namespace openspace {
class CachingTileProvider : public TileProvider {
public:
CachingTileProvider(std::shared_ptr<AsyncTileDataProvider> tileReader, int tileCacheSize,
CachingTileProvider(
std::shared_ptr<AsyncTileDataProvider> tileReader,
std::shared_ptr<TileCache> tileCache,
int framesUntilFlushRequestQueue);
virtual ~CachingTileProvider();
@@ -125,7 +129,7 @@ namespace openspace {
// Member variables //
//////////////////////////////////////////////////////////////////////////////////
LRUCache<HashKey, MetaTexture> _tileCache;
std::shared_ptr<TileCache> _tileCache;
int _framesSinceLastRequestFlush;
int _framesUntilRequestFlush;
@@ -55,6 +55,8 @@ Fragment getFragment() {
#endif // USE_COLORTEXTURE
//frag.color += patchBorderOverlay(fs_uv, vec3(0.2), 0.02);
frag.depth = fs_position.w;
return frag;
@@ -53,6 +53,7 @@ Fragment getFragment() {
colorTilesParent2);
#endif // USE_COLORTEXTURE
//frag.color += patchBorderOverlay(fs_uv, vec3(0.2), 0.02);
frag.depth = fs_position.w;