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;
}
}
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);
}
}
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());
}
}
}
}
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);
}
});
}
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;
}
Aggregations