World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 06-03-2010, 03:50 PM   #1
Kashank
Senior Member
 
Join Date: Jun 2009
Posts: 128
Kashank is on a distinguished road
Exclamation Position, Altitude and Elevation

Ok forgive me first off because I know there's several posts about this, however I'm still having issues with it.

First off. I'm drawing models with toolsheds model loader, and GlobeAnnotations

I have point data being sent to me, LAT, LON and ALT (MEAN SEA LEVEL!).

I have been creating Position variables just like this (wrongly)

Code:
Position newPos = new Position(Angle.fromDegreesLatitude(Lat), Angle.fromDegreesLongitude(Lon), ALT);
And until recently I thought this was ok... then I started noticing that in Aspen Colorado the GlobeAnnotations and the models draw at drastically different Heights above the globe. The GlobeAnnotations draw alot higher than the models. And this is when I noticed that the Position class wants an ELEVATION as the 3rd parameter, NOT an ALTITUDE. So I found the differences between the two and I tried doing it like this instead.

Code:
//ALT is MEAN SEA LEVEL
double ELEV = (globe.getElevation(Angle.fromDegreesLatitude(Lat), Angle.fromDegreesLongitude(Lon))) + ALT;

// Allocate and populate the new position
Position newPos = new Position(Angle.fromDegreesLatitude(Lat), Angle.fromDegreesLongitude(Lon), ELEV);
I calculated the ground elevation and added MSL to it? However in Aspen Colorado the GlobeAnnotations still draw drastically higher than the models.

When I create the GlobeAnnotations I instatiate them by taking newPos (the position I created from my data) and instatiate them like this (a bit shorter version but concept is the same)

Code:
Position GlobeAnnotationPosition = new Position( newPos.latitude, newPos.longitude, newPos.elevation);

GlobeAnnotation GA = new GlobeAnnotation();
GA.setPosition(GlobeAnnotationPosition);

All that basically to say...
How do I properly instatiate a position variable when I'm receiving Altitude (mean sea level) and not the elevation??

And where am I going wrong?


EDIT: Also, I'm drawing SphereAirspace objects. They appear in the same place as the Models, They are drawn significantly Lower than the GlobeAnnotations

Last edited by Kashank; 06-03-2010 at 04:00 PM.
Kashank is offline   Reply With Quote
Old 06-03-2010, 05:13 PM   #2
heidtmare
Senior Member
 
heidtmare's Avatar
 
Join Date: Feb 2008
Location: Melbourne, FL, USA
Posts: 675
heidtmare is on a distinguished road
Default

I was under the impression that annotations are tied to the ground and use a drawOffset to adjust relative position.

so in my head model should be:
PHP Code:
double ALT_MSL 
and annotation should be:
PHP Code:
double ALT_AGL ALT_MSL - (globe.getElevation(Angle.fromDegreesLatitude(Lat), Angle.fromDegreesLongitude(Lon))); 
or i could be way wrong, you never can tell...
heidtmare is offline   Reply With Quote
Old 06-03-2010, 05:19 PM   #3
Kashank
Senior Member
 
Join Date: Jun 2009
Posts: 128
Kashank is on a distinguished road
Default

Quote:
Originally Posted by heidtmare View Post
I was under the impression that annotations are tied to the ground and use a drawOffset to adjust relative position.

so in my head model should be:
PHP Code:
double ALT_MSL 
and annotation should be:
PHP Code:
double ALT_AGL ALT_MSL - (globe.getElevation(Angle.fromDegreesLatitude(Lat), Angle.fromDegreesLongitude(Lon))); 
or i could be way wrong, you never can tell...
Oh forgive me. The annotations' Leader is supposed to be pointing right at the position of the model.

If you still don't know what I mean... Picture a comic book, where the leader(point) of the dialog bubble is inside the characters mouth... My model would be the characters mouth, and the dialog bubble is the globeannotation.

Does your answer still apply?
Kashank is offline   Reply With Quote
Old 06-03-2010, 05:41 PM   #4
heidtmare
Senior Member
 
heidtmare's Avatar
 
Join Date: Feb 2008
Location: Melbourne, FL, USA
Posts: 675
heidtmare is on a distinguished road
Default

GlobeAnnotations use Above Ground Level(AGL).

[assumption]Models use Mean Sea Level(MSL).

so your position for annotation needs to be:
PHP Code:
double ALT_AGL ALT_MSL globe.getElevation(Angle.fromDegreesLatitude(Lat), Angle.fromDegreesLongitude(Lon));
Position.fromDegrees(latlonALT_AGL); 
and position of model needs to be:
PHP Code:
Position.fromDegrees(latlonALT_MSL
if my assumption is wrong then they both need to use the AGL value.




EDIT:
Heres another option

Exert from getAnnotationDrawPoint javadoc
Code:
* Get the final Vec4 point at which an annotation will be drawn. If the annotation Position elevation is lower then
* the highest elevation on the globe, it will be drawn above the ground using its elevation as an offset, scaled by
* the current vertical exaggeration. Otherwise, the original elevation will be used.
So, if you override getAnnotationDrawPoint to always use the original elevation you can then pass it the MSL value and all will be right in the world.

from gov.nasa.worldwind.examples.Annotations. java
PHP Code:
// Above mean sea level globe annotation
        
private class AMSLGlobeAnnotation extends GlobeAnnotation
        
{
            public 
AMSLGlobeAnnotation(String textPosition position)
            {
                
super(textposition);
            }

            public 
Vec4 getAnnotationDrawPoint(DrawContext dc)
            {
                return 
dc.getGlobe().computePointFromPosition(this.getPosition().getLatitude(),
                    
this.getPosition().getLongitude(),
                    
this.getPosition().getElevation() * dc.getVerticalExaggeration());
            }
        } 

Last edited by heidtmare; 06-03-2010 at 05:53 PM.
heidtmare is offline   Reply With Quote
Old 06-03-2010, 06:08 PM   #5
Kashank
Senior Member
 
Join Date: Jun 2009
Posts: 128
Kashank is on a distinguished road
Default

Thanks man! your first assumption was correct!

In one of my attempts I was close to getting it right, but I made one too many calculations with the AGL, as opposed to MSL.

There's a great chance in the future that I will do your suggestion with overriding the class! I appreciate all your help
Kashank is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusion about Position class nigel25840 Development Help 4 04-05-2010 09:00 AM
WW1.3.2-Plugin: Layer Edit canosso Add-ons & Scripts 21 02-27-2010 04:37 AM
Icons rendering relative to terrain elevation? elevenette Development Help 13 11-10-2009 02:26 PM
New Elevation Data Layers jdorny Development Help 1 06-12-2007 06:40 PM
Terrain elevation artifact bchix Technical Support 1 03-06-2007 05:13 PM


All times are GMT +1. The time now is 01:56 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.