コード例 #1
0
ファイル: WaypointHelper.java プロジェクト: AmZaf/Osmand
 private void findLocationPoints(
     RouteCalculationResult rt,
     int type,
     List<LocationPointWrapper> locationPoints,
     List<? extends LocationPoint> points,
     boolean announce) {
   List<Location> immutableAllLocations = rt.getImmutableAllLocations();
   int[] ind = new int[1];
   for (LocationPoint p : points) {
     float dist = dist(p, immutableAllLocations, ind);
     int rad = getSearchDeviationRadius(type);
     if (dist <= rad) {
       LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]);
       lpw.setAnnounce(announce);
       locationPoints.add(lpw);
     }
   }
 }
コード例 #2
0
ファイル: WaypointHelper.java プロジェクト: AmZaf/Osmand
 protected void calculatePoi(
     RouteCalculationResult route, List<LocationPointWrapper> locationPoints) {
   PoiUIFilter pf = getPoiFilter();
   if (pf != null) {
     final List<Location> locs = route.getImmutableAllLocations();
     List<Amenity> amenities = pf.searchAmenitiesOnThePath(locs, poiSearchDeviationRadius);
     for (Amenity a : amenities) {
       AmenityRoutePoint rp = a.getRoutePoint();
       int i = locs.indexOf(rp.pointA);
       if (i >= 0) {
         LocationPointWrapper lwp =
             new LocationPointWrapper(
                 route, POI, new AmenityLocationPoint(a), (float) rp.deviateDistance, i);
         lwp.setAnnounce(announcePOI());
         locationPoints.add(lwp);
       }
     }
   }
 }
コード例 #3
0
ファイル: WaypointHelper.java プロジェクト: AmZaf/Osmand
 private void calculateAlarms(RouteCalculationResult route, List<LocationPointWrapper> array) {
   for (AlarmInfo i : route.getAlarmInfo()) {
     if (i.getType() == AlarmInfoType.SPEED_CAMERA) {
       if (app.getSettings().SHOW_CAMERAS.get() || app.getSettings().SPEAK_SPEED_CAMERA.get()) {
         LocationPointWrapper lw =
             new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex());
         lw.setAnnounce(app.getSettings().SPEAK_SPEED_CAMERA.get());
         array.add(lw);
       }
     } else {
       if (app.getSettings().SHOW_TRAFFIC_WARNINGS.get()
           || app.getSettings().SPEAK_TRAFFIC_WARNINGS.get()) {
         LocationPointWrapper lw =
             new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex());
         lw.setAnnounce(app.getSettings().SPEAK_TRAFFIC_WARNINGS.get());
         array.add(lw);
       }
     }
   }
 }
コード例 #4
0
ファイル: WaypointHelper.java プロジェクト: AmZaf/Osmand
 public void announceVisibleLocations() {
   Location lastKnownLocation = app.getRoutingHelper().getLastProjection();
   if (lastKnownLocation != null && app.getRoutingHelper().isFollowingMode()) {
     for (int type = 0; type < locationPoints.size(); type++) {
       int currentRoute = route.getCurrentRoute();
       List<LocationPointWrapper> approachPoints = new ArrayList<LocationPointWrapper>();
       List<LocationPointWrapper> announcePoints = new ArrayList<LocationPointWrapper>();
       List<LocationPointWrapper> lp = locationPoints.get(type);
       if (lp != null) {
         int kIterator = pointsProgress.get(type);
         while (kIterator < lp.size() && lp.get(kIterator).routeIndex < currentRoute) {
           kIterator++;
         }
         pointsProgress.set(type, kIterator);
         while (kIterator < lp.size()) {
           LocationPointWrapper lwp = lp.get(kIterator);
           if (route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS * 2) {
             break;
           }
           LocationPoint point = lwp.point;
           double d1 =
               Math.max(
                   0.0,
                   MapUtils.getDistance(
                           lastKnownLocation.getLatitude(),
                           lastKnownLocation.getLongitude(),
                           point.getLatitude(),
                           point.getLongitude())
                       - lwp.getDeviationDistance());
           Integer state = locationPointsStates.get(point);
           if (state != null
               && state.intValue() == ANNOUNCED_ONCE
               && getVoiceRouter()
                   .isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS, 0f)) {
             locationPointsStates.put(point, ANNOUNCED_DONE);
             announcePoints.add(lwp);
           } else if (type != ALARMS
               && (state == null || state == NOT_ANNOUNCED)
               && getVoiceRouter()
                   .isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS, 0f)) {
             locationPointsStates.put(point, ANNOUNCED_ONCE);
             approachPoints.add(lwp);
           } else if (type == ALARMS
               && (state == null || state == NOT_ANNOUNCED)
               && getVoiceRouter()
                   .isDistanceLess(lastKnownLocation.getSpeed(), d1, ALARMS_ANNOUNCE_RADIUS, 0f)) {
             locationPointsStates.put(point, ANNOUNCED_ONCE);
             approachPoints.add(lwp);
           }
           kIterator++;
         }
         if (!announcePoints.isEmpty()) {
           if (announcePoints.size() > ANNOUNCE_POI_LIMIT) {
             announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT);
           }
           if (type == WAYPOINTS) {
             getVoiceRouter().announceWaypoint(announcePoints);
           } else if (type == POI) {
             getVoiceRouter().announcePoi(announcePoints);
           } else if (type == ALARMS) {
             // nothing to announce
           } else if (type == FAVORITES) {
             getVoiceRouter().announceFavorite(announcePoints);
           }
         }
         if (!approachPoints.isEmpty()) {
           if (approachPoints.size() > APPROACH_POI_LIMIT) {
             approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT);
           }
           if (type == WAYPOINTS) {
             getVoiceRouter().approachWaypoint(lastKnownLocation, approachPoints);
           } else if (type == POI) {
             getVoiceRouter().approachPoi(lastKnownLocation, approachPoints);
           } else if (type == ALARMS) {
             EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class);
             for (LocationPointWrapper pw : approachPoints) {
               ait.add(((AlarmInfo) pw.point).getType());
             }
             for (AlarmInfoType t : ait) {
               app.getRoutingHelper().getVoiceRouter().announceAlarm(t);
             }
           } else if (type == FAVORITES) {
             getVoiceRouter().approachFavorite(lastKnownLocation, approachPoints);
           }
         }
       }
     }
   }
 }