@Test
public void testGetNearestEnd() {

	assertNotNull(this.bounds);
	MapPolylineGridSet<MapPolyline> test = new MapPolylineGridSet<>(100,100,this.bounds);
       test.addAll(this.reference);
       assertEquals(this.reference.size(), test.size());
       Random rnd = new Random();
   	MapPolyline nearestData;
   	double minDistance, distance, x, y;
   	final ArrayList<MapPolyline> nearest = new ArrayList<>();
   	x = rnd.nextDouble()*this.bounds.getWidth()+this.bounds.getMinX();
   	y = rnd.nextDouble()*this.bounds.getHeight()+this.bounds.getMinY();
   	minDistance = Double.MAX_VALUE;
   	for (MapPolyline line : this.reference) {
   		distance = line.distanceToEnd(new Point2d(x, y));
   		if (distance<minDistance) {
   			minDistance = distance;
   			nearest.clear();
   			nearest.add(line);
   		}
   		else if (distance==minDistance) {
   			nearest.add(line);
   		}
   	}
   	nearestData = test.getNearestEnd(x, y);
   	assertNotNull(nearestData);
   	assertTrue(nearest.contains(nearestData));
}