Package org.geotools.xml

Examples of org.geotools.xml.PullParser$OrPullParserHandler


            inputStream = zis;
        } else {
            inputStream = new FileInputStream(kml);
        }
       
        PullParser parser = new PullParser(new KMLConfiguration(), inputStream, KML.Placemark);

        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
       
        int index = 0;
        SimpleFeature f;
        DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName(kml.getName());
        b.setCRS(crs);
        b.add("name", String.class);
        b.add("the_geom", Geometry.class); //$NON-NLS-1$
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

        while( (f = (SimpleFeature) parser.parse()) != null ) {
            Geometry geometry = (Geometry) f.getDefaultGeometry();
            Object nameAttribute = null;
            try {
                nameAttribute = f.getAttribute("name");
            } catch (Exception e){
View Full Code Here


        }
        assertEquals(20, count);
    }

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

        }
        assertEquals(20, count);
    }

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

    public KMLRawReader(InputStream inputStream, KMLRawReader.ReadType readType,
            SimpleFeatureType featureType) {
        if (KMLRawReader.ReadType.SCHEMA_AND_FEATURES.equals(readType)) {
            if (featureType == null) {
                parser = new PullParser(new KMLConfiguration(), inputStream, KML.Placemark,
                        KML.Schema);
            } else {
                parser = new PullParser(new KMLConfiguration(), inputStream, pullParserArgs(
                        featureTypeSchemaNames(featureType), KML.Placemark, KML.Schema));
            }
        } else if (KMLRawReader.ReadType.FEATURES.equals(readType)) {
            if (featureType == null) {
                parser = new PullParser(new KMLConfiguration(), inputStream, KML.Placemark);
            } else {
                parser = new PullParser(new KMLConfiguration(), inputStream, pullParserArgs(
                        featureTypeSchemaNames(featureType), KML.Placemark));
            }
        } else {
            throw new IllegalArgumentException("Unknown parse read type: " + readType.toString());
        }
View Full Code Here

TOP

Related Classes of org.geotools.xml.PullParser$OrPullParserHandler

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.