Package slash.navigation.common

Examples of slash.navigation.common.NavigationPosition


    }

    public double getDistance(int startIndex, int endIndex) {
        double result = 0;
        List<P> positions = getPositions();
        NavigationPosition previous = null;
        for (int i = startIndex; i <= endIndex; i++) {
            NavigationPosition next = positions.get(i);
            if (previous != null) {
                Double distance = previous.calculateDistance(next);
                if (distance != null)
                    result += distance;
            }
View Full Code Here


    public double[] getDistancesFromStart(int startIndex, int endIndex) {
        double[] result = new double[endIndex - startIndex + 1];
        List<P> positions = getPositions();
        int index = 0;
        double distance = 0.0;
        NavigationPosition previous = positions.size() > 0 ? positions.get(0) : null;
        while (index <= endIndex) {
            NavigationPosition next = positions.get(index);
            if (previous != null) {
                Double delta = previous.calculateDistance(next);
                if (delta != null)
                    distance += delta;
                if (index >= startIndex)
View Full Code Here

            int endIndex = min(indices[indices.length - 1], getPositionCount() - 1);

            int index = 0;
            double distance = 0.0;
            List<P> positions = getPositions();
            NavigationPosition previous = positions.get(0);
            while (index <= endIndex) {
                NavigationPosition next = positions.get(index);
                if (previous != null) {
                    Double delta = previous.calculateDistance(next);
                    if (delta != null)
                        distance += delta;
                    int indexInIndices = binarySearch(indices, index);
View Full Code Here

    }

    public double getElevationAscend(int startIndex, int endIndex) {
        double result = 0;
        List<P> positions = getPositions();
        NavigationPosition previous = null;
        for (int i = startIndex; i <= endIndex; i++) {
            NavigationPosition next = positions.get(i);
            if (previous != null) {
                Double elevation = previous.calculateElevation(next);
                if (elevation != null && elevation > 0)
                    result += elevation;
            }
View Full Code Here

    }

    public double getElevationDescend(int startIndex, int endIndex) {
        double result = 0;
        List<P> positions = getPositions();
        NavigationPosition previous = null;
        for (int i = startIndex; i <= endIndex; i++) {
            NavigationPosition next = positions.get(i);
            if (previous != null) {
                Double elevation = previous.calculateElevation(next);
                if (elevation != null && elevation < 0)
                    result += abs(elevation);
            }
View Full Code Here

        return result;
    }

    public double getElevationDelta(int index) {
        List<P> positions = getPositions();
        NavigationPosition previous = index > 0 ? positions.get(index - 1) : null;
        NavigationPosition current = index < positions.size() ? positions.get(index) : null;
        if(previous != null && current != null) {
            Double elevation = previous.calculateElevation(current);
            if(elevation != null)
                return elevation;
        }
View Full Code Here

        return new SimpleNavigationPosition(longitude, latitude);
    }

    private void filterEveryNthPosition(int positionCount, int maximumPositionCount) {
        List<NavigationPosition> positions = new ArrayList<NavigationPosition>();
        NavigationPosition first = asPosition(0.0, 0.0);
        positions.add(first);

        for (int i = 1; i < positionCount - 1; i++)
            positions.add(asPosition(i, 0.0));

        NavigationPosition last = asPosition(positionCount - 1, 0.0);
        positions.add(last);

        List<NavigationPosition> result = reducer.filterEveryNthPosition(positions, maximumPositionCount);

        assertEquals(maximumPositionCount, result.size());
View Full Code Here

    }

    @Test
    public void testFilterVisiblePosition() throws Exception {
        List<NavigationPosition> positions = new ArrayList<NavigationPosition>();
        NavigationPosition one = asPosition(0.0, 0.0);
        positions.add(one);
        NavigationPosition two = asPosition(0.1, 0.1);
        positions.add(two);
        NavigationPosition threeNotVisible = asPosition(45.0, 45.0);
        positions.add(threeNotVisible);
        NavigationPosition fourNotVisible = asPosition(45.1, 45.1);
        positions.add(fourNotVisible);
        NavigationPosition fiveNotVisible = asPosition(45.1, 45.1);
        positions.add(fiveNotVisible);
        NavigationPosition six = asPosition(0.2, 0.2);
        positions.add(six);

        List<NavigationPosition> result = reducer.filterVisiblePositions(positions, 1.0, false);
        assertEquals(5, result.size());
        assertEquals(one, result.get(0));
View Full Code Here

    }

    @Test
    public void testFilterVisiblePositionIncludingFirstAndLast() throws Exception {
        List<NavigationPosition> positions = new ArrayList<NavigationPosition>();
        NavigationPosition one = asPosition(0.0, 0.0);
        positions.add(one);
        NavigationPosition two = asPosition(0.1, 0.1);
        positions.add(two);
        NavigationPosition threeNotVisible = asPosition(45.0, 45.0);
        positions.add(threeNotVisible);
        NavigationPosition fourNotVisible = asPosition(45.1, 45.1);
        positions.add(fourNotVisible);
        NavigationPosition fiveNotVisible = asPosition(45.1, 45.1);
        positions.add(fiveNotVisible);
        NavigationPosition six = asPosition(0.2, 0.2);
        positions.add(six);
        NavigationPosition seven = asPosition(0.3, 0.3);
        positions.add(seven);

        List<NavigationPosition> result = reducer.filterVisiblePositions(positions, 1.0, true);
        assertEquals(6, result.size());
        assertEquals(one, result.get(0));
View Full Code Here

*/

public class RouteCalculations {
    private static int[] douglasPeuckerSimplify(List<? extends NavigationPosition> positions, int from, int to, double threshold) {
        // find the point with the maximum distance
        NavigationPosition pointA = positions.get(from);
        NavigationPosition pointB = positions.get(to);
        int maximumDistanceIndex = -1;
        double maximumDistance = 0.0;
        for (int i = from + 1; i < to; i++) {
            NavigationPosition position = positions.get(i);
            if (position.hasCoordinates()) {
                double distance = abs(position.calculateOrthogonalDistance(pointA, pointB));
                if (distance > maximumDistance) {
                    maximumDistance = distance;
                    maximumDistanceIndex = i;
                }
            }
View Full Code Here

TOP

Related Classes of slash.navigation.common.NavigationPosition

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.