Package gov.nasa.worldwind.geom

Examples of gov.nasa.worldwind.geom.Position


    protected void _assembleVertexControlPoints_(DrawContext dc)
    {
        Terrain terrain = dc.getTerrain();
        Path pol = (Path) super._pol_;

        Position refPos = pol.getReferencePosition();
        Vec4 refPoint = terrain.getSurfacePoint(refPos.getLatitude(), refPos.getLongitude(), 0);

        int altitudeMode = pol.getAltitudeMode();
        double height = 1000; // pol.getHeight();

        Vec4 vaa = null;
        double vaaLength = 0; // used to compute independent length of each cap vertex
        double vaLength = 0;

        int i = 0;
       
        for (LatLon location : pol.getPositions())
        {
            Vec4 vert;

            // Compute the top/cap point.
            if (altitudeMode == WorldWind.CONSTANT || !(location instanceof Position))
            {
                if (vaa == null)
                {
                    // Compute the vector lengths of the top and bottom points at the reference position.
                    vaa = refPoint.multiply3(height / refPoint.getLength3());
                    vaaLength = vaa.getLength3();
                    vaLength = refPoint.getLength3();
                }

                // Compute the bottom point, which is on the terrain.
                vert = terrain.getSurfacePoint(location.getLatitude(), location.getLongitude(), 0);

                double delta = vaLength - vert.dot3(refPoint) / vaLength;
                vert = vert.add3(vaa.multiply3(1d + delta / vaaLength));
            }
            else if (altitudeMode == WorldWind.RELATIVE_TO_GROUND)
            {
                vert = terrain.getSurfacePoint(location.getLatitude(), location.getLongitude(),
                    ((Position) location).getAltitude());
            }
            else // WorldWind.ABSOLUTE
            {
                vert = terrain.getGlobe().computePointFromPosition(location.getLatitude(), location.getLongitude(),
                    ((Position) location).getAltitude() * terrain.getVerticalExaggeration());
            }

            Position vertexPosition = super._wwd.getModel().getGlobe().computePositionFromPoint(vert);
           
            GfrMrkMoveHoriz pnt = new GfrMrkMoveHoriz(vertexPosition, vert,
                this._bmaControlVertex, i);

            this._lstMarkerControlPoints.add(pnt);
View Full Code Here


    protected void moveControlPoint(GfrMrkMoveHoriz controlPoint, Point lastMousePoint, Point moveToPoint)
    {
        View view = super._wwd.getView();
        Globe globe = super._wwd.getModel().getGlobe();

        Position refPos = controlPoint.getPosition();
        if (refPos == null)
            return;

        Line ray = view.computeRayFromScreenPoint(moveToPoint.getX(), moveToPoint.getY());
        Line previousRay = view.computeRayFromScreenPoint(lastMousePoint.getX(), lastMousePoint.getY());

        Vec4 vec = AirspaceEditorUtil.intersectGlobeAt(super._wwd, refPos.getElevation(), ray);
        Vec4 previousVec = AirspaceEditorUtil.intersectGlobeAt(super._wwd, refPos.getElevation(), previousRay);

        if (vec == null || previousVec == null)
        {
            return;
        }

        Position pos = globe.computePositionFromPoint(vec);
        Position previousPos = globe.computePositionFromPoint(previousVec);
        LatLon change = pos.subtract(previousPos);

        java.util.List<LatLon> boundary = new ArrayList<LatLon>();
  
        for (LatLon ll : ((Path) this._pol_).getPositions()) 
        {
            boundary.add(ll);
        }
       
        int intIndexControlPoint = controlPoint.getIndex();
       
       
        /*
         * There is a bug here :
         * refPos.getAltitude() gives the altitude of the control node :
         * e.g.
         *     3250m in a mountain,
         *     -4232m in the ocean.
         * But the posNew, while rendering is threated the elevation of the
         * control node ABOVE the elevation of the ground level.
         *
         * Nice example of this bug between France and Italy with a Path
         * from the Alps to Ligurian Sea.
         * The control node in the mountain increases its altitude everytime it is moved,
         * while the control node in the sea decreases its altitude.
         *
         * => possible fix : hard code a fix value instead of  refPos.getAltitude()
         * use the value of refPos.getAltitude() as a fix altitude, and not the
         * height above ground level.
         */
        Position posNew = new Position(pos.add(change), refPos.getAltitude());

        boundary.set(intIndexControlPoint, posNew);

        // Path ensures that the last boundary position is the same as the first. Remove the last point
        // before setting the boundary.

        java.util.List<Position> boundary2 = new ArrayList<Position>();
       
        for (LatLon ll : boundary)
        {
            boundary2.add(new Position(ll, ((Position) ll).getElevation()));
        }

        ((Path) this._pol_).setPositions(boundary2);
    }
View Full Code Here

    {
        // Find the closest points between the rays through each screen point, and the ray from the control point
        // and in the direction of the globe's surface normal. Compute the elevation difference between these two
        // points, and use that as the change in polygon height.

        Position referencePos = this._pol_.getReferencePosition();
       
        if (referencePos == null)
            return;

        Vec4 referencePoint = super._wwd.getModel().getGlobe().computePointFromPosition(referencePos);

        Vec4 surfaceNormal = super._wwd.getModel().getGlobe().computeSurfaceNormalAtLocation(referencePos.getLatitude(),
            referencePos.getLongitude());
        Line verticalRay = new Line(referencePoint, surfaceNormal);
        Line screenRay = super._wwd.getView().computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());
        Line previousScreenRay = super._wwd.getView().computeRayFromScreenPoint(previousMousePoint.getX(),
            previousMousePoint.getY());

        Vec4 pointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, screenRay);
        Vec4 previousPointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, previousScreenRay);

        Position pos = super._wwd.getModel().getGlobe().computePositionFromPoint(pointOnLine);
        Position previousPos = super._wwd.getModel().getGlobe().computePositionFromPoint(previousPointOnLine);
        double elevationChange = pos.getElevation() - previousPos.getElevation();

        java.util.List<Position> boundary = new ArrayList<Position>();
       
        for (LatLon ll : ((Path) this._pol_).getPositions())
        {
            boundary.add(new Position(ll, ((Position) ll).getElevation() + elevationChange));
        }

        ((Path) this._pol_).setPositions(boundary);
    }
