Package org.geotools.xml

Examples of org.geotools.xml.StreamingParser


        writer.close();
    }

    public void _testParseGetFeatureStreaming() throws Exception {
        InputStream in = getClass().getResourceAsStream("geoserver-GetFeature.xml");
        StreamingParser parser = new StreamingParser(configuration, in, SimpleFeature.class);

        int n = 0;

        while (parser.parse() != null)
            n++;

        assertEquals(5, n);
    }
View Full Code Here


    }

    @Test
    public void testParseGetFeatureStreaming() throws Exception {
        InputStream in = getClass().getResourceAsStream("geoserver-GetFeature.xml");
        StreamingParser parser = new StreamingParser(configuration, in, SimpleFeature.class);

        int n = 0;

        while (parser.parse() != null)
            n++;

        assertEquals(5, n);
    }
View Full Code Here

    public void testParseWithSchema() throws Exception {
       
    }

    public void testStreamParse() throws Exception {
        StreamingParser p = new StreamingParser(createConfiguration(),
            getClass().getResourceAsStream("KML_Samples.kml"), KML.Placemark);
        int count = 0;
        while(p.parse() != null) {
            count++;
        }
        assertEquals(20, count);
    }
View Full Code Here

        Collection placemarks = (Collection) f.getAttribute("Feature");
        assertEquals(49, placemarks.size());
    }

    public void testStream() throws Exception {
        StreamingParser parser = new StreamingParser(new KMLConfiguration(),
                getClass().getResourceAsStream("states.kml"), KML.Placemark);
        int count = 0;
        SimpleFeature f = null;

        while ((f = (SimpleFeature) parser.parse()) != null) {
            FeatureTypeStyle style = (FeatureTypeStyle) f.getAttribute("Style");
            assertNotNull(style);

            Symbolizer[] syms = style.rules().get(0).getSymbolizers();
            assertEquals(3, syms.length);
View Full Code Here

    FileInputStream fis;
   
    public KMLFeatureReader(String namespace, File file, QName name) throws IOException {
        fis = new FileInputStream(file);
        try {
            parser = new StreamingParser( new KMLConfiguration(), fis, KML.Placemark);
        } catch (Exception e) {
            throw new IOException("Error processing KML file", e);
        }
        forward();
        if (f != null) type = f.getType();
View Full Code Here

            String namespaceURI = featureName.getNamespaceURI();
            String schemaLocation = describeFeatureTypeRequest.toExternalForm();
            appSchemaConfiguration = new WFSAppSchemaConfiguration(wfsConfiguration, namespaceURI,
                    schemaLocation);

            this.parser = new StreamingParser(appSchemaConfiguration, getFeatureResponseStream,
                    featureName);
        } catch (ParserConfigurationException e) {
            throw new DataSourceException(e);
        } catch (SAXException e) {
            if (e.getCause() == null && e.getException() != null) {
View Full Code Here

     * of the streaming parser.
     */
    public static void streamParseGML3() throws Exception {
        InputStream in = GMLParsing.class.getResourceAsStream( "states.xml");
        GMLConfiguration gml = new GMLConfiguration();
        StreamingParser parser = new StreamingParser( gml, in, SimpleFeature.class );
       
        int nfeatures = 0;
        SimpleFeature f = null;
        while( ( f = (SimpleFeature) parser.parse() ) != null ) {
            nfeatures++;
            System.out.println(f.getID());
        }
       
        System.out.println("Number of features: " + nfeatures);
View Full Code Here

    public SimpleFeatureIterator decodeFeatureIterator(InputStream in, QName elementName)
            throws IOException, ParserConfigurationException, SAXException {
        if (Version.GML2 == version || Version.GML3 == version || Version.WFS1_0 == version
                || Version.WFS1_1 == version) {
            // ParserDelegate parserDelegate = new XSDParserDelegate( gmlConfiguration );
            StreamingParser parser;
            if (elementName != null) {
                parser = new StreamingParser(gmlConfiguration, in, elementName);
            } else {
                parser = new StreamingParser(gmlConfiguration, in, SimpleFeature.class);
            }
            return iterator(parser);
        }
        return null;
    }
View Full Code Here

public class GML3ParsingTest extends TestCase {

    public void testWithoutSchema() throws Exception {
        InputStream in = getClass().getResourceAsStream( "states.xml");
        GMLConfiguration gml = new GMLConfiguration();
        StreamingParser parser = new StreamingParser( gml, in, SimpleFeature.class );
       
        int nfeatures = 0;
        SimpleFeature f = null;
        while( ( f = (SimpleFeature) parser.parse() ) != null ) {
            nfeatures++;
            assertNotNull( f.getAttribute( "STATE_NAME"));
            assertNotNull( f.getAttribute( "STATE_ABBR"));
            assertTrue( f.getAttribute( "SAMP_POP") instanceof String );
        }
View Full Code Here

        //xml.deleteOnExit();
        tx.transform( new DOMSource( instance ), new StreamResult( xml ) );
       
        InputStream in = new FileInputStream( xml );
        GMLConfiguration gml = new GMLConfiguration();
        StreamingParser parser = new StreamingParser( gml, in, SimpleFeature.class );
       
        int nfeatures = 0;
        SimpleFeature f = null;
        while( ( f = (SimpleFeature) parser.parse() ) != null ) {
            nfeatures++;
            assertNotNull( f.getAttribute( "STATE_NAME"));
            assertNotNull( f.getAttribute( "STATE_ABBR"));
            assertTrue( f.getAttribute( "SAMP_POP") instanceof Double );
        }
View Full Code Here

TOP

Related Classes of org.geotools.xml.StreamingParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.