Search in sources :

Example 11 with RouteDataObject

use of net.osmand.binary.RouteDataObject in project Osmand by osmandapp.

the class VoiceRouter method getSpeakableStreetName.

public Term getSpeakableStreetName(RouteSegmentResult currentSegment, RouteDirectionInfo i, boolean includeDest) {
    if (i == null || !router.getSettings().SPEAK_STREET_NAMES.get()) {
        return empty;
    }
    if (player != null && player.supportsStructuredStreetNames()) {
        Term next = empty;
        // Issue 2377: Play Dest here only if not already previously announced, to avoid repetition
        if (includeDest == true) {
            next = new Struct(new Term[] { getTermString(getSpeakablePointName(i.getRef())), getTermString(getSpeakablePointName(i.getStreetName())), getTermString(getSpeakablePointName(i.getDestinationName())) });
        } else {
            next = new Struct(new Term[] { getTermString(getSpeakablePointName(i.getRef())), getTermString(getSpeakablePointName(i.getStreetName())), empty });
        }
        Term current = empty;
        if (currentSegment != null) {
            // Issue 2377: Play Dest here only if not already previously announced, to avoid repetition
            if (includeDest == true) {
                RouteDataObject obj = currentSegment.getObject();
                current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), currentSegment.isForwardDirection()))), getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()))), getTermString(getSpeakablePointName(obj.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), currentSegment.isForwardDirection()))) });
            } else {
                RouteDataObject obj = currentSegment.getObject();
                current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), currentSegment.isForwardDirection()))), getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()))), empty });
            }
        }
        Struct voice = new Struct("voice", next, current);
        return voice;
    } else {
        Term rf = getTermString(getSpeakablePointName(i.getRef()));
        if (rf == empty) {
            rf = getTermString(getSpeakablePointName(i.getStreetName()));
        }
        return rf;
    }
}
Also used : RouteDataObject(net.osmand.binary.RouteDataObject) Term(alice.tuprolog.Term) Struct(alice.tuprolog.Struct)

Example 12 with RouteDataObject

use of net.osmand.binary.RouteDataObject in project Osmand by osmandapp.

the class ImpassableRoadsLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (contextMenuLayer.getMoveableObject() instanceof RouteDataObject) {
        PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
        drawPoint(canvas, pf.x, pf.y);
    }
}
Also used : PointF(android.graphics.PointF) RouteDataObject(net.osmand.binary.RouteDataObject)

Example 13 with RouteDataObject

use of net.osmand.binary.RouteDataObject in project Osmand by osmandapp.

