Package slash.navigation.common

Examples of slash.navigation.common.BoundingBox


                if (i < positions.size() - 1)
                    waypointsBuffer.append(",");
            }
        }

        BoundingBox boundingBox = new BoundingBox(positions);
        String southWestBuffer = "new google.maps.LatLng(" + boundingBox.getSouthWest().getLatitude() + "," + boundingBox.getSouthWest().getLongitude() + ")";
        String northEastBuffer = "new google.maps.LatLng(" + boundingBox.getNorthEast().getLatitude() + "," + boundingBox.getNorthEast().getLongitude() + ")";
        String centerBuffer = "new google.maps.LatLng(" + boundingBox.getCenter().getLatitude() + "," + boundingBox.getCenter().getLongitude() + ")";

        String output = template.replaceAll("INSERT_ROUTENAME", route.getName()).
                replaceAll("INSERT_TRACK", routeBuffer.toString()).
                replaceAll("INSERT_ROUTE", trackBuffer.toString()).
                replaceAll("INSERT_WAYPOINTS", waypointsBuffer.toString()).
View Full Code Here


    }

    public static BoundingBox asBoundingBox(BoundingBoxType boundingBox) {
        if (boundingBox == null || boundingBox.getNorthEast() == null || boundingBox.getSouthWest() == null)
            return null;
        return new BoundingBox(asPosition(boundingBox.getNorthEast()), asPosition(boundingBox.getSouthWest()));
    }
View Full Code Here

        // reduce the number of result to those that are visible for tracks and waypoint lists
        if (positions.size() > maximumPositionCount && !characteristics.equals(Route)) {
            double visiblePositionAreaFactor = preferences.getDouble("visiblePositionAreaFactor", 3.0);
            double factor = max(visiblePositionAreaFactor * (zoom - MAXIMUM_ZOOM_FOR_SIGNIFICANCE_CALCULATION), 1) * visiblePositionAreaFactor;
            positions = filterVisiblePositions(positions, factor, false);
            visible = new BoundingBox(positions);
        } else {
            visible = null;
        }

        // reduce the number of result by selecting every Nth to limit significance computation time
View Full Code Here

        double height = abs(southWest.getLatitude() - northEast.getLatitude()) * threshold;
        northEast.setLongitude(northEast.getLongitude() + width);
        northEast.setLatitude(northEast.getLatitude() + height);
        southWest.setLongitude(southWest.getLongitude() - width);
        southWest.setLatitude(southWest.getLatitude() - height);
        BoundingBox boundingBox = new BoundingBox(northEast, southWest);

        List<NavigationPosition> result = new ArrayList<NavigationPosition>();

        if (includeFirstAndLastPosition)
            result.add(positions.get(0));

        int firstIndex = includeFirstAndLastPosition ? 1 : 0;
        int lastIndex = includeFirstAndLastPosition ? positions.size() - 1 : positions.size();

        NavigationPosition previousPosition = positions.get(firstIndex);
        boolean previousPositionVisible = boundingBox.contains(previousPosition);

        for (int i = firstIndex; i < lastIndex; i += 1) {
            NavigationPosition position = positions.get(i);
            boolean visible = boundingBox.contains(position);
            if (visible) {
                // if the previous position was not visible but the current position is visible:
                // add the previous position to render transition from non-visible to visible area
                if (!previousPositionVisible && previousPosition != null)
                    result.add(previousPosition);
View Full Code Here

        // Top. Karte 1:50.000 Nieders.
        // Top. Karte 1:50000 Sh/HH
        writeMissingAttribute(route.getMapLage(), writer, "MapName", "Bundesrepublik 1:1 Mio");
        writeMissingAttribute(route.getMapLage(), writer, "DimmFc", "100");
        writeMissingAttribute(route.getMapLage(), writer, "ZoomFc", "100");
        NavigationPosition center = new BoundingBox(route.getPositions()).getCenter();
        writeMissingAttribute(route.getMapLage(), writer, "CenterLat", formatPositionAsString(center.getLatitude()));
        writeMissingAttribute(route.getMapLage(), writer, "CenterLong", formatPositionAsString(center.getLongitude()));
        writer.println(CREATOR + NAME_VALUE_SEPARATOR + GENERATED_BY);
    }
View Full Code Here

                        } else
                            continue;
                    }

                    List<NavigationPosition> render = positionReducer.reduceSelectedPositions(copiedPositions, copiedSelectedPositionIndices);
                    NavigationPosition centerPosition = render.size() > 0 ? new BoundingBox(render).getCenter() : null;
                    selectPositions(render, recenter ? centerPosition : null);
                    log.info("Selected positions updated for " + render.size() + " positions, recentering: " + recenter + " to: " + centerPosition);
                    lastTime = currentTimeMillis();
                }
            }
