public long indexOf(double x, double y)
    {
        if (!rectangle.contains(x, y)) {
            // Put things outside the box at the end
            // This will also handle infinities and NaNs
            return Long.MAX_VALUE;
        }

        int xInt = (int) (xScale * (x - rectangle.getXMin()));
        int yInt = (int) (yScale * (y - rectangle.getYMin()));
        return discreteIndexOf(xInt, yInt);
    }
@Test
    public void testDegenerateRectangle()
    {
        HilbertIndex hilbert = new HilbertIndex(new Rectangle(0, 0, 0, 0));
        assertEquals(hilbert.indexOf(0., 0.), 0);
        assertEquals(hilbert.indexOf(2., 2.), Long.MAX_VALUE);
    }