class GridCreator implements Iterable<GridCell> {

    public GridCell getCell(GeoCoordinate coordinate) {
        Validate.notNull(coordinate, "coordinate must not be null");
        int xId = (int)((coordinate.getLongitude() + 180) / gridSize);
        int yId = (int)((coordinate.getLatitude() + 90) / gridSize);
        // edge cases, make sure the range stays in [0,numCellsX|Y[
        xId = Math.min(xId, getNumCellsX()-1);
        yId = Math.min(yId, getNumCellsY()-1);
        // plus zero to prevent "negative zero" returns
        double lat1 = Math.floor(coordinate.getLatitude() / gridSize) * gridSize + 0.;
        double lat2 = lat1 + gridSize;
        double lng1 = Math.floor(coordinate.getLongitude() / gridSize) * gridSize + 0.;
        double lng2 = lng1 + gridSize;
        return new GridCell(xId, yId, lat1, lat2, lng1, lng2, gridSize);
    }

    public  GridCreator(double gridSize);

}