Search in sources :

Example 16 with QuadRect

use of net.osmand.data.QuadRect in project Osmand by osmandapp.

the class RouteLayer method drawXAxisPoints.

private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
    QuadRect latLonBounds = tileBox.getLatLonBounds();
    List<WptPt> xAxisPoints = trackChartPoints.getXAxisPoints();
    float r = 3 * tileBox.getDensity();
    for (int i = 0; i < xAxisPoints.size(); i++) {
        WptPt axisPoint = xAxisPoints.get(i);
        if (axisPoint.getLatitude() >= latLonBounds.bottom && axisPoint.getLatitude() <= latLonBounds.top && axisPoint.getLongitude() >= latLonBounds.left && axisPoint.getLongitude() <= latLonBounds.right) {
            float x = tileBox.getPixXFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
            float y = tileBox.getPixYFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
            canvas.drawCircle(x, y, r + 2 * (float) Math.ceil(tileBox.getDensity()), paintGridOuterCircle);
            canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintGridCircle);
        }
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint)

Example 17 with QuadRect

use of net.osmand.data.QuadRect in project Osmand by osmandapp.

the class RouteLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (helper.getFinalLocation() != null && helper.getRoute().isCalculated()) {
        boolean updatePaints = attrs.updatePaints(view, settings, tileBox);
        attrs.isPaint3 = false;
        attrs.isPaint2 = false;
        if (updatePaints) {
            paintIconAction.setColorFilter(new PorterDuffColorFilter(attrs.paint3.getColor(), Mode.MULTIPLY));
            paintIcon.setColorFilter(new PorterDuffColorFilter(attrs.paint2.getColor(), Mode.MULTIPLY));
        }
        if (coloredArrowUp == null) {
            Bitmap originalArrowUp = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_route_direction_arrow, null);
            coloredArrowUp = originalArrowUp;
        // coloredArrowUp = Bitmap.createScaledBitmap(originalArrowUp, originalArrowUp.getWidth() * 3 / 4,
        // originalArrowUp.getHeight() * 3 / 4, true);
        }
        int w = tileBox.getPixWidth();
        int h = tileBox.getPixHeight();
        Location lastProjection = helper.getLastProjection();
        final RotatedTileBox cp;
        if (lastProjection != null && tileBox.containsLatLon(lastProjection.getLatitude(), lastProjection.getLongitude())) {
            cp = tileBox.copy();
            cp.increasePixelDimensions(w / 2, h);
        } else {
            cp = tileBox;
        }
        final QuadRect latlonRect = cp.getLatLonBounds();
        double topLatitude = latlonRect.top;
        double leftLongitude = latlonRect.left;
        double bottomLatitude = latlonRect.bottom;
        double rightLongitude = latlonRect.right;
        // double lat = 0;
        // double lon = 0;
        // this is buggy lat/lon should be 0 but in that case
        // it needs to be fixed in case there is no route points in the view bbox
        double lat = topLatitude - bottomLatitude + 0.1;
        double lon = rightLongitude - leftLongitude + 0.1;
        drawLocations(tileBox, canvas, topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon);
        if (trackChartPoints != null) {
            drawXAxisPoints(canvas, tileBox);
            LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
            if (highlightedPoint != null && highlightedPoint.getLatitude() >= latlonRect.bottom && highlightedPoint.getLatitude() <= latlonRect.top && highlightedPoint.getLongitude() >= latlonRect.left && highlightedPoint.getLongitude() <= latlonRect.right) {
                float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
                float y = tileBox.getPixYFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
                canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIconSelected);
            }
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap) RotatedTileBox(net.osmand.data.RotatedTileBox) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint) Location(net.osmand.Location)

Example 18 with QuadRect

use of net.osmand.data.QuadRect in project Osmand by osmandapp.

the class MenuBuilder method processNearstWiki.

