Examples of StreamingParser


Examples of org.geotools.xml.StreamingParser

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

Examples of org.geotools.xml.StreamingParser

        //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

Examples of org.geotools.xml.StreamingParser

        GMLConfiguration configuration = new GMLConfiguration();
        configuration.getProperties().add(Parser.Properties.IGNORE_SCHEMA_LOCATION);
        configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);

        StreamingParser parser = new StreamingParser(configuration, in, "//Point");

        for (int i = 0; i < 3; i++) {
            Point p = (Point) parser.parse();

            assertNotNull(p);
            assertEquals(i, p.getX(), 0d);
            assertEquals(i, p.getY(), 0d);
        }

        assertNull(parser.parse());

        try {
            in.close();
        } catch (IOException e) {
            // nothing to do, but this throws an exception under java 6
View Full Code Here

Examples of org.geotools.xml.StreamingParser

        tx.transform(new DOMSource(document), new StreamResult(schemaFile));

        in.close();
        in = new FileInputStream(schemaFile);

        StreamingParser parser = new StreamingParser(new GMLConfiguration(), in, "//TestFeature");

        for (int i = 0; i < 3; i++) {
            SimpleFeature f = (SimpleFeature) parser.parse();
            assertNotNull(f);

            assertEquals(i + "", f.getID());
            assertEquals(i, ((Point) f.getDefaultGeometry()).getX(), 0d);
            assertEquals(i, ((Point) f.getDefaultGeometry()).getY(), 0d);
            assertEquals(i, ((Integer) f.getAttribute("count")).intValue());
        }

        assertNull(parser.parse());

        try {
            in.close();
        } catch (IOException e) {
            // nothing to do, but this throws an exception under java 6
View Full Code Here

Examples of org.geotools.xml.StreamingParser

        Configuration configuration = new GMLConfiguration();
        InputStream input = getClass().getResourceAsStream("geometry.xml");
        String xpath = "/pointMember | /lineStringMember | /polygonMember";

        //String xpath = "/child::*";
        StreamingParser parser = new StreamingParser(configuration, input, xpath);

        makeAssertions(parser);
    }
View Full Code Here

Examples of org.geotools.xml.StreamingParser

public class GMLFeatureStreamingTest extends TestCase {
    public void testStreamByXpath() throws Exception {
        InputStream in = getClass().getResourceAsStream("feature.xml");
        String xpath = "/featureMember/TestFeature";

        StreamingParser parser = new StreamingParser(new TestConfiguration(), in, xpath);
        makeAssertions(parser);

        in.close();
    }
View Full Code Here

Examples of org.geotools.xml.StreamingParser

    }

    public void testStreamByElementName() throws Exception {
        InputStream in = getClass().getResourceAsStream("feature.xml");

        StreamingParser parser = new StreamingParser(new TestConfiguration(), in,
                new QName(GML.NAMESPACE, "featureMember"));
        makeAssertions(parser);

        in.close();
    }
View Full Code Here

Examples of org.geotools.xml.StreamingParser

        GMLConfiguration configuration = new GMLConfiguration();
        configuration.getProperties().add(Parser.Properties.IGNORE_SCHEMA_LOCATION);
        configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);

        StreamingParser parser = new StreamingParser(configuration, in, "//TestFeature");

        for (int i = 0; i < 3; i++) {
            SimpleFeature f = (SimpleFeature) parser.parse();

            assertNotNull(f);
        }

        assertNull(parser.parse());

        try {
            in.close();
        } catch (IOException e) {
            // nothing to do, but this throws an exception under java 6
View Full Code Here

Examples of org.geotools.xml.StreamingParser

        }
        return b.buildFeatureType();
    }

    public Object decode(InputStream input) throws Exception {
        StreamingParser parser = new StreamingParser(new KMLConfiguration(), input, KML.Placemark);
        SimpleFeature f = null;
        ListFeatureCollection features = null;
        HashMap oldftype = null;
        SimpleFeatureType type = null;
        SimpleFeatureBuilder featureBuilder = null;

        while ((f = (SimpleFeature) parser.parse()) != null) {
            HashMap ftype = getSignature(f);
            if (oldftype == null) {
                oldftype = ftype;
                type = getType(ftype);
                featureBuilder = new SimpleFeatureBuilder(type);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.