[osg-submissions] Fix georeference of gdal plugin

Cedric Pinson mornifle at plopbyte.net
Sat Dec 8 06:36:53 PST 2007


Hi Robert,
Here a patch for gdal reader, it did not take the georeference 
correctly. I added a diff to show you the difference. with my fix it 
works as expected for a tiff georeferenced.


diff for info:
0a1,9
 > /**
 >  * Who is the original author ???
 >  *
 >  *
 >  * Modified (2007)
 >  *
 >  *  Authors:
 >  *  Cedric Pinson <mornifle at plopbyte.net>
 >  */
666c675
<             TopLeft[1] = geoTransform[1];
---
 >             TopLeft[1] = geoTransform[3];
736c745
<
---
 >                
738,739c747,748
<                         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;
742,751c751,760
<                     for(unsigned int c=0;c<hf->getNumColumns();++c)
<                     {
<                         float temp = hf->getHeight(c,r);
<                         hf->setHeight(c,r,hf->getHeight(c,copy_r));
<                         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);
---
 >                      for(unsigned int c=0;c<hf->getNumColumns();++c)
 >                      {
 >                          float temp = hf->getHeight(c,r);
 >                          hf->setHeight(c,r,hf->getHeight(c,copy_r));
 >                          hf->setHeight(c,copy_r,temp);
 >                      }
 >                 }
 >                 hf->setOrigin(osg::Vec3(TopLeft[0],BottomLeft[1],-100));
 >                 hf->setXInterval(geoTransform[1]);
 >                 hf->setYInterval(-geoTransform[5]);

Cheers

-- 
+33 (0) 6 63 20 03 56  Cedric Pinson mailto:mornifle at plopbyte.net http://www.plopbyte.net


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ReaderWriterGDAL.cpp
Type: text/x-c++src
Size: 37797 bytes
Desc: not available
Url : http://lists.openscenegraph.org/pipermail/osg-submissions-openscenegraph.org/attachments/20071208/c2a1196c/attachment-0001.cpp 


More information about the osg-submissions mailing list