OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Retrieve coordinate system string from osgdem-generated terrain


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> VirtualPlanetBuilder [vpb]
View previous topic :: View next topic  
Author Message
creature (Ethan Fahy)
Appreciator


Joined: 07 Sep 2011
Posts: 142

PostPosted: Mon Dec 10, 2012 7:30 pm    Post subject:
Retrieve coordinate system string from osgdem-generated terrain
Reply with quote

Hello everyone,

I am using the --cs "+proj=utm +zone=xx +datum=WGS84" flag in osgdem to generate my terrain. (where xx is the utm zone number). If a load the terrain into a node and then do a dynamic_cast of that node to a coordinateSystemNode and use the getFormat() or getCoordinateSystem() functions they both return empty strings. Is there any way to get a wkt string from an osgdem-generated terrain object? I'm ideally looking to get a string that is compatible with the various coordinate system string formats readable by the gdal/ogr libraries.

Thanks,

-Ethan
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Tue Dec 11, 2012 10:20 am    Post subject:
Retrieve coordinate system string from osgdem-generated terrain
Reply with quote

Hi Ethan,

VPB should be creating databases with the root CoordinateSystemNode storing the Format and CooridnateSystem strings.  I've just pulled down the example data from openscenegraph.org and it has both set correctly, to check this I did:

wget http://www.openscenegraph.org/data/earth_bayarea/earth.ive
osgconv earth.ive earth.osg
head earth.osg

And I get:

CoordinateSystemNode {
  name "earth.ive"
  nodeMask 0xffffffff
  cullingActive TRUE
  Format "WKT"
  CoordinateSystem "GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4326"]]"
  EllipsoidModel {
    RadiusEquator 6378137
    RadiusPolar 6356752.3142
  }

Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
creature (Ethan Fahy)
Appreciator


Joined: 07 Sep 2011
Posts: 142

PostPosted: Tue Dec 11, 2012 3:46 pm    Post subject:
Reply with quote

Thanks for looking into that Robert. I'm finding that my terrain.osg results differ from the example earth.ive file you mentioned. The difference is that the top level of my terrain is an osgTerrain::Terrain obect instead of a CoordinateSystemNode. This is true despite my not using the --TERRAIN flag. My osgTerrain::Terrain object has empty strings for both Format and CoordinateSystem, but the osgTerrain::Locator object nested inside does have proper Format and CoordinateSystem strings. I can extract this info in the following way:

Code:

osgTerrain::Terrain* terrain = dynamic_cast<osgTerrain::Terrain*>(node.get());
   osg::PagedLOD* pagedLOD = dynamic_cast<osg::PagedLOD*>(terrain->getChild(0));
   osgTerrain::TerrainTile* terrainTile = dynamic_cast<osgTerrain::TerrainTile*>(pagedLOD->getChild(0));
   osgTerrain::Locator* locator = terrainTile->getLocator();
   string format = locator->getFormat();
   string coordinateSystem = locator->getCoordinateSystem();


where node is the top level osgTerrain::Terrain node that I read in from file.

Below is the top part of my terrain.osg file:

Code:

