[osg-users] [vpb] geographic to geocentric coordinate transformation

Elias Tarasov elias.tarasov at gmail.com
Wed Jun 17 01:39:33 PDT 2015


Hello!
It seems i have a problem Deniz had faced previously.
My generated terrain viewed from osgviewer is here:
https://drive.google.com/file/d/0ByDDImhSolf6Szh5YW81MDdqV2M/view?usp=sharing

My gdalinfo for dem file used to generate terrain is here:

Driver: GTiff/GeoTIFF
Files: n30_w086_1arc_v3_conv.tif
       n30_w086_1arc_v3_conv.tif.aux.xml
Size is 58, 50
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (-85.495972222222221,30.536250000000003)
Pixel Size = (0.000277777777778,-0.000277777777778)
Metadata:
  AREA_OR_POINT=Point
  DTED_CompilationDate=0002
  DTED_DataEdition=02
  DTED_DigitizingSystem=SRTM
  DTED_HorizontalAccuracy=0013
  DTED_HorizontalDatum=WGS84
  DTED_MaintenanceDate=0000
  DTED_MaintenanceDescription=0000
  DTED_MatchMergeDate=0000
  DTED_MatchMergeVersion=A
  DTED_NimaDesignator=DTED2
  DTED_OriginLatitude=0300000N
  DTED_OriginLongitude=0860000W
  DTED_Producer=USCNIMA
  DTED_RelHorizontalAccuracy=NA
  DTED_RelVerticalAccuracy=0004
  DTED_SecurityCode_DSI=U
  DTED_SecurityCode_UHL=U
  DTED_UniqueRef_DSI=H24 084
  DTED_UniqueRef_UHL=H24 084
  DTED_VerticalAccuracy_ACC=0005
  DTED_VerticalAccuracy_UHL=0005
  DTED_VerticalDatum=E96
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( -85.4959722,  30.5362500) ( 85d29'45.50"W, 30d32'10.50"N)
Lower Left  ( -85.4959722,  30.5223611) ( 85d29'45.50"W, 30d31'20.50"N)
Upper Right ( -85.4798611,  30.5362500) ( 85d28'47.50"W, 30d32'10.50"N)
Lower Right ( -85.4798611,  30.5223611) ( 85d28'47.50"W, 30d31'20.50"N)
Center      ( -85.4879167,  30.5293056) ( 85d29'16.50"W, 30d31'45.50"N)
Band 1 Block=58x50 Type=Int16, ColorInterp=Gray
  Min=31.000 Max=61.000
  Minimum=31.000, Maximum=61.000, Mean=49.202, StdDev=6.253
  NoData Value=0
  Unit Type: m
  Metadata:
    STATISTICS_MAXIMUM=61
    STATISTICS_MEAN=49.202413793103
    STATISTICS_MINIMUM=31
    STATISTICS_STDDEV=6.2528388891449
		
Here, center of my terrain is: 
Center      ( -85.4879167,  30.5293056) ( 85d29'16.50"W, 30d31'45.50"N)

Now i want to place a camera in the center of that terrain to use it from an app:

const double M_PI_2 = 1.57079632679489661923; 

int main( int argc, char** argv ) {

	osg::ref_ptr<osg::Group> root = new osg::Group;
	osg::ref_ptr<osg::Node> cessna = osgDB::readNodeFile("c:/OpenSceneGraph/data/cessnafire.osg");
	osg::ref_ptr<osg::Node> map = osgDB::readNodeFile("c:/Terrain/FromUSGS/output/out.osgb");
	root->addChild( cessna.get() );
	root->addChild( map.get() );
			
	osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
	viewer->setSceneData( root.get() );

	osg::Matrixd vm;
	osg::EllipsoidModel ellipsoid;
	ellipsoid.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(-85.4877762), osg::DegreesToRadians(30.5292506), 100, vm);
	vm.invert(vm);

	osg::Matrixd rotation2YUp;
	rotation2YUp.makeRotate(-M_PI_2, osg::Vec3f(1.0, 0.0, 0.0));
	vm *= rotation2YUp;
	viewer->getCamera()->setViewMatrix(vm); 

	return viewer->run();
}

But i don't see anything. Just empty screen. 
Well, since terrain had been built in geocentric mode, i think app somehow moved terrain and cessna to the correct position in ECEF. 
So, i just need to move a camera to that position.

I guess camera's position is wrong, but i don't know how to fix it.

Thank you!

Cheers,
Elias

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64106#64106








More information about the osg-users mailing list