the class ImpassableRoadsLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (tileBox.getZoom() >= startZoom) {
        for (long id : getImpassableRoadLocations().keySet()) {
            if (contextMenuLayer.getMoveableObject() instanceof RouteDataObject) {
                RouteDataObject object = (RouteDataObject) contextMenuLayer.getMoveableObject();
                if (object.id == id) {
                    continue;
                }
            }
            Location location = getImpassableRoadLocations().get(id);
            final double latitude = location.getLatitude();
            final double longitude = location.getLongitude();
            if (tileBox.containsLatLon(latitude, longitude)) {
                drawPoint(canvas, tileBox, latitude, longitude);
            }
        }
        for (StoredRoadDataObject storedRoadDataObject : storedRoadDataObjects) {
            final LatLon latLon = storedRoadDataObject.getLatLon();
            if (tileBox.containsLatLon(latLon)) {
                drawPoint(canvas, tileBox, latLon.getLatitude(), latLon.getLongitude());
            }
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) RouteDataObject(net.osmand.binary.RouteDataObject) Location(net.osmand.Location)

Example 14 with RouteDataObject

use of net.osmand.binary.RouteDataObject in project Osmand by osmandapp.

the class GeocodingLookupService method geocode.

private boolean geocode(final LatLon latLon) {
    Location loc = new Location("");
    loc.setLatitude(latLon.getLatitude());
    loc.setLongitude(latLon.getLongitude());
    return app.getLocationProvider().getGeocodingResult(loc, new ResultMatcher<GeocodingResult>() {

        @Override
        public boolean publish(GeocodingResult object) {
            String result = null;
            if (object != null) {
                String lang = SampleApplication.LANGUAGE;
                boolean transliterate = SampleApplication.TRANSLITERATE;
                String geocodingResult = "";
                double relevantDistance = -1;
                if (object.building != null) {
                    String bldName = object.building.getName(lang, transliterate);
                    if (!Algorithms.isEmpty(object.buildingInterpolation)) {
                        bldName = object.buildingInterpolation;
                    }
                    geocodingResult = object.street.getName(lang, transliterate) + " " + bldName + ", " + object.city.getName(lang, transliterate);
                } else if (object.street != null) {
                    geocodingResult = object.street.getName(lang, transliterate) + ", " + object.city.getName(lang, transliterate);
                    relevantDistance = object.getDistanceP();
                } else if (object.city != null) {
                    geocodingResult = object.city.getName(lang, transliterate);
                } else if (object.point != null) {
                    RouteDataObject rd = object.point.getRoad();
                    String sname = rd.getName(lang, transliterate);
                    if (Algorithms.isEmpty(sname)) {
                        sname = "";
                    }
                    String ref = rd.getRef(lang, transliterate, true);
                    if (!Algorithms.isEmpty(ref)) {
                        if (!Algorithms.isEmpty(sname)) {
                            sname += ", ";
                        }
                        sname += ref;
                    }
                    geocodingResult = sname;
                    relevantDistance = object.getDistanceP();
                }
                result = geocodingResult;
                if (relevantDistance == -1) {
                    relevantDistance = object.getDistance();
                }
                if (!Algorithms.isEmpty(result) && relevantDistance > 100) {
                    result = app.getString("shared_string_near") + " " + result;
                }
            }
            lastFoundAddress = result;
            searchDone = true;
            return true;
        }

        @Override
        public boolean isCancelled() {
            return !hasAnyRequest(latLon);
        }
    });
}
Also used : GeocodingResult(net.osmand.binary.GeocodingUtilities.GeocodingResult) RouteDataObject(net.osmand.binary.RouteDataObject) Location(net.osmand.Location)

Example 15 with RouteDataObject

use of net.osmand.binary.RouteDataObject in project Osmand by osmandapp.

the class MenuController method getMenuController.

public static MenuController getMenuController(MapActivity mapActivity, LatLon latLon, PointDescription pointDescription, Object object, MenuType menuType) {
    MenuController menuController = null;
    if (object != null) {
        if (object instanceof Amenity) {
            menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
        } else if (object instanceof FavouritePoint) {
            menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
        } else if (object instanceof SearchHistoryHelper.HistoryEntry) {
            menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
        } else if (object instanceof TargetPoint) {
            menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
        } else if (object instanceof Recording) {
            menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
        } else if (object instanceof OsmPoint) {
            menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
        } else if (object instanceof WptPt) {
            menuController = new WptPtMenuController(mapActivity, pointDescription, (WptPt) object);
        } else if (object instanceof DownloadMapObject) {
            menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
        } else if (object instanceof OpenStreetNote) {
            menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
        } else if (object instanceof GpxDisplayItem) {
            menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
        } else if (object instanceof MapMarker) {
            menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
        } else if (object instanceof TransportStopRoute) {
            menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
        } else if (object instanceof TransportStop) {
            menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
        } else if (object instanceof AMapPoint) {
            menuController = new AMapPointMenuController(mapActivity, pointDescription, (AMapPoint) object);
        } else if (object instanceof LatLon) {
            if (pointDescription.isParking()) {
                menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
            } else if (pointDescription.isMyLocation()) {
                menuController = new MyLocationMenuController(mapActivity, pointDescription);
            }
        } else if (object instanceof RouteDataObject) {
            menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
        } else if (object instanceof RenderedObject) {
            menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
        } else if (object instanceof MapillaryImage) {
            menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
        }
    }
    if (menuController == null) {
        menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
    }
    menuController.menuType = menuType;
    menuController.setLatLon(latLon);
    menuController.onCreated();
    return menuController;
}
Also used : TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) WptPt(net.osmand.plus.GPXUtilities.WptPt) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) TransportStopController(net.osmand.plus.mapcontextmenu.controllers.TransportStopController) FavouritePoint(net.osmand.data.FavouritePoint) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) MapillaryImage(net.osmand.plus.mapillary.MapillaryImage) ParkingPositionMenuController(net.osmand.plus.parkingpoint.ParkingPositionMenuController) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.osmedit.EditPOIMenuController) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) TransportStop(net.osmand.data.TransportStop) Amenity(net.osmand.data.Amenity) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) AudioVideoNoteMenuController(net.osmand.plus.audionotes.AudioVideoNoteMenuController) OsmBugMenuController(net.osmand.plus.osmedit.OsmBugMenuController) OsmPoint(net.osmand.plus.osmedit.OsmPoint) TransportRouteController(net.osmand.plus.mapcontextmenu.controllers.TransportRouteController) AMapPoint(net.osmand.aidl.maplayer.point.AMapPoint) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) DownloadMapObject(net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) OsmBugMenuController(net.osmand.plus.osmedit.OsmBugMenuController) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.mapillary.MapillaryMenuController) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) ParkingPositionMenuController(net.osmand.plus.parkingpoint.ParkingPositionMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) AudioVideoNoteMenuController(net.osmand.plus.audionotes.AudioVideoNoteMenuController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.osmedit.EditPOIMenuController) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) LatLon(net.osmand.data.LatLon) RenderedObject(net.osmand.NativeLibrary.RenderedObject) OpenStreetNote(net.osmand.plus.osmedit.OsmBugsLayer.OpenStreetNote) RouteDataObject(net.osmand.binary.RouteDataObject) Recording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.mapillary.MapillaryMenuController)

Aggregations

RouteDataObject (net.osmand.binary.RouteDataObject)49 ArrayList (java.util.ArrayList)13 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)9 Location (net.osmand.Location)9 RouteSegment (net.osmand.router.BinaryRoutePlanner.RouteSegment)8 TLongHashSet (gnu.trove.set.hash.TLongHashSet)7 LatLon (net.osmand.data.LatLon)6 IOException (java.io.IOException)5 RouteSubregion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion)4 QuadPoint (net.osmand.data.QuadPoint)4 File (java.io.File)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)3 RouteRegion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion)3 RoutePlannerFrontEnd (net.osmand.router.RoutePlannerFrontEnd)3 RoutingConfiguration (net.osmand.router.RoutingConfiguration)3 RoutingContext (net.osmand.router.RoutingContext)3 TLongArrayList (gnu.trove.list.array.TLongArrayList)2 Point (java.awt.Point)2