Fixed HeightField coordinates set up
This commit is contained in:
@@ -676,7 +676,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
|
||||
double TopLeft[2],BottomLeft[2],BottomRight[2],TopRight[2];
|
||||
TopLeft[0] = geoTransform[0];
|
||||
TopLeft[1] = geoTransform[1];
|
||||
TopLeft[1] = geoTransform[3];
|
||||
BottomLeft[0] = TopLeft[0]+geoTransform[2]*(dataHeight-1);
|
||||
BottomLeft[1] = TopLeft[1]+geoTransform[5]*(dataHeight-1);
|
||||
BottomRight[0] = BottomLeft[0]+geoTransform[1]*(dataWidth-1);
|
||||
@@ -684,6 +684,9 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
TopRight[0] = TopLeft[0]+geoTransform[1]*(dataWidth-1);
|
||||
TopRight[1] = TopLeft[1]+geoTransform[4]*(dataWidth-1);
|
||||
|
||||
|
||||
double rotation = atan2(geoTransform[2], geoTransform[1]);
|
||||
osg::notify(osg::INFO)<<"GDAL rotation = "<<rotation<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << "TopLeft "<<TopLeft[0]<<"\t"<<TopLeft[1]<<std::endl;
|
||||
osg::notify(osg::INFO) << "BottomLeft "<<BottomLeft[0]<<"\t"<<BottomLeft[1]<<std::endl;
|
||||
@@ -748,8 +751,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
bandSelected->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(&(hf->getHeightList().front())),destWidth,destHeight,GDT_Float32,0,0);
|
||||
|
||||
// now need to flip since the OSG's origin is in lower left corner.
|
||||
osg::notify(osg::INFO)<<"flipping"<<std::endl;
|
||||
unsigned int copy_r = hf->getNumRows()-1;
|
||||
osg::notify(osg::INFO)<<"flipping"<<std::endl;
|
||||
unsigned int copy_r = hf->getNumRows()-1;
|
||||
for(unsigned int r=0;r<copy_r;++r,--copy_r)
|
||||
{
|
||||
for(unsigned int c=0;c<hf->getNumColumns();++c)
|
||||
@@ -759,9 +762,13 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
hf->setHeight(c,copy_r,temp);
|
||||
}
|
||||
}
|
||||
hf->setOrigin(osg::Vec3(BottomLeft[0],-BottomLeft[1],0));
|
||||
hf->setXInterval((BottomRight[0]-BottomLeft[0])/destWidth);
|
||||
hf->setYInterval((TopLeft[1]-BottomLeft[1])/destHeight);
|
||||
hf->setOrigin(osg::Vec3(BottomLeft[0],BottomLeft[1],0));
|
||||
|
||||
hf->setXInterval(sqrt(geoTransform[1]*geoTransform[1] + geoTransform[2]*geoTransform[2]));
|
||||
hf->setYInterval(sqrt(geoTransform[4]*geoTransform[4] + geoTransform[5]*geoTransform[5]));
|
||||
|
||||
hf->setRotation(osg::Quat(rotation, osg::Vec3d(0.0, 0.0, 1.0)));
|
||||
|
||||
return hf;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user