GML3CurveSegmentReader extends GML3GeometryBaseReader { private Bezier parseBezier( XMLStreamReaderWrapper xmlStream, ICRS defaultCRS ) throws XMLParsingException, XMLStreamException, UnknownCRSException { validateInterpolationAttribute( xmlStream, "polynomialSpline" ); xmlStream.nextTag(); Points points = parseControlPoints( xmlStream, defaultCRS ); int degree = xmlStream.getElementTextAsPositiveInteger( gmlNs, "degree" ); List<Knot> knots = new LinkedList<Knot>(); while ( xmlStream.nextTag() == XMLStreamConstants.START_ELEMENT ) { if ( !"knot".equals( xmlStream.getLocalName() ) ) { break; } xmlStream.nextTag(); xmlStream.require( XMLStreamConstants.START_ELEMENT, gmlNs, "Knot" ); xmlStream.nextTag(); double value = xmlStream.getElementTextAsDouble( gmlNs, "value" ); xmlStream.nextTag(); int multiplicity = xmlStream.getElementTextAsPositiveInteger( gmlNs, "multiplicity" ); xmlStream.nextTag(); double weight = xmlStream.getElementTextAsDouble( gmlNs, "weight" ); xmlStream.nextTag(); xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "Knot" ); xmlStream.nextTag(); xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "knot" ); knots.add( new Knot( value, multiplicity, weight ) ); } if ( knots.size() != 2 ) { String msg = "Error in 'gml:Bezier' element. Must specify exactly two knots."; throw new XMLParsingException( xmlStream, msg ); } xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "Bezier" ); return geomFac.createBezier( points, degree, knots.get( 0 ), knots.get( 1 ) ); } GML3CurveSegmentReader( GML3GeometryReader geometryParser, GMLStreamReader gmlStream );   }
@Test public void parseBezier() throws XMLStreamException, FactoryConfigurationError, IOException, XMLParsingException, UnknownCRSException { Bezier arc = (Bezier) getParser().parseCurveSegment( getReader( "Bezier.gml" ), CRSManager.getCRSRef( "EPSG:4326" ) ); Assert.assertEquals( 4, arc.getControlPoints().size() ); Assert.assertEquals( 2.0, arc.getControlPoints().get( 0 ).get0() ); Assert.assertEquals( 1.0, arc.getControlPoints().get( 0 ).get1() ); Assert.assertEquals( -2.0, arc.getControlPoints().get( 1 ).get0() ); Assert.assertEquals( 2.0, arc.getControlPoints().get( 1 ).get1() ); Assert.assertEquals( -4.0, arc.getControlPoints().get( 2 ).get0() ); Assert.assertEquals( 3.0, arc.getControlPoints().get( 2 ).get1() ); Assert.assertEquals( -6.0, arc.getControlPoints().get( 3 ).get0() ); Assert.assertEquals( 4.0, arc.getControlPoints().get( 3 ).get1() ); Assert.assertEquals( 4, arc.getPolynomialDegree() ); Assert.assertEquals( 2, arc.getKnots().size() ); Assert.assertEquals( 1.0, arc.getKnot1().getValue() ); Assert.assertEquals( 4, arc.getKnot1().getMultiplicity() ); Assert.assertEquals( 5.0, arc.getKnot1().getWeight() ); Assert.assertEquals( 2.0, arc.getKnot2().getValue() ); Assert.assertEquals( 5, arc.getKnot2().getMultiplicity() ); Assert.assertEquals( 1.0, arc.getKnot2().getWeight() ); }