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 

VPB terrain, Locator, geospatial coordinates


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> VirtualPlanetBuilder [vpb]
View previous topic :: View next topic  
Author Message
Chris 'Xenon' Hanson
Guest





PostPosted: Wed Jul 15, 2009 8:30 pm    Post subject:
VPB terrain, Locator, geospatial coordinates
Reply with quote

I'm having some difficulty with a new tool I'm working on that will hopefully be
released publicly as soon as I can nail this bit down.

Essentially, I'm working on a method to enable deformation of VPB heightfield terrain
during load/save operations (though not dynamically at scenegraph runtime). It would allow
for a variety of tools to hook into the deformation pipeline either while VPB is saving or
OSG is loading a VPB-built scenegraph.

Currently it can easily do "uniform" elevation alterations like clipping/clamping,
scaling, adding/subtracting and find/replacing. However, to be really useful it needs a
way to tell the deformation evaluator where on the Earth the elevation sample in question
is, to permit non-uniform deformations like roads and building sites.

I had originally planned to do this operation directly in VPB, where access to
geospatial coordinates is a bit simpler, but Robert convinced me to do it on the VPB-built
scenegraph via a pseudo-loader/saver that invokes a real/loader/saver while modifying the
scenegraph as it goes through the pipeline.

My coordinate system of choice for communicating the position of the vertex being
deformed is geographic WGS84 lat/lon, since it can be expressed with an X/Y pair of
doubles and works anywhere in the world without needing to know a zone or anything.

This is working fine, but it's difficult for me to reliably recover the WGS84 geographic
coordinates from the VPB-built tiles. Let's imagine we're loading a tile and modifying it
on the fly.

Once an osgTerrain::TerrainTile is loaded, we can find the osgTerrain::Locator within it
as well as an osgTerrain::HeightFieldLayer. The HeightFieldLayer refers to the Locator.
The Locator typically specifies a WKT CoordinateSystem. In this case, my tile IS WGS84
geographic, but I believe different kinds of tiles (built with different VPB options)
could well be different.

Here's my Locator as seen in the .osg file for this tile:
osgTerrain::Locator {
UniqueID Locator_2
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\"]],AUTHORITY[\"EPSG\",\"4326\"]]"
CoordinateSystemType GEOCENTRIC
TransformScaledByResolution FALSE
Transform {
0.000349040550368496 0 0 0
0 0.000349073839882141 0 0
0 0 1 0
0.45727627733832 0.53232542185827 0 1
}
}

Notice "CoordinateSystemType GEOCENTRIC". In my GIS-mindset, geocentric means something
like ECEF coordinates http://en.wikipedia.org/wiki/ECEF and anything using latitude and
longitude is GeoGRAPHIC coordinates.

The HeightFieldLayer contains an origin and interval which can be combined to determine
the coordinates of any vertex in the heightfield. For example, mine are
Origin 26.2000007629395 30.5 0
XInterval 0.00079994200496003
YInterval 0.000800018315203488

To me, those are GeoGRAPHIC, not GeoCENTRIC. But it may be a distinction of terminology.

Now, in my own personal case, this is exactly what I need -- they already appear to be
WGS84 lat/lon and I can go about my business without converting them. But I believe in
some cases, they will need conversion so I want to make sure I can handle that case before
I contribute this code.

I thought that perhaps Locator::convertLocalToModel and convertModelToLocal would be the
thing, but those seem to be for converting between Local coordinates, which range 0...1
across the heightfield (and its associated image layer).

So at the end of the day, I'm trying to come up with a standard set of steps to take
coordinates derived from the Origin and Interval members of the heightfield and get
something that I know will be geographic latitude and longitude, no matter how the dataset
was built by VPB. I know I can use EllipsoidModel's convertLatLongHeightToXYZ and
convertXYZToLatLongHeight to go back and forth between XYZ and Lat/Lon/Elev, no problem.
What I don't know is how to uniformly interpret the values in the heightfield with the
provided Locator in order to always come up with Lat/Lon/Elev (or XYZ to convert to LLA).
I figured it would have to be a method on the Locator, since the Locator is the object
that has and understands the CoordinateSystemType, but
convertLocalToModel/convertModelToLocal (and the combined convertLocalCoordBetween) don't
seem to be the answer.

Enlightenment welcomed. I think folks will really find this code useful once it's robust
enough to release. Attached is a small piece of typical data (very boring terrain in the
middle of a desert) built as .osg format by VPB.

--
Chris 'Xenon' Hanson, omo sanza lettere Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen



------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12264

