Announcement

Collapse
No announcement yet.

Screen coordinates to Lat, Long

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Screen coordinates to Lat, Long

    Hello,

    I am trying to display dinamic sectors in my screen, drawed as rectangles (for example), but i need: latitude min and max, longitude min and max for each sector, and i am having problems to transform screen coordinates to geographic coordinates. Let me explain better:

    I can get the central point of the screen using:
    double latitude = globeFragment.getWorldWindow().getNaviga tor().getLatitude();
    double longitude = globeFragment.getWorldWindow().getNaviga tor().getLongitude();
    double altitude = globeFragment.getWorldWindow().getNaviga tor().getAltitude();

    Imagine that i want to draw 4 sectors and my device has the following dimensions: width: 2048px, height:1440 px. Therefore, my first sector will have these screen coordinates:
    -----------------------------------------------------
    (0,0) (0, WIDTH/2)

    (HEIGHT/2, 0) (HEIGHT/2, WIDTH/2)
    ------------------------------------------------------
    ¿How can i obtain these geographic coordinates using those screen coordinates?. In the documentation i only have seen functions like: cartesianToGeographic, geographicToCartesian , etc but nothing like screenToCartesian(to unproject like in worlwind web). Thank you,

    Mig

  • #2
    I got a solution thanks to a team mate (i write it down. Perhaps could help someone):

    // Get the screen ray

    Line rayLine = new Line(); globeFragment.getWorldWindow().rayThroug hScreenPoint(0,100,rayLine);

    // Intersects the ray with the globe -> cartesian coord.

    Vec3 cartesianCoord= new Vec3();

    globeFragment.getWorldWindow().getGlobe( ).intersect(rayLine, cartesianCoord);

    // Transform cartesian to geographic coord.

    Position result = new Position();

    globeFragment.getWorldWindow().getGlobe( ).cartesianToGeographic(cartesianCoord.x , cartesianCoord.y, cartesianCoord.z, result);
    Last edited by migvf; 03-11-2019, 03:01 PM.

    Comment

    Working...
    X