Announcement

Collapse
No announcement yet.

Basic Dragger Issue

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

  • Basic Dragger Issue

    Since updating to 2.1.0, I get a null pointer exception when trying to drag a placemark using a basic dragger.

  • #2
    Hello,

    The BasicDragger received an update in 2.1.0 to account for drifting away from the cursor during dragging. Classes implementing Movable or Movable2 in the SDK were updated to use the new Draggable interface. I ran the Placemarks example in the SDK with a BasicDragger and did not see the NPE during dragging operations.

    Are you using one of the base WW classes or a custom class? There does seem to be an issue with handling of legacy drag operations, see this issue:
    https://github.com/NASAWorldWind/Wor...Java/issues/94
    This would occur if you were using a Movable/Movable2 object that had not been updated to the Draggable interface. The standard PointPlacemark was updated in 2.1.0 and my testing indicates there isn't a problem, but if you can provide more details, I might be able to duplicate the behavior.

    Thanks,
    Zach
    Zach
    World Wind Team
    https://github.com/NASAWorldWind

    Comment


    • #3
      So I have a custom placemark class that implemented movable but now implements draggable. I am having issues converting the point to a position.

      Point screenPoint = dragContext.getPoint();
      Vec4 screenCoordinates = new Vec4(screenPoint.getX(), screenPoint.getY());
      Vec4 cartesian = dragContext.getView().unProject(screenCo ordinates);
      Position position = dragContext.getGlobe().computePositionFr omPoint(cartesian);
      this.moveTo(position);

      The last line sets the position of the placemark. Any info on converting a point to a position?

      Comment


      • #4
        Changed my code to the following and seems to work...

        Point screenPoint = dragContext.getPoint();
        View view = dragContext.getView();

        double latitude = view.computePositionFromScreenPoint(scre enPoint.getX(), screenPoint.getY()).getLatitude().degree s;
        double longitude = view.computePositionFromScreenPoint(scre enPoint.getX(), screenPoint.getY()).getLongitude().degre es;
        Position position = new Position(LatLon.fromDegrees(latitude, longitude), 0);

        Comment


        • #5
          I recommend using the DraggableSupport object. It accounts for billboard vs terrain object presentations and dragging on terrain or the ellipsoid. It will also handle the position conversions and, since you've implemented Movable, it will call it automatically.

          Check out the drag and doDrag methods in PointPlacemark for an example of to use DraggableSupport:
          https://github.com/NASAWorldWind/Wor...ark.java#L1746

          Zach
          Zach
          World Wind Team
          https://github.com/NASAWorldWind

          Comment

          Working...
          X