final double expectedScreenY2 = 385.9;
final double x2 = this.defaultViewEnvelope.getMinX() + (2 * expectedScreenX2);
final double y2 = this.defaultViewEnvelope.getMinY() + (2 * expectedScreenY2);
Point point = this.geometryFactory.createPoint( new Coordinate( x1, y1 ) );
LineString line = this.geometryFactory.createLineString( LimbGeneratorTest.Utils.createCoords( "" + x1 + " " + y1 +", " + x2 + " " + y2 ) );
MultiLineString multiLine = this.geometryFactory.createMultiLineString( new LineString[]{ line, line } );
GeometryCollection innerCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ point, line } );
GeometryCollection outerCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ multiLine, innerCollection } );
// It's important to re-use the same line object multiple times.
// We're then able to verify that the cloning process takes a deep copy of the geometry collection.
// A shallow copy will result in the transform being applied several times to the same line object.
// (Interestingly, outerCollection.clone() takes a deep copy
// but GeometryFactory::createGeometry( outerCollection ) takes a shallow copy.)
Limb limb = new Limb();
limb.setIntersection( outerCollection );
Options options = new Options();
options.setScreenSize( this.halfScreenSize );
PositionAssignmentLimbRefiner testObj = new PositionAssignmentLimbRefiner();
testObj.refine( limb, this.defaultView, options );
assertTrue( limb.getPosition() instanceof GeometryCollection );
GeometryCollection position = (GeometryCollection)limb.getPosition();
assertTrue( position.getGeometryN( 0 ) instanceof MultiLineString );
MultiLineString position1 = (MultiLineString)position.getGeometryN( 0 );
assertTrue( position1.getGeometryN( 0 ) instanceof LineString );
LineString multiLine1 = (LineString)position1.getGeometryN( 0 );
assertEquals( expectedScreenX1, multiLine1.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
assertEquals( expectedScreenY1, multiLine1.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
assertEquals( expectedScreenX2, multiLine1.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
assertEquals( expectedScreenY2, multiLine1.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
assertTrue( position1.getGeometryN( 1 ) instanceof LineString );
LineString multiLine2 = (LineString)position1.getGeometryN( 1 );
assertEquals( expectedScreenX1, multiLine2.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
assertEquals( expectedScreenY1, multiLine2.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
assertEquals( expectedScreenX2, multiLine2.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
assertEquals( expectedScreenY2, multiLine2.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
assertTrue( position.getGeometryN( 1 ) instanceof GeometryCollection );