예제 #1
0
 /**
  * Convenience method for {@link Graphs#findClosestObject}.
  *
  * @param pos The {@link Point} which is used as reference.
  * @param rm The {@link RoadModel} which is searched.
  * @param predicate A {@link Predicate} indicating which objects are included in the search.
  * @return The closest object in <code>rm</code> to <code>pos</code> which satisfies the <code>
  *     predicate</code>.
  * @see Graphs#findClosestObject
  */
 @Nullable
 public static RoadUser findClosestObject(Point pos, RoadModel rm, Predicate<RoadUser> predicate) {
   final Collection<RoadUser> filtered = Collections2.filter(rm.getObjects(), predicate);
   return findClosestObject(pos, rm, filtered);
 }
예제 #2
0
 /**
  * Convenience method for {@link Graphs#findClosestObject}.
  *
  * @param pos The {@link Point} which is used as reference.
  * @param rm The {@link RoadModel} which is searched.
  * @param type The type of object that is searched.
  * @param <T> The type of the returned object.
  * @return The closest object in <code>rm</code> to <code>pos</code> of type <code>type</code>.
  * @see Graphs#findClosestObject
  */
 @Nullable
 public static <T extends RoadUser> T findClosestObject(
     Point pos, RoadModel rm, final Class<T> type) {
   return findClosestObject(pos, rm, rm.getObjectsOfType(type));
 }
예제 #3
0
 @Override
 @Nullable
 public Point apply(@Nullable T input) {
   return rm.getPosition(verifyNotNull(input));
 }
예제 #4
0
 @Override
 public boolean apply(@Nullable RoadUser input) {
   return Point.distance(model.getPosition(verifyNotNull(input)), position) < radius;
 }
예제 #5
0
 /**
  * Returns all {@link RoadUser}s of type <code> type</code> in <code>model</code> that are
  * <strong>within</strong> a bird-flight distance of <code>radius</code> to <code>position</code>.
  *
  * @param position The position which is used to measure distance.
  * @param model The {@link RoadModel} which contains the objects.
  * @param radius Objects with a distance smaller than <code>radius</code> to <code>position</code>
  *     are included.
  * @param type The {@link Class} of the required type.
  * @param <T> The type of the objects in the returned collection.
  * @return A collection of type <code>type</code>.
  */
 public static <T extends RoadUser> Collection<T> findObjectsWithinRadius(
     final Point position, final RoadModel model, final double radius, final Class<T> type) {
   return RoadModels.findObjectsWithinRadius(
       position, model, radius, model.getObjectsOfType(type));
 }
예제 #6
0
 /**
  * Returns all {@link RoadUser}s in <code>model</code> that are <strong>within</strong> a
  * bird-flight distance of <code>radius</code> to <code>position</code>.
  *
  * @param position The position which is used to measure distance.
  * @param model The {@link RoadModel} which contains the objects.
  * @param radius Objects with a distance smaller than <code>radius</code> to <code>position</code>
  *     are included.
  * @return A collection of {@link RoadUser}s.
  */
 public static Collection<RoadUser> findObjectsWithinRadius(
     final Point position, final RoadModel model, final double radius) {
   return RoadModels.findObjectsWithinRadius(position, model, radius, model.getObjects());
 }
예제 #7
0
 /**
  * Searches the closest <code>n</code> objects to position <code>pos</code> in {@link RoadModel}
  * <code>rm</code>.
  *
  * @param pos The {@link Point} which is used as a reference point.
  * @param rm The {@link RoadModel} instance in which the closest objects are searched.
  * @param type The type of objects which are included in the search.
  * @param n The maximum number of objects to return where n must be &ge; 0.
  * @param <T> The type of the objects in the returned collection.
  * @return A list of objects that are closest to <code>pos</code>. The list is ordered such that
  *     the closest object appears first. An empty list is returned when <code>objects</code> is
  *     empty.
  */
 public static <T extends RoadUser> List<T> findClosestObjects(
     Point pos, RoadModel rm, Class<T> type, int n) {
   return RoadModels.findClosestObjects(pos, rm, rm.getObjectsOfType(type), n);
 }
예제 #8
0
 /**
  * Searches the closest <code>n</code> objects to position <code>pos</code> in {@link RoadModel}
  * <code>rm</code>. Only the objects that satisfy <code>predicate</code> are included in the
  * search.
  *
  * @param pos The {@link Point} which is used as a reference point.
  * @param rm The {@link RoadModel} instance in which the closest objects are searched.
  * @param predicate Only objects that satisfy this predicate will be returned.
  * @param n The maximum number of objects to return where n must be &ge; 0.
  * @return A list of objects that are closest to <code>pos</code>. The list is ordered such that
  *     the closest object appears first. An empty list is returned when <code>objects</code> is
  *     empty.
  */
 public static List<RoadUser> findClosestObjects(
     Point pos, RoadModel rm, Predicate<RoadUser> predicate, int n) {
   final Collection<RoadUser> filtered = Collections2.filter(rm.getObjects(), predicate);
   return RoadModels.findClosestObjects(pos, rm, filtered, n);
 }
예제 #9
0
 @Override
 public boolean apply(@Nullable RoadUser input) {
   return type.isInstance(input) && model.equalPosition(verifyNotNull(input), reference);
 }