@Test
    public void touchPolygon() {
        //directly on line
        assertThat(polygon(GP_1, 0, false, 0, 1000, 1000, 0).touches(GP_1, TO_LATLON_E6)).isTrue();
        assertThat(polygon(GP_1, 0, false, 0, 1000, 1000, 0).touches(addE6(GP_1, 0, 10), TO_LATLON_E6)).isTrue();

        //within "half linewidth" distance of line
        final int minLineWidth  = GeoItemUtils.getMinPixelTouchWidth();
        assertThat(polygon(GP_1, 0, false, 0, 1000, 1000, -1000).touches(addE6(GP_1, minLineWidth / 2, 10), TO_LATLON_E6)).isTrue();
        assertThat(polygon(GP_1, 0, false, 0, 1000, 1000, -1000).touches(addE6(GP_1, minLineWidth / 2 + 10, minLineWidth / 2 + 10), TO_LATLON_E6)).isFalse();

        //inside
        assertThat(polygon(GP_1, 0, false, 0, 1000, 1000, -1000).touches(addE6(GP_1, 250, 250), TO_LATLON_E6)).isFalse();
        assertThat(polygon(GP_1, 0, true, 0, 1000, 1000, -1000).touches(addE6(GP_1, 250, 250), TO_LATLON_E6)).isTrue();
        assertThat(polygon(GP_1, 0, true, 0, 1000, 1000, -1000).touches(addE6(GP_1, 1000, 1000), TO_LATLON_E6)).isFalse();

        //inside a hole
        final GeoPrimitive pWithHole = polygon(GP_1, 0, true, 0, 1000, 1000, 0, 0, -1000)
                .buildUpon().addHole(geopointList(GP_1, 0, 800, 800, -800)).build();
        assertThat(pWithHole.touches(addE6(GP_1, 200, 200), TO_LATLON_E6)).as("inside the hole").isFalse();
        assertThat(pWithHole.touches(addE6(GP_1, 900, 900), TO_LATLON_E6)).as("inside polygon but outside the hole").isTrue();

    }
A fake bitmap provider used for testing touching routines
main/src/test/java/cgeo/geocaching/models/geoitem/GeoItemTest.java