Changed s/getGdalDataset() methods to use void* to avoid introspeciton wrapping problems.
This commit is contained in:
parent
49301347e8
commit
b835ec9ee9
@ -135,7 +135,7 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
SourceData(Source* source=0):
|
||||
_source(source),
|
||||
_hasGCPs(false),
|
||||
_gdalDataSet(0) {}
|
||||
_gdalDataset(0) {}
|
||||
|
||||
virtual ~SourceData();
|
||||
|
||||
@ -158,7 +158,7 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
bool _hasGCPs;
|
||||
|
||||
osg::ref_ptr<osg::Node> _model;
|
||||
GDALDataset* _gdalDataSet;
|
||||
GDALDataset* _gdalDataset;
|
||||
|
||||
typedef std::map<const osg::CoordinateSystemNode*,SpatialProperties> SpatialPropertiesMap;
|
||||
mutable SpatialPropertiesMap _spatialPropertiesMap;
|
||||
@ -194,7 +194,7 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
_minLevel(0),
|
||||
_maxLevel(MAXIMUM_NUMBER_OF_LEVELS),
|
||||
_layer(0),
|
||||
_gdalDataSet(0)
|
||||
_gdalDataset(0)
|
||||
{}
|
||||
|
||||
Source(Type type, const std::string& filename):
|
||||
@ -207,7 +207,7 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
_minLevel(0),
|
||||
_maxLevel(MAXIMUM_NUMBER_OF_LEVELS),
|
||||
_layer(0),
|
||||
_gdalDataSet(0)
|
||||
_gdalDataset(0)
|
||||
{}
|
||||
|
||||
void setSortValue(double s) { _sortValue = s; }
|
||||
@ -224,8 +224,9 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
void setTemporaryFile(bool temporaryFile) { _temporaryFile = temporaryFile; }
|
||||
bool getTemporaryFile() const { return _temporaryFile; }
|
||||
|
||||
void setGdalDataSet(GDALDataset* gdalDataSet) { _gdalDataSet = gdalDataSet; }
|
||||
GDALDataset* getGdalDataSet() const { return _gdalDataSet; }
|
||||
void setGdalDataset(void* gdalDataset);
|
||||
void* getGdalDataset();
|
||||
const void* getGdalDataset() const;
|
||||
|
||||
void setCoordinateSystemPolicy(ParameterPolicy policy) { _coordinateSystemPolicy = policy; }
|
||||
ParameterPolicy getCoordinateSystemPolicy() const { return _coordinateSystemPolicy; }
|
||||
@ -339,8 +340,8 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
|
||||
ResolutionList _requiredResolutions;
|
||||
|
||||
GDALDataset* _gdalDataSet;
|
||||
};
|
||||
GDALDataset* _gdalDataset;
|
||||
};
|
||||
|
||||
enum CompositeType
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ bool areCoordinateSystemEquivalent(const osg::CoordinateSystemNode* lhs,const os
|
||||
|
||||
DataSet::SourceData::~SourceData()
|
||||
{
|
||||
if (_gdalDataSet) GDALClose(_gdalDataSet);
|
||||
if (_gdalDataset) GDALClose(_gdalDataset);
|
||||
}
|
||||
|
||||
DataSet::SourceData* DataSet::SourceData::readData(Source* source)
|
||||
@ -227,13 +227,13 @@ DataSet::SourceData* DataSet::SourceData::readData(Source* source)
|
||||
case(Source::IMAGE):
|
||||
case(Source::HEIGHT_FIELD):
|
||||
{
|
||||
GDALDataset* gdalDataSet = source->getGdalDataSet();
|
||||
GDALDataset* gdalDataSet = (GDALDataset*)source->getGdalDataset();
|
||||
if(!gdalDataSet)
|
||||
gdalDataSet = (GDALDataset*)GDALOpen(source->getFileName().c_str(),GA_ReadOnly);
|
||||
if (gdalDataSet)
|
||||
{
|
||||
SourceData* data = new SourceData(source);
|
||||
data->_gdalDataSet = gdalDataSet;
|
||||
data->_gdalDataset = gdalDataSet;
|
||||
|
||||
data->_numValuesX = gdalDataSet->GetRasterXSize();
|
||||
data->_numValuesY = gdalDataSet->GetRasterYSize();
|
||||
@ -355,7 +355,7 @@ const DataSet::SpatialProperties& DataSet::SourceData::computeSpatialProperties(
|
||||
if (_cs.valid() && cs)
|
||||
{
|
||||
|
||||
if (_gdalDataSet)
|
||||
if (_gdalDataset)
|
||||
{
|
||||
|
||||
//my_notify(osg::INFO)<<"Projecting bounding volume for "<<_source->getFileName()<<std::endl;
|
||||
@ -370,7 +370,7 @@ const DataSet::SpatialProperties& DataSet::SourceData::computeSpatialProperties(
|
||||
/* destination coordinate system. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
void *hTransformArg =
|
||||
GDALCreateGenImgProjTransformer( _gdalDataSet,_cs->getCoordinateSystem().c_str(),
|
||||
GDALCreateGenImgProjTransformer( _gdalDataset,_cs->getCoordinateSystem().c_str(),
|
||||
NULL, cs->getCoordinateSystem().c_str(),
|
||||
TRUE, 0.0, 1 );
|
||||
|
||||
@ -382,7 +382,7 @@ const DataSet::SpatialProperties& DataSet::SourceData::computeSpatialProperties(
|
||||
|
||||
double adfDstGeoTransform[6];
|
||||
int nPixels=0, nLines=0;
|
||||
if( GDALSuggestedWarpOutput( _gdalDataSet,
|
||||
if( GDALSuggestedWarpOutput( _gdalDataset,
|
||||
GDALGenImgProjTransform, hTransformArg,
|
||||
adfDstGeoTransform, &nPixels, &nLines )
|
||||
!= CE_None )
|
||||
@ -489,10 +489,10 @@ void DataSet::SourceData::readImage(DestinationData& destination)
|
||||
doResample = true;
|
||||
}
|
||||
|
||||
bool hasRGB = _gdalDataSet->GetRasterCount() >= 3;
|
||||
bool hasAlpha = _gdalDataSet->GetRasterCount() >= 4;
|
||||
bool hasColorTable = _gdalDataSet->GetRasterCount() >= 1 && _gdalDataSet->GetRasterBand(1)->GetColorTable();
|
||||
bool hasGreyScale = _gdalDataSet->GetRasterCount() == 1;
|
||||
bool hasRGB = _gdalDataset->GetRasterCount() >= 3;
|
||||
bool hasAlpha = _gdalDataset->GetRasterCount() >= 4;
|
||||
bool hasColorTable = _gdalDataset->GetRasterCount() >= 1 && _gdalDataset->GetRasterBand(1)->GetColorTable();
|
||||
bool hasGreyScale = _gdalDataset->GetRasterCount() == 1;
|
||||
unsigned int numSourceComponents = hasAlpha?4:3;
|
||||
|
||||
if (hasRGB || hasColorTable || hasGreyScale)
|
||||
@ -515,10 +515,10 @@ void DataSet::SourceData::readImage(DestinationData& destination)
|
||||
// as RGB.
|
||||
if( hasRGB )
|
||||
{
|
||||
GDALRasterBand* bandRed = _gdalDataSet->GetRasterBand(1);
|
||||
GDALRasterBand* bandGreen = _gdalDataSet->GetRasterBand(2);
|
||||
GDALRasterBand* bandBlue = _gdalDataSet->GetRasterBand(3);
|
||||
GDALRasterBand* bandAlpha = hasAlpha ? _gdalDataSet->GetRasterBand(4) : 0;
|
||||
GDALRasterBand* bandRed = _gdalDataset->GetRasterBand(1);
|
||||
GDALRasterBand* bandGreen = _gdalDataset->GetRasterBand(2);
|
||||
GDALRasterBand* bandBlue = _gdalDataset->GetRasterBand(3);
|
||||
GDALRasterBand* bandAlpha = hasAlpha ? _gdalDataset->GetRasterBand(4) : 0;
|
||||
|
||||
bandRed->RasterIO(GF_Read,
|
||||
windowX,_numValuesY-(windowY+windowHeight),
|
||||
@ -555,7 +555,7 @@ void DataSet::SourceData::readImage(DestinationData& destination)
|
||||
int i;
|
||||
|
||||
|
||||
band = _gdalDataSet->GetRasterBand(1);
|
||||
band = _gdalDataset->GetRasterBand(1);
|
||||
|
||||
|
||||
band->RasterIO(GF_Read,
|
||||
@ -596,7 +596,7 @@ void DataSet::SourceData::readImage(DestinationData& destination)
|
||||
GDALRasterBand *band;
|
||||
|
||||
|
||||
band = _gdalDataSet->GetRasterBand(1);
|
||||
band = _gdalDataset->GetRasterBand(1);
|
||||
|
||||
|
||||
band->RasterIO(GF_Read,
|
||||
@ -817,7 +817,7 @@ void DataSet::SourceData::readHeightField(DestinationData& destination)
|
||||
|
||||
|
||||
// which band do we want to read from...
|
||||
int numBands = _gdalDataSet->GetRasterCount();
|
||||
int numBands = _gdalDataset->GetRasterCount();
|
||||
GDALRasterBand* bandGray = 0;
|
||||
GDALRasterBand* bandRed = 0;
|
||||
GDALRasterBand* bandGreen = 0;
|
||||
@ -826,7 +826,7 @@ void DataSet::SourceData::readHeightField(DestinationData& destination)
|
||||
|
||||
for(int b=1;b<=numBands;++b)
|
||||
{
|
||||
GDALRasterBand* band = _gdalDataSet->GetRasterBand(b);
|
||||
GDALRasterBand* band = _gdalDataset->GetRasterBand(b);
|
||||
if (band->GetColorInterpretation()==GCI_GrayIndex) bandGray = band;
|
||||
else if (band->GetColorInterpretation()==GCI_RedBand) bandRed = band;
|
||||
else if (band->GetColorInterpretation()==GCI_GreenBand) bandGreen = band;
|
||||
@ -932,6 +932,22 @@ void DataSet::SourceData::readModels(DestinationData& destination)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataSet::Source::setGdalDataset(void* gdalDataSet)
|
||||
{
|
||||
_gdalDataset = (GDALDataset*)gdalDataSet;
|
||||
}
|
||||
|
||||
void* DataSet::Source::getGdalDataset()
|
||||
{
|
||||
return _gdalDataset;
|
||||
}
|
||||
|
||||
const void* DataSet::Source::getGdalDataset() const
|
||||
{
|
||||
return _gdalDataset;
|
||||
}
|
||||
|
||||
void DataSet::Source::setSortValueFromSourceDataResolution()
|
||||
{
|
||||
if (_sourceData.valid())
|
||||
@ -1071,7 +1087,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
/* destination coordinate system. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
void *hTransformArg =
|
||||
GDALCreateGenImgProjTransformer( _sourceData->_gdalDataSet,_sourceData->_cs->getCoordinateSystem().c_str(),
|
||||
GDALCreateGenImgProjTransformer( _sourceData->_gdalDataset,_sourceData->_cs->getCoordinateSystem().c_str(),
|
||||
NULL, cs->getCoordinateSystem().c_str(),
|
||||
TRUE, 0.0, 1 );
|
||||
|
||||
@ -1083,7 +1099,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
|
||||
double adfDstGeoTransform[6];
|
||||
int nPixels=0, nLines=0;
|
||||
if( GDALSuggestedWarpOutput( _sourceData->_gdalDataSet,
|
||||
if( GDALSuggestedWarpOutput( _sourceData->_gdalDataset,
|
||||
GDALGenImgProjTransform, hTransformArg,
|
||||
adfDstGeoTransform, &nPixels, &nLines )
|
||||
!= CE_None )
|
||||
@ -1124,14 +1140,14 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
|
||||
GDALDestroyGenImgProjTransformer( hTransformArg );
|
||||
|
||||
GDALDataType eDT = GDALGetRasterDataType(GDALGetRasterBand(_sourceData->_gdalDataSet,1));
|
||||
GDALDataType eDT = GDALGetRasterDataType(GDALGetRasterBand(_sourceData->_gdalDataset,1));
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Create the file */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
int numSourceBands = GDALGetRasterCount(_sourceData->_gdalDataSet);
|
||||
int numSourceBands = GDALGetRasterCount(_sourceData->_gdalDataset);
|
||||
int numDestinationBands = (numSourceBands >= 3) ? 4 : numSourceBands; // expand RGB to RGBA, but leave other formats unchanged
|
||||
|
||||
GDALDatasetH hDstDS = GDALCreate( hDriver, filename.c_str(), nPixels, nLines,
|
||||
@ -1153,7 +1169,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
// Set up the transformer along with the new datasets.
|
||||
|
||||
hTransformArg =
|
||||
GDALCreateGenImgProjTransformer( _sourceData->_gdalDataSet,_sourceData->_cs->getCoordinateSystem().c_str(),
|
||||
GDALCreateGenImgProjTransformer( _sourceData->_gdalDataset,_sourceData->_cs->getCoordinateSystem().c_str(),
|
||||
hDstDS, cs->getCoordinateSystem().c_str(),
|
||||
TRUE, 0.0, 1 );
|
||||
|
||||
@ -1167,7 +1183,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
/* -------------------------------------------------------------------- */
|
||||
GDALColorTableH hCT;
|
||||
|
||||
hCT = GDALGetRasterColorTable( GDALGetRasterBand(_sourceData->_gdalDataSet,1) );
|
||||
hCT = GDALGetRasterColorTable( GDALGetRasterBand(_sourceData->_gdalDataset,1) );
|
||||
if( hCT != NULL )
|
||||
GDALSetRasterColorTable( GDALGetRasterBand(hDstDS,1), hCT );
|
||||
|
||||
@ -1176,7 +1192,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
/* -------------------------------------------------------------------- */
|
||||
GDALWarpOptions *psWO = GDALCreateWarpOptions();
|
||||
|
||||
psWO->hSrcDS = _sourceData->_gdalDataSet;
|
||||
psWO->hSrcDS = _sourceData->_gdalDataset;
|
||||
psWO->hDstDS = hDstDS;
|
||||
|
||||
psWO->pfnTransformer = pfnTransformer;
|
||||
@ -1212,7 +1228,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg::
|
||||
for(i = 0; i < psWO->nBandCount; i++ )
|
||||
{
|
||||
int success = 0;
|
||||
GDALRasterBand* band = (i<numSourceBands) ? _sourceData->_gdalDataSet->GetRasterBand(i+1) : 0;
|
||||
GDALRasterBand* band = (i<numSourceBands) ? _sourceData->_gdalDataset->GetRasterBand(i+1) : 0;
|
||||
double noDataValue = band ? band->GetNoDataValue(&success) : 0.0;
|
||||
double new_noDataValue = 0;
|
||||
if (success)
|
||||
@ -1348,11 +1364,11 @@ void DataSet::Source::buildOverviews()
|
||||
{
|
||||
return;
|
||||
|
||||
if (_sourceData.valid() && _sourceData->_gdalDataSet )
|
||||
if (_sourceData.valid() && _sourceData->_gdalDataset )
|
||||
{
|
||||
|
||||
int anOverviewList[4] = { 2, 4, 8, 16 };
|
||||
GDALBuildOverviews( _sourceData->_gdalDataSet, "AVERAGE", 4, anOverviewList, 0, NULL,
|
||||
GDALBuildOverviews( _sourceData->_gdalDataset, "AVERAGE", 4, anOverviewList, 0, NULL,
|
||||
GDALTermProgress/*GDALDummyProgress*/, NULL );
|
||||
|
||||
}
|
||||
|
@ -337,8 +337,9 @@ BEGIN_OBJECT_REFLECTOR(osgTerrain::DataSet::Source)
|
||||
I_Method0(const std::string &, getFileName);
|
||||
I_Method1(void, setTemporaryFile, IN, bool, temporaryFile);
|
||||
I_Method0(bool, getTemporaryFile);
|
||||
I_Method1(void, setGdalDataSet, IN, GDALDataset *, gdalDataSet);
|
||||
I_Method0(GDALDataset *, getGdalDataSet);
|
||||
I_Method1(void, setGdalDataset, IN, void *, gdalDataset);
|
||||
I_Method0(void *, getGdalDataset);
|
||||
I_Method0(const void *, getGdalDataset);
|
||||
I_Method1(void, setCoordinateSystemPolicy, IN, osgTerrain::DataSet::Source::ParameterPolicy, policy);
|
||||
I_Method0(osgTerrain::DataSet::Source::ParameterPolicy, getCoordinateSystemPolicy);
|
||||
I_Method1(void, setCoordinateSystem, IN, const std::string &, wellKnownText);
|
||||
@ -373,7 +374,7 @@ BEGIN_OBJECT_REFLECTOR(osgTerrain::DataSet::Source)
|
||||
I_Property(osg::CoordinateSystemNode *, CoordinateSystem);
|
||||
I_Property(osgTerrain::DataSet::Source::ParameterPolicy, CoordinateSystemPolicy);
|
||||
I_Property(const std::string &, FileName);
|
||||
I_Property(GDALDataset *, GdalDataSet);
|
||||
I_Property(void *, GdalDataset);
|
||||
I_Property(osg::Matrixd &, GeoTransform);
|
||||
I_Property(osgTerrain::DataSet::Source::ParameterPolicy, GeoTransformPolicy);
|
||||
I_Property(unsigned int, Layer);
|
||||
|
Loading…
Reference in New Issue
Block a user