View Full Code Here

                    nearestDistance = d;
                }
            }
        }

        Position newPosition = super._wwd.getModel().getGlobe().computePositionFromPoint(pickPoint);

        // Copy the outer boundary list
        ArrayList<Position> positionList = new ArrayList<Position>(this._lstMarkerControlPoints.size());
       
        for (LatLon position : ((Path) super._pol_).getPositions())
View Full Code Here

       
        java.util.List<Position> boundary2 = new ArrayList<Position>();
       
        for (LatLon ll : locations)
        {
            boundary2.add(new Position(ll, ((Position) ll).getElevation()));
        }

        polygon.setPositions(boundary2);
        return true;
    }
View Full Code Here

        // intersected positions to move the control point's location.

        View view = this._wwd.getView();
        Globe globe = this._wwd.getModel().getGlobe();

        Position refPos = this._pol_.getReferencePosition();
        if (refPos == null)
            return;

        Line ray = view.computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());
        Line previousRay = view.computeRayFromScreenPoint(previousMousePoint.getX(), previousMousePoint.getY());

        Vec4 vec = AirspaceEditorUtil.intersectGlobeAt(this._wwd, refPos.getElevation(), ray);
        Vec4 previousVec = AirspaceEditorUtil.intersectGlobeAt(this._wwd, refPos.getElevation(), previousRay);

        if (vec == null || previousVec == null)
        {
            return;
        }

        Position pos = globe.computePositionFromPoint(vec);
        Position previousPos = globe.computePositionFromPoint(previousVec);
        LatLon change = pos.subtract(previousPos);

        this._pol_.move(new Position(change.getLatitude(), change.getLongitude(), 0.0));
    }
View Full Code Here

        if (this._lstMarkerControlPoints.size() < 2)
            return;

        // Add one control point for the height between the first and second vertices.
        // TODO: ensure that this control point is visible
        Position firstVertex = this._lstMarkerControlPoints.get(0).getPosition();
        Position secondVertex = this._lstMarkerControlPoints.get(1).getPosition();

        Globe globe = this._wwd.getModel().getGlobe();

        // Get cartesian points for the vertices
        Vec4 firstPoint = globe.computePointFromPosition(firstVertex);
        Vec4 secondPoint = globe.computePointFromPosition(secondVertex);

        // Find the midpoint of the line segment that connects the vertices
        Vec4 halfwayPoint = firstPoint.add3(secondPoint).divide3(2.0);

        Position halfwayPosition = globe.computePositionFromPoint(halfwayPoint);
       
        this._lstMarkerControlPoints.add(new GfrMrkMoveVert(halfwayPosition, halfwayPoint,
            this._bmaControlHeight, this._lstMarkerControlPoints.size()));
    }
View Full Code Here

   public Position getGeometryPointStart(String strIdObject) throws Exception
   {
      Point2D.Double p2d = getGeometryPointStartAsPoint2D(strIdObject);

      //Memo Reading Lon Lat, but LatLon necessary for Position
      Position pos = Position.fromDegrees(p2d.getY(), p2d.getX());
      return pos;
   }
View Full Code Here

   public Position getGeometryPointEnd(String strIdObject) throws Exception
   {
      Point2D.Double p2d = getGeometryPointEndAsPoint2D(strIdObject);

      //Memo Reading Lon Lat, but LatLon necessary for Position
      Position pos = Position.fromDegrees(p2d.getY(), p2d.getX());
      return pos;
   }
View Full Code Here

   {

      List<Position> lstPosition = new ArrayList<Position>();


      Position posStart = getGeometryPointStart(strIdObject);
      Position posEnd = getGeometryPointEnd(strIdObject);

      lstPosition.add(posStart);
      lstPosition.add(posEnd);

View Full Code Here

TOP

Related Classes of gov.nasa.worldwind.geom.Position

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.