CurveLinearizer { public Curve linearize( Curve curve, LinearizationCriterion crit ) { Curve linearizedCurve = null; switch ( curve.getCurveType() ) { case LineString: { linearizedCurve = curve; break; } default: { if ( curve instanceof Ring ) { Ring ring = (Ring) curve; List<Curve> curves = ring.getMembers(); List<Curve> linearizedMembers = new ArrayList<Curve>( curves.size() ); for ( Curve member : curves ) { linearizedMembers.add( linearize( member, crit ) ); } linearizedCurve = geomFac.createRing( ring.getId(), ring.getCoordinateSystem(), linearizedMembers ); } else { List<CurveSegment> segments = curve.getCurveSegments(); CurveSegment[] linearSegments = new CurveSegment[segments.size()]; for ( int i = 0; i < linearSegments.length; i++ ) { linearSegments[i] = linearize( segments.get( i ), crit ); } linearizedCurve = geomFac.createCurve( curve.getId(), curve.getCoordinateSystem(), linearSegments ); } break; } } return linearizedCurve; } CurveLinearizer( GeometryFactory geomFac ); Curve linearize( Curve curve, LinearizationCriterion crit ); LineStringSegment linearize( CurveSegment segment, LinearizationCriterion crit ); LineStringSegment linearizeArc( Arc arc, LinearizationCriterion crit ); LineStringSegment linearizeArcString( ArcString arcString, LinearizationCriterion crit ); LineStringSegment linearizeCubicSpline( CubicSpline spline, LinearizationCriterion crit ); static boolean areCollinear( Point p0, Point p1, Point p2 );  }
@Test public void linearizeArcCircle() { List<CurveSegment> segments = new ArrayList<CurveSegment>(); segments.add( createArc( 384776.006, 5740367.157, 384774.079, 5740367.526, 384772.318, 5740368.390 ) ); segments.add( createArc( 384772.318, 5740368.390, 384770.240, 5740370.494, 384769.157, 5740373.245 ) ); segments.add( createArc( 384769.157, 5740373.245, 384769.672, 5740377.484, 384772.453, 5740380.726 ) ); segments.add( createArc( 384772.453, 5740380.726, 384780.502, 5740380.644, 384783.672, 5740373.244 ) ); segments.add( createArc( 384783.672, 5740373.244, 384780.995, 5740368.743, 384776.006, 5740367.157 ) ); Curve curve = new DefaultCurve( null, null, null, segments ); linearizer.linearize( curve, new MaxErrorCriterion( 0.0001, 150 ) ); }