View Full Code Here

    private void setCenterOfMap(List<NavigationPosition> positions, boolean recenter) {
        StringBuilder buffer = new StringBuilder();

        boolean fitBoundsToPositions = positions.size() > 0 && recenter;
        if (fitBoundsToPositions) {
            BoundingBox boundingBox = new BoundingBox(positions);
            buffer.append("fitBounds(").append(boundingBox.getSouthWest().getLatitude()).append(",").
                    append(boundingBox.getSouthWest().getLongitude()).append(",").
                    append(boundingBox.getNorthEast().getLatitude()).append(",").
                    append(boundingBox.getNorthEast().getLongitude()).append(");\n");
            ignoreNextZoomCallback = true;
        }

        if (haveToInitializeMapOnFirstStart) {
            NavigationPosition center;
            // if there are positions right at the start center on them else take the last known center and zoom
            if (positions.size() > 0) {
                center = new BoundingBox(positions).getCenter();
            } else {
                int zoom = getZoom();
                buffer.append("setZoom(").append(zoom).append(");\n");
                center = getLastMapCenter();
            }
View Full Code Here

        if (selectPositionsMatcher.matches()) {
            Double latitudeNorthEast = parseDouble(selectPositionsMatcher.group(1));
            Double longitudeNorthEast = parseDouble(selectPositionsMatcher.group(2));
            Double latitudeSouthWest = parseDouble(selectPositionsMatcher.group(3));
            Double longitudeSouthWest = parseDouble(selectPositionsMatcher.group(4));
            final BoundingBox boundingBox = new BoundingBox(longitudeNorthEast, latitudeNorthEast,
                    longitudeSouthWest, latitudeSouthWest);
            final Boolean replaceSelection = parseBoolean(selectPositionsMatcher.group(5));
            invokeLater(new Runnable() {
                public void run() {
                    selectPositions(boundingBox, replaceSelection);
View Full Code Here

            return null;
        // otherwise center between given positions
        NavigationPosition second = positionsModel.getPosition(row + 1);
        if (!second.hasCoordinates() || !position.hasCoordinates())
            return null;
        return new BoundingBox(asList(second, position)).getCenter();
    }
View Full Code Here

        return new SimpleNavigationPosition(longitude, latitude);
    }

    @Test
    public void testContains() {
        assertTrue(new BoundingBox(0.1, 0.1, -0.1, -0.1).contains(asPosition(0.0, 0.0)));
        assertTrue(new BoundingBox(-1.0, -1.0, -2.0, -2.0).contains(asPosition(-1.5, -1.5)));
        assertTrue(new BoundingBox(-1.0, 2.0, -2.0, 1.0).contains(asPosition(-1.5, 1.5)));
        assertTrue(new BoundingBox(2.0, 2.0, 1.0, 1.0).contains(asPosition(1.5, 1.5)));
        assertTrue(new BoundingBox(2.0, -1.0, 1.0, -2.0).contains(asPosition(1.5, -1.5)));
    }
View Full Code Here

TOP

Related Classes of slash.navigation.common.BoundingBox

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.