GML3SurfacePatchReader extends GML3GeometryBaseReader { PolygonPatch parsePolygonPatch( XMLStreamReaderWrapper xmlStream, ICRS defaultCRS ) throws XMLParsingException, XMLStreamException, UnknownCRSException { validateAttribute( xmlStream, "interpolation", "planar" ); Ring exteriorRing = null; List<Ring> interiorRings = new LinkedList<Ring>(); if ( xmlStream.nextTag() == START_ELEMENT ) { if ( xmlStream.getLocalName().equals( "exterior" ) ) { if ( xmlStream.nextTag() != START_ELEMENT ) { String msg = "Error in 'gml:PolygonPatch' element. Expected a 'gml:_Ring' element."; throw new XMLParsingException( xmlStream, msg ); } exteriorRing = geometryParser.parseAbstractRing( xmlStream, defaultCRS ); xmlStream.nextTag(); xmlStream.require( END_ELEMENT, gmlNs, "exterior" ); xmlStream.nextTag(); } } while ( xmlStream.getEventType() == START_ELEMENT ) { if ( xmlStream.getLocalName().equals( "interior" ) ) { if ( xmlStream.nextTag() != START_ELEMENT ) { String msg = "Error in 'gml:PolygonPatch' element. Expected a 'gml:_Ring' element."; throw new XMLParsingException( xmlStream, msg ); } interiorRings.add( geometryParser.parseAbstractRing( xmlStream, defaultCRS ) ); xmlStream.nextTag(); xmlStream.require( END_ELEMENT, gmlNs, "interior" ); } else { String msg = "Error in 'gml:Polygon' element. Expected a 'gml:interior' element."; throw new XMLParsingException( xmlStream, msg ); } xmlStream.nextTag(); } xmlStream.require( END_ELEMENT, gmlNs, "PolygonPatch" ); return geomFac.createPolygonPatch( exteriorRing, interiorRings ); } GML3SurfacePatchReader( GML3GeometryReader geometryParser, GMLStreamReader gmlStream );   }
@Test public void parsePolygonPatch() throws XMLStreamException, FactoryConfigurationError, IOException, XMLParsingException, UnknownCRSException { XMLStreamReaderWrapper parser = getParser( "PolygonPatch.gml" ); PolygonPatch patch = (PolygonPatch) getPatchParser().parseSurfacePatch( parser, CRSManager.getCRSRef( "EPSG:4326" ) ); Assert.assertEquals( 2.0, patch.getExteriorRing().getStartPoint().get0() ); Assert.assertEquals( 0.0, patch.getExteriorRing().getStartPoint().get1() ); Assert.assertEquals( 2.0, patch.getExteriorRing().getEndPoint().get0() ); Assert.assertEquals( 0.0, patch.getExteriorRing().getEndPoint().get1() ); Assert.assertEquals( 2, patch.getInteriorRings().size() ); }