Package org.geotools.feature

Examples of org.geotools.feature.DefaultFeatureCollection


        InputStream in = url.openConnection().getInputStream();
       
        InputStreamReader filereader=new InputStreamReader(in);
       
        InputSource input = new InputSource(filereader);
        DefaultFeatureCollection collection = new DefaultFeatureCollection();
        GMLReceiver receiver=new GMLReceiver(collection);
        GMLFilterFeature filterFeature = new GMLFilterFeature(receiver);
        GMLFilterGeometry filterGeometry = new GMLFilterGeometry(filterFeature);
        GMLFilterDocument filterDocument = new GMLFilterDocument(filterGeometry);
        try {
            // parse xml
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(filterDocument);
            reader.parse(input);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        SimpleFeature feature=collection.features().next();
        ReferencedEnvelope bounds = new ReferencedEnvelope( feature.getBounds() );
        bounds=new ReferencedEnvelope( bounds.getMinX()-(bounds.getWidth()/8),
                bounds.getMaxX()+(bounds.getWidth()/8),
                bounds.getMinY()-(bounds.getHeight()/4),
                bounds.getMaxY()+(bounds.getHeight()/4), bounds.getCoordinateReferenceSystem() );
View Full Code Here


        }
        return mapper;
    }

    public Collection<? extends IIssue> getIssues() throws IOException {
        DefaultFeatureCollection fc = new DefaultFeatureCollection( getFeatures());
       
        return new FeatureCollectionToIssueCollectionAdapter(fc, getAttributeMapper());
    }
View Full Code Here

    @Ignore
    @Test
    public void testGetBounds() throws Exception {
        IGeoResource resource = CatalogTests.createGeoResource("resource", 0, false); //$NON-NLS-1$
        FeatureStore<SimpleFeatureType, SimpleFeature> fs = resource.resolve(FeatureStore.class, null);
        DefaultFeatureCollection collection = new DefaultFeatureCollection();
        collection.clear();
        GeometryFactory fac=new GeometryFactory();

        Object[] atts = new Object[]{
                fac.createPoint(new Coordinate(0,0)),
                "name1" //$NON-NLS-1$
        };
        SimpleFeatureType schema = fs.getSchema();
        collection.add(SimpleFeatureBuilder.build(schema, atts, "id"));

        atts = new Object[]{
                fac.createPoint(new Coordinate(45,45)),
                "name2" //$NON-NLS-1$
        };
        collection.add(SimpleFeatureBuilder.build(schema, atts, "id"));

        fs.removeFeatures(Filter.INCLUDE);
       
        fs.addFeatures(collection);
        Layer layer = map.getLayerFactory().createLayer(resource);
View Full Code Here

     */
    public static class GMLStrategy implements TransferStrategy {

        public void javaToNative(Object object, TransferData transferData) {
            SimpleFeature feature = (SimpleFeature) object;
            DefaultFeatureCollection collection = new DefaultFeatureCollection();
            collection.add(feature);
            FeatureTransformer transformer = new FeatureTransformer();
            transformer.setIndentation(4);
            try {
                TextTransfer.getInstance().javaToNative(transformer.transform(collection),
                        transferData);
View Full Code Here

        }

        public Object nativeToJava(TransferData transferData) {
            String string = (String) TextTransfer.getInstance().nativeToJava(transferData);
            InputSource input = new InputSource(new StringReader(string));
            DefaultFeatureCollection collection = new DefaultFeatureCollection();
            GMLReceiver receiver = new GMLReceiver(collection);
            GMLFilterFeature filterFeature = new GMLFilterFeature(receiver);
            GMLFilterGeometry filterGeometry = new GMLFilterGeometry(filterFeature);
            GMLFilterDocument filterDocument = new GMLFilterDocument(filterGeometry);
            try {
                // parse xml
                XMLReader reader = XMLReaderFactory.createXMLReader();
                reader.setContentHandler(filterDocument);
                reader.parse(input);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }

            return collection.features().next();
        }
View Full Code Here

        feature1 = SimpleFeatureBuilder.build(ft, new Object[]{"feature1", 1}, "feature1");
        feature2 = SimpleFeatureBuilder.build(ft, new Object[]{"feature2", 2}, "feature2");
        feature3 = SimpleFeatureBuilder.build(ft, new Object[]{"feature3", 3}, "feature3");
        feature4 = SimpleFeatureBuilder.build(ft, new Object[]{"feature4", 4}, "feature4");

        features = new DefaultFeatureCollection();

        features.add(feature1);
        features.add(feature2);
        features.add(feature3);
        features.add(feature4);
View Full Code Here

    public void testUpdateFeatureCollection() throws Exception {
        SimpleFeatureType ft = DataUtilities.createType("type", "name:String,id:int"); //$NON-NLS-1$//$NON-NLS-2$
        SimpleFeature f1 = SimpleFeatureBuilder.build(ft, new Object[]{"feature1", 10}, "feature1"); //$NON-NLS-1$ //$NON-NLS-2$
        SimpleFeature f2 = SimpleFeatureBuilder.build(ft, new Object[]{"feature5", 5}, "feature5"); //$NON-NLS-1$ //$NON-NLS-2$

        DefaultFeatureCollection newFeatures = new DefaultFeatureCollection();

        newFeatures.add(f1);
        newFeatures.add(f2);

        table.update(newFeatures);
       
        UDIGTestUtil.inDisplayThreadWait(100000000, new WaitCondition(){
View Full Code Here

    }

    @Ignore
    @Test
    public void testSetFeatures() {
        DefaultFeatureCollection newFeatures = new DefaultFeatureCollection();
        newFeatures.add(feature1);
        table.setFeatures(newFeatures);
        while( Display.getCurrent().readAndDispatch() );

        assertEquals(1, table.getViewer().getTable().getItemCount());
        TableItem item = table.getViewer().getTable().getItem(0);
        assertEquals(feature1, item.getData());

        newFeatures.add(feature2);
        while( Display.getCurrent().readAndDispatch() );
        assertEquals(2, table.getViewer().getTable().getItemCount());
        item = table.getViewer().getTable().getItem(0);
        assertEquals(feature1, item.getData());
        item = table.getViewer().getTable().getItem(1);
        assertEquals(feature2, item.getData());

        newFeatures.remove(feature1);
        while( Display.getCurrent().readAndDispatch() );
        assertEquals(1, table.getViewer().getTable().getItemCount());
        item = table.getViewer().getTable().getItem(0);
        assertEquals(feature2, item.getData());
View Full Code Here

                SimpleFeatureType schema = feature.getFeatureType();
                FeatureCollection<SimpleFeatureType, SimpleFeature> collection;
                collection = (FeatureCollection) schema2features.get(schema);

                if (collection == null) {
                    collection = new DefaultFeatureCollection(null, schema);
                    schema2features.put(schema, collection);
                }

                collection.add(feature);
            }
View Full Code Here

        //create some data
        GeometryFactory gf = new GeometryFactory();
        SimpleFeatureType featureType = DataUtilities.createType("testType",
                "string:String,int:Integer,double:Double,geom:Point");

        features = new DefaultFeatureCollection(null, null) {};
        features.add(
            SimpleFeatureBuilder.build(featureType, new Object[] {
                "one", new Integer(1), new Double(1.1), gf.createPoint(new Coordinate(1, 1))
            }, "fid.1")
        );
View Full Code Here

TOP

Related Classes of org.geotools.feature.DefaultFeatureCollection

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.