osgTerrain::Terrain {
  name "xxx\\xxx\\xxx\\\terrain.ive"
  nodeMask 0xffffffff
  cullingActive TRUE
  SampleRatio 1
  VerticalScale 1
  BlendingPolicy INHERIT
  Format ""
  CoordinateSystem ""
  num_children 1
  PagedLOD {
    nodeMask 0xffffffff
    cullingActive TRUE
    Center 731350 3.49247e+006 2211.23
    Radius -1
    RangeMode DISTANCE_FROM_EYE_POINT
    RangeList 2 {
      1.60316e+006 1e+010
      0 1.60316e+006
    }
    NumChildrenThatCannotBeExpired 0
    DisableExternalChildrenPaging 0
    FileNameList 2 {
      ""
      terrain_root_L0_X0_Y0/terrain_L0_X0_Y0_subtile.ive
    }
    num_children 1
    osgTerrain::TerrainTile {
      nodeMask 0xffffffff
      cullingActive TRUE
      BlendingPolicy INHERIT
      osgTerrain::Locator {
        UniqueID Locator_0
        Format "WKT"
        CoordinateSystem "PROJCS[\"UTM Zone 41, Northern Hemisphere\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",63],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]"
        CoordinateSystemType PROJECTED
        TransformScaledByResolution FALSE
        Transform {
          347303.25 0 0 0
          0 298624.25 0 0
          0 0 1 0
          557698.6875 3343161.75 0 1
        }
      }
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Tue Dec 11, 2012 4:19 pm    Post subject:
Retrieve coordinate system string from osgdem-generated terrain
Reply with quote

HI Ethan,

The VPB flag --TERRAIN is not required, by default osgTerrain will be used by VPB these days.  osgTerrain::Terrain is subclassed from CoordinateSystemNode and I've just checked all the serialization, .ive and .osg plugins and it all looks correct w.r.t reading/writing of the CoordinateSystem parameters.  I have looked into as much as I have time for right now and haven't spotted a cause of the problem.  Have a look at VirtualPlanetBuilder/src/vpb's creation of the root tile of database when it's running on your machine, perhaps it's missing the assignment of the coordinate system parameters.

Robert.

On 11 December 2012 15:46, Ethan Fahy < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Thanks for looking into that Robert.  I'm finding that my terrain.osg results differ from the example earth.ive file you mentioned.  The difference is that the top level of my terrain is an osgTerrain::Terrain obect instead of a CoordinateSystemNode.  This is true despite my not using the --TERRAIN flag.  My osgTerrain::Terrain object has empty strings for both Format and CoordinateSystem, but the osgTerrain::Locator object nested inside does have proper Format and CoordinateSystem strings.  I can extract this info in the following way:


Code:

osgTerrain::Terrain* terrain = dynamic_cast<osgTerrain::Terrain*>(node.get());
        osg::PagedLOD* pagedLOD = dynamic_cast<osg::PagedLOD*>(terrain->getChild(0));
        osgTerrain::TerrainTile* terrainTile = dynamic_cast<osgTerrain::TerrainTile*>(pagedLOD->getChild(0));
        osgTerrain::Locator* locator = terrainTile->getLocator();
        string format = locator->getFormat();
        string coordinateSystem = locator->getCoordinateSystem();




where node is the top level osgTerrain::Terrain node that I read in from file.

Below is the top part of my terrain.osg file:


Code:

osgTerrain::Terrain {
  name "xxx\xxx\xxx\terrain.ive"
  nodeMask 0xffffffff
  cullingActive TRUE
  SampleRatio 1
  VerticalScale 1
  BlendingPolicy INHERIT
  Format ""
  CoordinateSystem ""
  num_children 1
  PagedLOD {
    nodeMask 0xffffffff
    cullingActive TRUE
    Center 731350 3.49247e+006 2211.23
    Radius -1
    RangeMode DISTANCE_FROM_EYE_POINT
    RangeList 2 {
      1.60316e+006 1e+010
      0 1.60316e+006
    }
    NumChildrenThatCannotBeExpired 0
    DisableExternalChildrenPaging 0
    FileNameList 2 {
      ""
      terrain_root_L0_X0_Y0/terrain_L0_X0_Y0_subtile.ive
    }
    num_children 1
    osgTerrain::TerrainTile {
      nodeMask 0xffffffff
      cullingActive TRUE
      BlendingPolicy INHERIT
      osgTerrain::Locator {
        UniqueID Locator_0
        Format "WKT"
        CoordinateSystem "PROJCS["UTM Zone 41, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",63],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]"
        CoordinateSystemType PROJECTED
        TransformScaledByResolution FALSE
        Transform {
          347303.25 0 0 0
          0 298624.25 0 0
          0 0 1 0
          557698.6875 3343161.75 0 1
        }
      }




------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=51523#51523





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
casperyap
Newbie


Joined: 16 Jan 2015
Posts: 1

PostPosted: Fri Jan 16, 2015 7:34 am    Post subject:
Reply with quote

Hi,

I am having the same problem recently. After stepping through the osgdem source code, it seems that there may be a bug in DataSet.cpp line 1905. There was a missing "!". Instead of

...
if (_destinationCoordinateSystem.valid && _destinationCoordinateSyste->getCoordinateSystem().empty()) ....

I replaced it with

if (_destinationCoordinateSystem.valid && !_destinationCoordinateSyste->getCoordinateSystem().empty())

The coordinate systems would be in after the above modification. Hope this helps. Smile

Cheers,
Casper
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Sat Jan 17, 2015 11:01 am    Post subject:
Retrieve coordinate system string from osgdem-generated terrain
Reply with quote

Hi Casper,

If you think you have a fix could you post the whole modified file to osg-submissions.

Thanks,
Robert.


On 16 January 2015 at 07:34, Casper Yap < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

I am having the same problem recently. After stepping through the osgdem source code, it seems that there may be a bug in DataSet.cpp line 1905. There was a missing "!". Instead of

...
if (_destinationCoordinateSystem.valid && _destinationCoordinateSyste->getCoordinateSystem().empty()) ....

I replaced it with

if (_destinationCoordinateSystem.valid && !_destinationCoordinateSyste->getCoordinateSystem().empty())

The coordinate systems would be in after the above modification. Hope this helps. Smile

Cheers,
Casper

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> VirtualPlanetBuilder [vpb] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Building OSG for Android -- Windowing... bwhaines Build system [build] 1 Sun Apr 23, 2017 2:01 am View latest post
No new posts Fix FBX conversion to OpenGL coordina... Farshid Lashkari Submission 1 Wed Mar 15, 2017 6:34 pm View latest post
No new posts How to query height of terrain given ... vinothrajendran4 VirtualPlanetBuilder [vpb] 0 Tue Mar 14, 2017 2:43 pm View latest post
No new posts Height of terrain bhanu406 General 5 Fri Mar 03, 2017 7:56 am View latest post
No new posts Error building terrain with shapefile... robertosfield VirtualPlanetBuilder [vpb] 0 Mon Feb 06, 2017 9:11 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP