Package nav.position

Examples of nav.position.Position


        // If the two positions are different, then add the current latest
        // position to the trail and replace it with the new position
        if (position.getLatitude() != latestPosition.getLatitude()
                || position.getLongitude() != latestPosition.getLongitude()) {
            try {
                updateTrail(new Trail(new Position(latestPosition.getLatitude(),
                        latestPosition.getLongitude())));
                drawHull();
            } catch (Exception e) {
                e.printStackTrace();
            }
View Full Code Here


            return;
        } else {
            color = Color.BLACK;
        }

        Position bow = getBowPosition();
        Position stern = getSternPosition();
        int heading = getHeading();
        if (heading < 0 || heading > 360) {
            heading = getCourse();
            if (heading < 0 || heading > 360) {
                return;
            }
        }
        double dist = getDistanceToBow();
        dist = dist * 0.3;
        Position bowTip = NavCalculator.computePosition(bow, heading, dist);
        int direction;
       
        dist = getBeam() / 2;

        if (heading >= 90) {
            direction = heading - 90;
        } else {
            direction = (heading - 90) + 360;
        }
        Position bowPort = NavCalculator.computePosition(bow, direction, dist);
        Position sternPort = NavCalculator.computePosition(stern, direction, dist);
        if (heading <= 270) {
            direction = heading + 90;
        } else {
            direction = (heading + 90) - 360;
        }
        Position sternStarboard = NavCalculator.computePosition(stern, direction, dist);
        Position bowStarboard = NavCalculator.computePosition(bow, direction, dist);
        double elevation = visibleTrail.getPositions().iterator().next().getElevation();
        List<gov.nasa.worldwind.geom.Position> boundaries = new ArrayList<gov.nasa.worldwind.geom.Position>();
        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(bowPort.getLatitude(), bowPort.getLongitude()), elevation));
        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(sternPort.getLatitude(), sternPort.getLongitude()), elevation));
        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(sternStarboard.getLatitude(), sternStarboard.getLongitude()), elevation));

        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(bowStarboard.getLatitude(), bowStarboard.getLongitude()), elevation));
        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(bowTip.getLatitude(), bowTip.getLongitude()), elevation));
//        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(getPosition().getLatitude(), getPosition().getLongitude()), elevation));
//        boundaries.add(new gov.nasa.worldwind.geom.Position(LatLon.fromDegrees(getCentroid().getLatitude(), getCentroid().getLongitude()), elevation));


View Full Code Here

        // Latitude (29-116)
        float lat = extractPosition(input.substring(28));

        // Init the position vessel's position
        try {
            position = new Position(lat, lng);
        } catch (InvalidPositionException ipe) {
            try {
                position = new Position(0, 0);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
View Full Code Here

     * @return                  The predicted future <code>Position</code>.
     * @since 1.0
     */
    public static Position predictPosition(int time, double speed,
            double currentLat, double currentLong, double course) {
        Position futurePosition = null;
        course = Math.toRadians(course);
        double futureLong = currentLong + speed * time * Math.sin(course);
        double futureLat = currentLat + speed * time * Math.cos(course);
        try {
            futurePosition = new Position(futureLat, futureLong);
        } catch (InvalidPositionException ipe) {
            ipe.printStackTrace();
        }
        return futurePosition;

View Full Code Here

        super(contents);
    }

    private void assignPosition() {
        try {
            pos = new Position(Double.parseDouble(contents[14]), Double.parseDouble(contents[15]));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

            angle = heading - 180;
        } else {
            angle = 360 - heading;
        }

        Position newPosition = null;

        // Convert meters into nautical miles
        distance = distance * 0.000539956803;
        angle = Math.toRadians(angle);
        double initialLat = initialPos.getLatitude();
        double initialLong = initialPos.getLongitude();
        double dlat = distance * Math.cos(angle);
        dlat = dlat / 60;
        dlat = Math.abs(dlat);
        double newLat = 0;
        if ((heading > 270 && heading < 360) || (heading > 0 && heading < 90)) {
            newLat = initialLat + dlat;
        } else if (heading < 270 && heading > 90) {
            newLat = initialLat - dlat;
        }
        double meanLat = (Math.abs(dlat) / 2.0) + newLat;
        double dep = (Math.abs(dlat * 60)) * Math.tan(angle);
        double dlong = dep * (1.0 / Math.cos(Math.toRadians(meanLat)));
        dlong = dlong / 60;
        dlong = Math.abs(dlong);
        double newLong;
        if (heading > 180 && heading < 360) {
            newLong = initialLong - dlong;
        } else {
            newLong = initialLong + dlong;
        }

        if (newLong < -180) {
            double diff = Math.abs(newLong + 180);
            newLong = 180 - diff;
        }

        if (newLong > 180) {
            double diff = Math.abs(newLong + 180);
            newLong = (180 - diff) * -1;
        }

        if (heading == 0 || heading == 360 || heading == 180) {
            newLong = initialLong;
            newLat = initialLat + dlat;
        } else if (heading == 90 || heading == 270) {
            newLat = initialLat;
//            newLong = initialLong + dlong; THIS WAS THE ORIGINAL (IT WORKED)
            newLong = initialLong - dlong;
        }
        try {
            newPosition = new Position(newLat,
                    newLong);
        } catch (InvalidPositionException ipe) {
            ipe.printStackTrace();
            System.out.println(newLat + "," + newLong);
        }
View Full Code Here

        assignPosition();
    }

    private void assignPosition() {
        try {
            pos = new Position(Double.parseDouble(contents[14]), Double.parseDouble(contents[15]));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of nav.position.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.