Beispiel #1
0
 /**
  * Convenience method for {@link Graphs#findClosestObject(Point, Collection, Function)}.
  *
  * @param pos The {@link Point} which is used as reference.
  * @param rm The {@link RoadModel} which is searched.
  * @param objects The {@link Collection} which is searched, each object must exist in <code>rm
  *     </code>.
  * @param <T> The type of the returned object.
  * @return The closest object in <code>rm</code> to <code>pos</code> which satisfies the <code>
  *     predicate</code>.
  * @see Graphs#findClosestObject(Point, Collection, Function)
  */
 @Nullable
 public static <T extends RoadUser> T findClosestObject(
     Point pos, RoadModel rm, Collection<T> objects) {
   return Graphs.findClosestObject(pos, objects, new RoadModels.RoadUserToPositionFunction<T>(rm));
 }
Beispiel #2
0
 /**
  * Searches the closest <code>n</code> objects to position <code>pos</code> in collection <code>
  * objects</code>.
  *
  * @param pos The {@link Point} which is used as a reference point.
  * @param rm The {@link RoadModel} instance which is used to lookup the positions of the objects
  *     in <code>objects</code>.
  * @param objects The list of objects which is searched.
  * @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, Collection<T> objects, int n) {
   return Graphs.findClosestObjects(
       pos, objects, new RoadModels.RoadUserToPositionFunction<T>(rm), n);
 }