/** * @throws XMLStreamException * @throws FactoryConfigurationError * @throws IOException * @throws UnknownCRSException * @throws TransformationException */ @Test public void testPoint() throws XMLStreamException, FactoryConfigurationError, IOException, UnknownCRSException, TransformationException { XMLStreamReaderWrapper xmlReader = new XMLStreamReaderWrapper(this.getClass().getResource(BASE_DIR + POINT_FILE)); xmlReader.nextTag(); Assert.assertEquals(XMLStreamConstants.START_ELEMENT, xmlReader.getEventType()); Assert.assertEquals(new QName(GML21NS, "Point"), xmlReader.getName()); Point point = new GML2GeometryReader().parsePoint(xmlReader, null); Assert.assertEquals(XMLStreamConstants.END_ELEMENT, xmlReader.getEventType()); Assert.assertEquals(new QName(GML21NS, "Point"), xmlReader.getName()); Assert.assertEquals(5.0, point.get0(), DELTA); Assert.assertEquals(40.0, point.get1(), DELTA); Assert.assertEquals( CRSRegistry.lookup("http://www.opengis.net/gml/srs/epsg.xml#4326"), point.getCoordinateSystem().getWrappedCRS()); XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", new Boolean(true)); XMLMemoryStreamWriter memoryWriter = new XMLMemoryStreamWriter(); SchemaLocationXMLStreamWriter writer = new SchemaLocationXMLStreamWriter( memoryWriter.getXMLStreamWriter(), SCHEMA_LOCATION_ATTRIBUTE); GML2GeometryWriter exporter = new GML2GeometryWriter(writer, null, null, new HashSet<String>()); writer.setPrefix("gml", "http://www.opengis.net/gml"); exporter.export(point); writer.flush(); XMLAssert.assertValidity(memoryWriter.getReader(), SCHEMA_LOCATION); }