PostPosted: Thu Jul 16, 2009 7:18 am    Post subject:
VPB terrain, Locator, geospatial coordinates
Reply with quote

Hi Chris,

On Wed, Jul 15, 2009 at 9:29 PM, Chris 'Xenon'
Hanson<> wrote:
Quote:
 Notice "CoordinateSystemType GEOCENTRIC". In my GIS-mindset, geocentric means something
like ECEF coordinates http://en.wikipedia.org/wiki/ECEF and anything using latitude and
longitude is GeoGRAPHIC coordinates.

 The HeightFieldLayer contains an origin and interval which can be combined to determine
the coordinates of any vertex in the heightfield. For example, mine are
         Origin 26.2000007629395 30.5 0
         XInterval 0.00079994200496003
         YInterval 0.000800018315203488

 To me, those are GeoGRAPHIC, not GeoCENTRIC. But it may be a distinction of terminology.

The case when the locator says GEOCENTRIC means that the data should
be projected from GEOGRAPHIC into ECEF coordinates. The above Origin
and XInterval, YInterval are effectively in GEOCRAPHIC in your above
example, but once they've been processed by the locator the final XYZ
coords with be in ECEF.

If the Locator was set to GEOGRAPHIC then this projection into ECEF
would not happen.

So... I believe osgTerrain::Locator is actually doing what you are
expecting it do and then meaning is appropriate. Your confusion
probably comes from the fact above values are effectively intermediate
coords in this context - as the OSG has to place in coords into lat,
long, height before it can convert to ECEF xyz.


Quote:
 Now, in my own personal case, this is exactly what I need -- they already appear to be
WGS84 lat/lon and I can go about my business without converting them. But I believe in
some cases, they will need conversion so I want to make sure I can handle that case before
I contribute this code.

VPB by default uses WGS84 so will be what you want most of the time.
If the model is geocentric then VPB will use WGS84.

However, users can set the destination coordinate system in VPB and in
this case you'll need to convert from the coordinate system it's in to
WGS84 using a tool like PROJ.


Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Thu Jul 16, 2009 3:22 pm    Post subject:
VPB terrain, Locator, geospatial coordinates
Reply with quote

Robert Osfield wrote:
Quote:
VPB by default uses WGS84 so will be what you want most of the time.
If the model is geocentric then VPB will use WGS84.
However, users can set the destination coordinate system in VPB and in
this case you'll need to convert from the coordinate system it's in to
WGS84 using a tool like PROJ.

Ok. Thanks for the explanation.

In the case of the user choosing a non-WGS84+Geographic coordinate system in VPB -- how
does this manifest in the TerrainTile? I see from the .osg that there are _two_ locators
embedded there -- which of these will change in what what to indicate the projection?

Quote:
Robert.

--
Chris 'Xenon' Hanson, omo sanza lettere Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12264

PostPosted: Thu Jul 16, 2009 4:25 pm    Post subject:
VPB terrain, Locator, geospatial coordinates
Reply with quote

Hi Chris,

On Thu, Jul 16, 2009 at 4:22 PM, Chris 'Xenon'
Hanson<> wrote:
Quote:
 In the case of the user choosing a non-WGS84+Geographic coordinate system in VPB -- how
does this manifest in the TerrainTile?

The Locator's CoordinateSystem string will represent the new
coordinate system description.

Quote:
I see from the .osg that there are _two_ locators
embedded there -- which of these will change in what what to indicate the projection?

The use of multiple Locator's enables osgTerrin to handle cases where
the height field and the imagery don't align, with VPB datasets they
all align right now so they'll be identical.

Robert.


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


Joined: 23 May 2009
Posts: 621

PostPosted: Sun Jul 25, 2010 10:01 am    Post subject:
Reply with quote

Hi Chris,

is it possible to share your height modification algorithms you mentioned at the beginning of the thread?


Thank you!

Cheers,
Torben
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 Use PNG as texture for terrain in osg... Rodrigo General [3rdparty] 12 Mon Jan 07, 2019 5:13 pm View latest post
No new posts Mapping texture coordinates to a port... ijwolf8 General 0 Thu Oct 25, 2018 8:11 pm View latest post
No new posts Load an obj file and mapping a given ... aaa3d General 3 Mon Aug 06, 2018 2:27 pm View latest post
No new posts LineSegmentIntersector doesn't give a... MaFa18 General 3 Thu Jun 21, 2018 10:12 am View latest post
No new posts EXTERNAL: Re: EXTERNAL: Re: Writing t... Rowley, Marlin R General 0 Wed Apr 18, 2018 2:31 pm 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