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 testOrder()
    {
        HilbertIndex hilbert = new HilbertIndex(new Rectangle(0, 0, 4, 4));
        long h0 = hilbert.indexOf(0., 0.);
        long h1 = hilbert.indexOf(1., 1.);
        long h2 = hilbert.indexOf(1., 3.);
        long h3 = hilbert.indexOf(3., 3.);
        long h4 = hilbert.indexOf(3., 1.);
        assertTrue(h0 < h1);
        assertTrue(h1 < h2);
        assertTrue(h2 < h3);
        assertTrue(h3 < h4);
    }