protected boolean processNearstWiki() {
    if (showNearestWiki && latLon != null) {
        QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
        nearestWiki = app.getResourceManager().searchAmenities(new BinaryMapIndexReader.SearchPoiTypeFilter() {

            @Override
            public boolean accept(PoiCategory type, String subcategory) {
                return type.isWiki();
            }

            @Override
            public boolean isEmpty() {
                return false;
            }
        }, rect.top, rect.left, rect.bottom, rect.right, -1, null);
        Collections.sort(nearestWiki, new Comparator<Amenity>() {

            @Override
            public int compare(Amenity o1, Amenity o2) {
                double d1 = MapUtils.getDistance(latLon, o1.getLocation());
                double d2 = MapUtils.getDistance(latLon, o2.getLocation());
                return Double.compare(d1, d2);
            }
        });
        Long id = objectId;
        List<Amenity> wikiList = new ArrayList<>();
        for (Amenity wiki : nearestWiki) {
            String lng = wiki.getContentLanguage("content", preferredMapAppLang, "en");
            if (wiki.getId().equals(id) || (!lng.equals("en") && !lng.equals(preferredMapAppLang))) {
                wikiList.add(wiki);
            }
        }
        nearestWiki.removeAll(wikiList);
        return true;
    }
    return false;
}
Also used : Amenity(net.osmand.data.Amenity) PoiCategory(net.osmand.osm.PoiCategory) ArrayList(java.util.ArrayList) QuadRect(net.osmand.data.QuadRect)

Example 19 with QuadRect

use of net.osmand.data.QuadRect in project Osmand by osmandapp.

the class FavouritePointMenuBuilder method findTransportStop.

private TransportStop findTransportStop(String nameStringEn, double lat, double lon) {
    QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 15);
    List<TransportStop> res = app.getResourceManager().searchTransportSync(rect.top, rect.left, rect.bottom, rect.right, new ResultMatcher<TransportStop>() {

        @Override
        public boolean publish(TransportStop object) {
            return true;
        }

        @Override
        public boolean isCancelled() {
            return false;
        }
    });
    for (TransportStop stop : res) {
        String stringEn = stop.toStringEn();
        if (stringEn.equals(nameStringEn)) {
            return stop;
        }
    }
    return null;
}
Also used : TransportStop(net.osmand.data.TransportStop) QuadRect(net.osmand.data.QuadRect)

Example 20 with QuadRect

use of net.osmand.data.QuadRect in project Osmand by osmandapp.

the class AmenityMenuController method processTransportStop.

private void processTransportStop() {
    routes = new ArrayList<>();
    List<TransportIndexRepository> reps = getMapActivity().getMyApplication().getResourceManager().searchTransportRepositories(amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude());
    boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
    boolean isSubwayEntrance = amenity.getSubType().equals("subway_entrance");
    for (TransportIndexRepository t : reps) {
        ArrayList<TransportStop> ls = new ArrayList<>();
        QuadRect ll = MapUtils.calculateLatLonBbox(amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), isSubwayEntrance ? 400 : 150);
        t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
        for (TransportStop tstop : ls) {
            addRoutes(useEnglishNames, t, tstop, (int) MapUtils.getDistance(tstop.getLocation(), amenity.getLocation()), isSubwayEntrance);
        }
    }
    Collections.sort(routes, new Comparator<TransportStopRoute>() {

        @Override
        public int compare(TransportStopRoute o1, TransportStopRoute o2) {
            if (o1.distance != o2.distance) {
                return Algorithms.compare(o1.distance, o2.distance);
            }
            int i1 = Algorithms.extractFirstIntegerNumber(o1.desc);
            int i2 = Algorithms.extractFirstIntegerNumber(o2.desc);
            if (i1 != i2) {
                return Algorithms.compare(i1, i2);
            }
            return o1.desc.compareTo(o2.desc);
        }
    });
    builder.setRoutes(routes);
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) ArrayList(java.util.ArrayList) TransportIndexRepository(net.osmand.plus.resources.TransportIndexRepository) TransportStop(net.osmand.data.TransportStop) QuadRect(net.osmand.data.QuadRect)

Aggregations

QuadRect (net.osmand.data.QuadRect)60 Paint (android.graphics.Paint)19 ArrayList (java.util.ArrayList)19 LatLon (net.osmand.data.LatLon)13 Bitmap (android.graphics.Bitmap)8 RotatedTileBox (net.osmand.data.RotatedTileBox)8 WptPt (net.osmand.plus.GPXUtilities.WptPt)8 TIntArrayList (gnu.trove.list.array.TIntArrayList)7 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)6 Amenity (net.osmand.data.Amenity)5 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)4 Point (com.vividsolutions.jts.geom.Point)4 List (java.util.List)4 QuadPointDouble (net.osmand.data.QuadPointDouble)4 TransportStop (net.osmand.data.TransportStop)4 PoiCategory (net.osmand.osm.PoiCategory)4 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)4 Rect (android.graphics.Rect)3 RectF (android.graphics.RectF)3 File (java.io.File)3