public boolean overlaps(final BoundingBox pBoundingBox, double pZoom) {

        //FIXME this is a total hack but it works around a number of issues related to vertical map
        //replication and horiztonal replication that can cause polygons to completely disappear when
        //panning
        if (pZoom < 3)
            return true;

        boolean latMatch = false;
        boolean lonMatch = false;

        //vertical wrapping detection
        if (pBoundingBox.mLatSouth <= mLatNorth &&
                pBoundingBox.mLatSouth >= mLatSouth)
            latMatch = true;


        //normal case, non overlapping
        if (mLonWest >= pBoundingBox.mLonWest && mLonWest <= pBoundingBox.mLonEast)
            lonMatch = true;
        //normal case, non overlapping
        if (mLonEast >= pBoundingBox.mLonWest && mLonWest <= pBoundingBox.mLonEast)
            lonMatch = true;

        //special case for when *this completely surrounds the pBoundbox
        if (mLonWest <= pBoundingBox.mLonWest &&
                mLonEast >= pBoundingBox.mLonEast &&
                mLatNorth >= pBoundingBox.mLatNorth &&
                mLatSouth <= pBoundingBox.mLatSouth)
            return true;

        //normal case, non overlapping
        if (mLatNorth >= pBoundingBox.mLatSouth && mLatNorth <= mLatSouth)
            latMatch = true;
        //normal case, non overlapping
        if (mLatSouth >= pBoundingBox.mLatSouth && mLatSouth <= mLatSouth)
            latMatch = true;

        if (mLonWest > mLonEast) {
            //the date line is included in the bounding box

            //we want to match lon from the dateline to the eastern bounds of the box
            //and the dateline to the western bounds of the box

            if (mLonEast <= pBoundingBox.mLonEast && pBoundingBox.mLonWest >= mLonWest)
                lonMatch = true;


            if (mLonWest >= pBoundingBox.mLonEast &&
                    mLonEast <= pBoundingBox.mLonEast) {
                lonMatch = true;
                if (pBoundingBox.mLonEast < mLonWest &&
                        pBoundingBox.mLonWest < mLonWest)
                    lonMatch = false;

                if (pBoundingBox.mLonEast > mLonEast &&
                        pBoundingBox.mLonWest > mLonEast)
                    lonMatch = false;
            }
            if (mLonWest >= pBoundingBox.mLonEast &&
                    mLonEast >= pBoundingBox.mLonEast) {
                lonMatch = true;

            }
			/*
			//that is completely within this
			if (mLonWest>= pBoundingBox.mLonEast &&
				mLonEast<= pBoundingBox.mLonEast) {
				lonMatch = true;
				if (pBoundingBox.mLonEast < mLonWest &&
					pBoundingBox.mLonWest < mLonWest)
					lonMatch = false;

				if (pBoundingBox.mLonEast > mLonEast &&
					pBoundingBox.mLonWest > mLonEast )
					lonMatch = false;
			}
			if (mLonWest>= pBoundingBox.mLonEast &&
				mLonEast>= pBoundingBox.mLonEast) {
				lonMatch = true;

			}*/
        }

        return latMatch && lonMatch;
    }
@Test
    public void testOverlapsDateLine2() {

        //  ________________
        //  |      |       |
        //  |** ?? |     **|
        //  |-*----+-----*-|
        //  |**    |     **|
        //  |      |       |
        //  ----------------
        //box is notated as *
        //test area is notated as ?


        BoundingBox box = new BoundingBox(45, -178, -45, -1);
        Assert.assertTrue(box.overlaps(box, 4));

        BoundingBox farAway = new BoundingBox(45, -74, 44, -72);
        Assert.assertFalse(box.overlaps(farAway, 4));


        //  ________________
        //  |******|     **|
        //  |  ?? *|     * |
        //  |-----*+-----*-|
        //  |     *|     * |
        //  |******|     **|
        //  ----------------
        //box is notated as *
        //test area is notated as ?


        box = new BoundingBox(45, 0, -45, 170);
        Assert.assertTrue(box.overlaps(box, 4));

        farAway = new BoundingBox(40, -72, 38, -74);
        Assert.assertTrue(box.overlaps(farAway, 4));

        farAway = new BoundingBox(40, 5, 38, 4);
        Assert.assertFalse(box.overlaps(farAway, 4));

        farAway = new BoundingBox(-40, 5, -42, 4);
        Assert.assertFalse(box.overlaps(farAway, 4));


    }