### Question:
TileSetCoordinateSpace { public TileCoordinate tileCoordinateContaining(Point<C2D> point, boolean lowerLeftInclusive) { if (!this.extent.contains(point.getPosition())) throw new IllegalArgumentException(String.format("Point %s outside the extent of this TileSet", point.toString())); C2D relativeToOrigin = relativeToOrigin(point); double x = relativeToOrigin.getX(); double y = relativeToOrigin.getY(); double width = tileWidthInMapUnits(); double height = tileHeightInMapUnits(); double approxI = removeRoundingError(x / width); double approxJ = removeRoundingError(y / height); int i = (int) approxI; int j = (int) approxJ; if (!lowerLeftInclusive && i == approxI) i -= 1; if (!lowerLeftInclusive && j == approxJ) j -= 1; return new TileCoordinate(i, j); } TileSetCoordinateSpace(Point<C2D> origin, Dimension tileDimension, Envelope<C2D> extent, double unitsPerPixel); Envelope<C2D> boundingBox(TileCoordinate coordinate); PixelRange tilePixelRange(TileCoordinate coordinate); Dimension tileSetPixelDimension(); double tileWidthInMapUnits(); double tileHeightInMapUnits(); TileCoordinate tileCoordinateContaining(Point<C2D> point, boolean lowerLeftInclusive); double unitsPerPixel(); PixelRange pixelRange(Envelope<C2D> bbox); Pixel toPixel(Point<C2D> point); Point<C2D> toPoint(Pixel pixel);  }### Answer:
@Test public void test_point_to_tile_coordinate() { TileCoordinate received = space1.tileCoordinateContaining(point(crs, c(500, 500)), true); assertEquals(TileCoordinate.valueOf(0, 0), received); received = space1.tileCoordinateContaining(point(crs, c(50, 50)), true); assertEquals(TileCoordinate.valueOf(-9, -9), received); received = space1.tileCoordinateContaining(point(crs, c(610, 575)), true); assertEquals(TileCoordinate.valueOf(2, 1), received); received = space1.tileCoordinateContaining(point(crs, c(550, 550)), false); assertEquals(TileCoordinate.valueOf(0, 0), received); received = space1.tileCoordinateContaining(point(crs, c(550, 550)), true); assertEquals(TileCoordinate.valueOf(1, 1), received); try { space2.tileCoordinateContaining(point(crs, c(220, 220)), true); fail(); } catch (IllegalArgumentException e) { } }