@Test public void scheduleTest() { for (int tileSize : TILE_SIZES) { Tile tile0 = new Tile(0, 0, (byte) 0); Job job = new Job(tile0, tileSize, false); QueueItem<Job> queueItem = new QueueItem<Job>(job); Assert.assertEquals(0, queueItem.getPriority(), 0); MapPosition mapPosition = new MapPosition(new LatLong(0, 0), (byte) 0); QueueItemScheduler.schedule(createCollection(queueItem), mapPosition, tileSize); Assert.assertEquals(0, queueItem.getPriority(), 0); mapPosition = new MapPosition(new LatLong(0, 180), (byte) 0); QueueItemScheduler.schedule(createCollection(queueItem), mapPosition, tileSize); int halfTileSize = tileSize / 2; Assert.assertEquals(halfTileSize, queueItem.getPriority(), 0); mapPosition = new MapPosition(new LatLong(0, -180), (byte) 0); QueueItemScheduler.schedule(createCollection(queueItem), mapPosition, tileSize); Assert.assertEquals(halfTileSize, queueItem.getPriority(), 0); mapPosition = new MapPosition(new LatLong(0, 0), (byte) 1); QueueItemScheduler.schedule(createCollection(queueItem), mapPosition, tileSize); double expectedPriority = Math.hypot(halfTileSize, halfTileSize) + QueueItemScheduler.PENALTY_PER_ZOOM_LEVEL * tileSize; Assert.assertEquals(expectedPriority, queueItem.getPriority(), 0); } }
static <T extends Job> void schedule(Collection<QueueItem<T>> queueItems, MapPosition mapPosition, int tileSize) { for (QueueItem<T> queueItem : queueItems) { queueItem.setPriority(calculatePriority(queueItem.object.tile, mapPosition, tileSize)); } }
QueueItemScheduler { static <T extends Job> void schedule(Collection<QueueItem<T>> queueItems, MapPosition mapPosition, int tileSize) { for (QueueItem<T> queueItem : queueItems) { queueItem.setPriority(calculatePriority(queueItem.object.tile, mapPosition, tileSize)); } } }
QueueItemScheduler { static <T extends Job> void schedule(Collection<QueueItem<T>> queueItems, MapPosition mapPosition, int tileSize) { for (QueueItem<T> queueItem : queueItems) { queueItem.setPriority(calculatePriority(queueItem.object.tile, mapPosition, tileSize)); } } private  QueueItemScheduler(); }
QueueItemScheduler { static <T extends Job> void schedule(Collection<QueueItem<T>> queueItems, MapPosition mapPosition, int tileSize) { for (QueueItem<T> queueItem : queueItems) { queueItem.setPriority(calculatePriority(queueItem.object.tile, mapPosition, tileSize)); } } private  QueueItemScheduler();  }
QueueItemScheduler { static <T extends Job> void schedule(Collection<QueueItem<T>> queueItems, MapPosition mapPosition, int tileSize) { for (QueueItem<T> queueItem : queueItems) { queueItem.setPriority(calculatePriority(queueItem.object.tile, mapPosition, tileSize)); } } private  QueueItemScheduler();   }