Package org.geotools.grid

Examples of org.geotools.grid.PolygonElement


        PolygonElement oblong = new OblongImpl(0, 0, -1, HEIGHT, null);
    }

    @Test(expected=IllegalArgumentException.class)
    public void zeroWidth() {
        PolygonElement oblong = new OblongImpl(0, 0, 0, HEIGHT, null);
    }
View Full Code Here


        PolygonElement oblong = new OblongImpl(0, 0, 0, HEIGHT, null);
    }

    @Test(expected=IllegalArgumentException.class)
    public void negativeHeight() {
        PolygonElement oblong = new OblongImpl(0, 0, WIDTH, -1, null);
    }
View Full Code Here

        assertEnvelope(expected, result);
    }

    @Test
    public void getBoundsAngled() {
        PolygonElement hexagon = new HexagonImpl(0.0, 0.0, SIDE_LEN, HexagonOrientation.ANGLED, null);

        Envelope expected = new Envelope(
                0.0,
                Math.sqrt(3.0) * SIDE_LEN,
                0.0,
                2.0 * SIDE_LEN);

        Envelope result = hexagon.getBounds();

        assertEnvelope(expected, result);
    }
View Full Code Here

        PolygonElement oblong = new OblongImpl(0, 0, WIDTH, -1, null);
    }

    @Test(expected=IllegalArgumentException.class)
    public void zeroHeight() {
        PolygonElement oblong = new OblongImpl(0, 0, WIDTH, 0, null);
    }
View Full Code Here

        assertEnvelope(expected, result);
    }

    @Test
    public void toGeometry() {
        PolygonElement hexagon = new HexagonImpl(0.0, 0.0, SIDE_LEN, HexagonOrientation.FLAT, null);
        Geometry polygon = hexagon.toGeometry();
        assertNotNull(polygon);
        assertTrue(polygon instanceof Polygon);

        Set<Coordinate> polyCoords = new HashSet<Coordinate>(Arrays.asList(polygon.getCoordinates()));
        for (Coordinate c : hexagon.getVertices()) {
            assertTrue(polyCoords.contains(c));
        }
    }
View Full Code Here

        PolygonElement oblong = new OblongImpl(0, 0, WIDTH, 0, null);
    }

    @Test
    public void getArea() {
        PolygonElement oblong = new OblongImpl(MINX, MINY, WIDTH, HEIGHT, null);
        double expected = WIDTH * HEIGHT;
        assertEquals(expected, oblong.getArea(), TOL);
    }
View Full Code Here

        }
    }

    @Test
    public void toDenseGeometry() {
        PolygonElement hexagon = new HexagonImpl(0.0, 0.0, SIDE_LEN, HexagonOrientation.FLAT, null);

        final int density = 10;
        final double maxSpacing = SIDE_LEN / density;

        Geometry polygon = hexagon.toDenseGeometry(maxSpacing);
        assertNotNull(polygon);
        assertTrue(polygon instanceof Polygon);
        assertTrue(polygon.getCoordinates().length - 1 >= 6 * density);
    }
View Full Code Here

        assertEquals(expected, oblong.getArea(), TOL);
    }

    @Test
    public void getBounds() {
        PolygonElement oblong = new OblongImpl(MINX, MINY, WIDTH, HEIGHT, null);
        assertEnvelope(new Envelope(-10, WIDTH - 10, -5, HEIGHT - 5), oblong.getBounds());
    }
View Full Code Here

        assertEnvelope(new Envelope(-10, WIDTH - 10, -5, HEIGHT - 5), oblong.getBounds());
    }

    @Test
    public void getCenter() {
        PolygonElement oblong = new OblongImpl(MINX, MINY, WIDTH, HEIGHT, null);
        Coordinate expected = new Coordinate(WIDTH/2 + MINX, HEIGHT/2 + MINY);
        assertCoordinate(expected, oblong.getCenter());
    }
View Full Code Here

        assertCoordinate(expected, oblong.getCenter());
    }

    @Test
    public void getVertices() {
        PolygonElement oblong = new OblongImpl(MINX, MINY, WIDTH, HEIGHT, null);
        Coordinate[] expected = {
            new Coordinate(MINX, MINY),
            new Coordinate(MINX, MINY + HEIGHT),
            new Coordinate(MINX + WIDTH, MINY + HEIGHT),
            new Coordinate(MINX + WIDTH, MINY),
        };

        Coordinate[] actual = oblong.getVertices();
        assertEquals(expected.length, actual.length);
        for (int i = 0; i < expected.length; i++) {
            assertCoordinate(expected[i], actual[i]);
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.grid.PolygonElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.