List<CoordinatePoint> points = PolylineEncoder.decode(polygon.getOuterRing());
points = shiftPoints(points);
assertEquals(8, points.size());
assertEqualsPoints(new CoordinatePoint(1.0, 2.0), points.get(0), DELTA);
assertEqualsPoints(new CoordinatePoint(2.0, 2.0), points.get(1), DELTA);
assertEqualsPoints(new CoordinatePoint(3.0, 2.0), points.get(2), DELTA);
assertEqualsPoints(new CoordinatePoint(3.0, 3.0), points.get(3), DELTA);
assertEqualsPoints(new CoordinatePoint(3.0, 4.0), points.get(4), DELTA);
assertEqualsPoints(new CoordinatePoint(2.0, 4.0), points.get(5), DELTA);
assertEqualsPoints(new CoordinatePoint(1.0, 4.0), points.get(6), DELTA);
assertEqualsPoints(new CoordinatePoint(1.0, 3.0), points.get(7), DELTA);
factory.addBounds(new CoordinateBounds(5.5, 4.5, 5.6, 4.6));
grid = factory.getGrid();
assertEquals(5, grid.size());
Collections.sort(grid, BOUNDS_COMPARATOR);
checkBounds(grid.get(0), new CoordinateBounds(1.0, 2.0, 2.0, 3.0), DELTA);
checkBounds(grid.get(1), new CoordinateBounds(1.0, 3.0, 2.0, 4.0), DELTA);
checkBounds(grid.get(2), new CoordinateBounds(2.0, 2.0, 3.0, 3.0), DELTA);
checkBounds(grid.get(3), new CoordinateBounds(2.0, 3.0, 3.0, 4.0), DELTA);
checkBounds(grid.get(4), new CoordinateBounds(5.0, 4.0, 6.0, 5.0), DELTA);
boundary = factory.getBoundary();
assertEquals(2, boundary.size());
Collections.sort(boundary, POLYGON_COMPARATOR);
polygon = boundary.get(0);
assertTrue(polygon.getInnerRings().isEmpty());
points = PolylineEncoder.decode(polygon.getOuterRing());
points = shiftPoints(points);
assertEquals(8, points.size());
assertEqualsPoints(new CoordinatePoint(1.0, 2.0), points.get(0), DELTA);
assertEqualsPoints(new CoordinatePoint(2.0, 2.0), points.get(1), DELTA);
assertEqualsPoints(new CoordinatePoint(3.0, 2.0), points.get(2), DELTA);
assertEqualsPoints(new CoordinatePoint(3.0, 3.0), points.get(3), DELTA);
assertEqualsPoints(new CoordinatePoint(3.0, 4.0), points.get(4), DELTA);
assertEqualsPoints(new CoordinatePoint(2.0, 4.0), points.get(5), DELTA);
assertEqualsPoints(new CoordinatePoint(1.0, 4.0), points.get(6), DELTA);
assertEqualsPoints(new CoordinatePoint(1.0, 3.0), points.get(7), DELTA);
polygon = boundary.get(1);
assertTrue(polygon.getInnerRings().isEmpty());
points = PolylineEncoder.decode(polygon.getOuterRing());
points = shiftPoints(points);
assertEquals(4, points.size());
assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
assertEqualsPoints(new CoordinatePoint(6.0, 4.0), points.get(1), DELTA);
assertEqualsPoints(new CoordinatePoint(6.0, 5.0), points.get(2), DELTA);
assertEqualsPoints(new CoordinatePoint(5.0, 5.0), points.get(3), DELTA);
}