public void testTransformPolygon() {
LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(-10, -10), new Coordinate(10, 0),
new Coordinate(-10, 10), new Coordinate(-10, -10) });
LinearRing hole = factory.createLinearRing(new Coordinate[] { new Coordinate(-5, -5), new Coordinate(5, 0),
new Coordinate(-5, 5), new Coordinate(-5, -5) });
Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });
// World to screen:
Polygon result = (Polygon) viewPort.transform(polygon, RenderSpace.WORLD, RenderSpace.SCREEN);
Coordinate c = result.getExteriorRing().getCoordinates()[0];
Assert.assertEquals((MAP_WIDTH / 2) - (viewPort.getScale() * 10), c.getX(), DELTA);
Assert.assertEquals((MAP_HEIGHT / 2) + (viewPort.getScale() * 10), c.getY(), DELTA);
c = result.getExteriorRing().getCoordinates()[1];
Assert.assertEquals((MAP_WIDTH / 2) + (viewPort.getScale() * 10), c.getX(), DELTA);
Assert.assertEquals((MAP_HEIGHT / 2), c.getY(), DELTA);
c = result.getInteriorRingN(0).getCoordinates()[2];
Assert.assertEquals((MAP_WIDTH / 2) - (viewPort.getScale() * 5), c.getX(), DELTA);
Assert.assertEquals((MAP_HEIGHT / 2) - (viewPort.getScale() * 5), c.getY(), DELTA);
// Screen to world:
result = (Polygon) viewPort.transform(result, RenderSpace.SCREEN, RenderSpace.WORLD);
c = result.getExteriorRing().getCoordinates()[0];
Assert.assertEquals(-10.0, c.getX(), DELTA);
Assert.assertEquals(-10.0, c.getY(), DELTA);
c = result.getExteriorRing().getCoordinates()[1];
Assert.assertEquals(10, c.getX(), DELTA);
Assert.assertEquals(0, c.getY(), DELTA);
c = result.getInteriorRingN(0).getCoordinates()[2];
Assert.assertEquals(-5.0, c.getX(), DELTA);
Assert.assertEquals(5.0, c.getY(), DELTA);
}