Esempio n. 1
0
 public Drawable getDrawable(Context uiCtx, OsmandApplication app) {
   if (type == POI) {
     Amenity amenity = ((AmenityLocationPoint) point).a;
     PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
     if (st != null) {
       if (RenderingIcons.containsBigIcon(st.getIconKeyName())) {
         return uiCtx
             .getResources()
             .getDrawable(RenderingIcons.getBigIconResourceId(st.getIconKeyName()));
       } else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
         return uiCtx
             .getResources()
             .getDrawable(
                 RenderingIcons.getBigIconResourceId(st.getOsmTag() + "_" + st.getOsmValue()));
       }
     }
     return null;
   } else if (type == TARGETS) {
     int i =
         !((TargetPoint) point).intermediate
             ? R.drawable.list_destination
             : R.drawable.list_intermediate;
     return uiCtx.getResources().getDrawable(i);
   } else if (type == FAVORITES || type == WAYPOINTS) {
     return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false);
   } else if (type == ALARMS) {
     // assign alarm list icons manually for now
     if (((AlarmInfo) point).getType().toString() == "SPEED_CAMERA") {
       return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera);
     } else if (((AlarmInfo) point).getType().toString() == "BORDER_CONTROL") {
       return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control);
     } else if (((AlarmInfo) point).getType().toString() == "RAILWAY") {
       if (app.getSettings().DRIVING_REGION.get().americanSigns) {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
       } else {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways);
       }
     } else if (((AlarmInfo) point).getType().toString() == "TRAFFIC_CALMING") {
       if (app.getSettings().DRIVING_REGION.get().americanSigns) {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
       } else {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming);
       }
     } else if (((AlarmInfo) point).getType().toString() == "TOLL_BOOTH") {
       return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth);
     } else if (((AlarmInfo) point).getType().toString() == "STOP") {
       return uiCtx.getResources().getDrawable(R.drawable.list_stop);
     } else if (((AlarmInfo) point).getType().toString() == "PEDESTRIAN") {
       if (app.getSettings().DRIVING_REGION.get().americanSigns) {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
       } else {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian);
       }
     } else {
       return null;
     }
   } else {
     return null;
   }
 }
Esempio n. 2
0
 private float dist(LocationPoint l, List<Location> locations, int[] ind) {
   float dist = Float.POSITIVE_INFINITY;
   // Special iterations because points stored by pairs!
   for (int i = 1; i < locations.size(); i++) {
     final double ld =
         MapUtils.getOrthogonalDistance(
             l.getLatitude(), l.getLongitude(),
             locations.get(i - 1).getLatitude(), locations.get(i - 1).getLongitude(),
             locations.get(i).getLatitude(), locations.get(i).getLongitude());
     if (ld < dist) {
       if (ind != null) {
         ind[0] = i;
       }
       dist = (float) ld;
     }
   }
   return dist;
 }
Esempio n. 3
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   LocationPointWrapper other = (LocationPointWrapper) obj;
   if (point == null) {
     if (other.point != null) return false;
   } else if (!point.equals(other.point)) return false;
   return true;
 }
Esempio n. 4
0
 @Override
 public int hashCode() {
   return ((point == null) ? 0 : point.hashCode());
 }
Esempio n. 5
0
 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);
           }
         }
       }
     }
   }
 }