Package org.opengis.filter

Examples of org.opengis.filter.FilterFactory


     */
    @Ignore
    @Test
    public void testPerformOnMap() throws Exception {
        DropFilterAction action=new DropFilterAction();
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Filter filter=fac.id(FeatureUtils.stringToId(fac, sourceFeatures[0].getID()));
       
        AdaptingFilter aF = AdaptingFilterFactory.createAdaptingFilter(filter, sourceMap.getLayersInternal().get(0));
        final Layer layer = targetMap.getLayersInternal().get(0);
        final  FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = layer.getResource(FeatureSource.class, new NullProgressMonitor());
        assertEquals(1, featureSource.getCount(Query.ALL));
View Full Code Here


        final RenderListener listener=new RenderListener();

        map.getRenderManagerInternal().getRenderExecutor().eAdapters().add(listener);
        listener.rendered=false;
        FeatureStore<SimpleFeatureType, SimpleFeature> store=map.getLayersInternal().get(0).getResource(FeatureStore.class, new NullProgressMonitor());
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        store.removeFeatures(fac.id(FeatureUtils.stringToId(fac, features[0].getID())));

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return listener.rendered;
            }
           
        }, true);
       
        assertTrue(listener.rendered);
       
        listener.rendered=false;
       
        store.modifyFeatures(features[0].getFeatureType().getDescriptor("name"),"changed"//$NON-NLS-1$ //$NON-NLS-2$
            fac.id( FeatureUtils.stringToId(fac, features[1].getID() )));

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return listener.rendered;
            }
           
        }, true);

        assertTrue(listener.rendered);

        listener.rendered=false;
       
        map.getEditManagerInternal().rollbackTransaction();

        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return listener.rendered;
            }
           
        }, true);

        assertTrue(listener.rendered);
       
        listener.rendered=false;
       
        store.modifyFeatures(features[0].getFeatureType().getDescriptor("name"),"changed",   //$NON-NLS-1$//$NON-NLS-2$
            fac.id( FeatureUtils.stringToId(fac, features[1].getID() )));
        UDIGTestUtil.inDisplayThreadWait(5000, new WaitCondition(){

            public boolean isTrue() {
                return listener.rendered;
            }
View Full Code Here

   
    @Ignore
    @Test
    public void testSetFeatureAttribute() throws Exception{
        FeatureStore<SimpleFeatureType, SimpleFeature> store=map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        FeatureCollection<SimpleFeatureType, SimpleFeature> collection=store.getFeatures(fac.id(FeatureUtils.stringToId(fac, features[1].getID())));
        FeatureIterator<SimpleFeature> iter = collection.features();
        assertEquals(ORIGINAL_VALUE, iter.next().getAttribute(1));
        iter.close();
        store.modifyFeatures(store.getSchema().getDescriptor(1), MODIFIED_VALUE, fac.id(FeatureUtils.stringToId(fac, features[1].getID()) ));

        //not committed so other featurestores should not get modified value
        FeatureSource<SimpleFeatureType, SimpleFeature> dsSource= ds.getFeatureSource("testType"); //$NON-NLS-1$
        collection=dsSource.getFeatures(fac.id(FeatureUtils.stringToId(fac, features[1].getID())));
       
        iter = collection.features();
        assertEquals(ORIGINAL_VALUE, iter.next().getAttribute(1));
        iter.close();
       
        //layer featureStore has transactions so should have new value
        collection=store.getFeatures(fac.id(FeatureUtils.stringToId(fac, features[1].getID())));
        iter = collection.features();
        assertEquals(MODIFIED_VALUE, iter.next().getAttribute(1));
        iter.close();

        //Create and send a commit command
        map.sendCommandSync(EditCommandFactory.getInstance().createCommitCommand());
       
        //Now is committed so all FeatureSources should have the new value
        collection=dsSource.getFeatures(fac.id(FeatureUtils.stringToId(fac, features[1].getID())));
        iter = collection.features();
        assertEquals(MODIFIED_VALUE, iter.next().getAttribute(1));
        iter.close();
    }
View Full Code Here

   
    @Ignore
    @Test
    public void testRollback() throws Exception{
        FeatureStore<SimpleFeatureType, SimpleFeature> store=map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        String id = features[1].getID();
        FeatureCollection<SimpleFeatureType, SimpleFeature> collection=store.getFeatures(fac.id(FeatureUtils.stringToId(fac, id)));
        FeatureIterator<SimpleFeature> iter = collection.features();
        assertEquals(ORIGINAL_VALUE, iter.next().getAttribute(1));
        iter.close();
        store.modifyFeatures(store.getSchema().getDescriptor(1), MODIFIED_VALUE, fac.id(FeatureUtils.stringToId(fac, id)) );

        //not committed so other featurestores should not get modified value
        FeatureSource<SimpleFeatureType, SimpleFeature> dsSource= ds.getFeatureSource("testType"); //$NON-NLS-1$
        collection=dsSource.getFeatures(fac.id(FeatureUtils.stringToId(fac, id)));
        iter = collection.features();
        assertEquals(ORIGINAL_VALUE, iter.next().getAttribute(1));
        iter.close();
       
        //layer featureStore has transactions so should have new value
        collection=store.getFeatures(fac.id(FeatureUtils.stringToId(fac, id)));
        iter = collection.features();
        assertEquals(MODIFIED_VALUE, iter.next().getAttribute(1));
        iter.close();

        //Create and send a commit command
        map.sendCommandSync(EditCommandFactory.getInstance().createRollbackCommand());
       
        //Now is committed so all FeatureSources should have the new value
        collection=store.getFeatures(fac.id(FeatureUtils.stringToId(fac, id)));
        iter = collection.features();
        assertEquals(ORIGINAL_VALUE, iter.next().getAttribute(1));
        iter.close();
    }
View Full Code Here

     *
     * @param layer
     * @param results
     * @throws FactoryConfigurationError
     */public static void setSelection( final ILayer layer, GenericValidationResults results ) {
       FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
      
       Set<Identifier> fid = new HashSet<Identifier>();
        // generate a fid filter out of the invalid features
        for( SimpleFeature feature : results ) {
            fid.add(ff.featureId(feature.getID()));
        }
        // select the invalid features on the current layer
        MapCommand selectionCommand = SelectionCommandFactory.getInstance().createSelectCommand(
                layer, ff.id(fid));
        layer.getMap().sendCommandASync(selectionCommand);
    }
View Full Code Here

     * Test method for 'org.locationtech.udig.project.ui.DropFilterAction.perform(Object, Object, IProgressMonitor)'
     */
    @Ignore
    @Test
    public void testPerform() throws Exception {
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Filter filter=fac.id(FeatureUtils.stringToId(fac, sourceFeatures[0].getID()));
        Layer layer = targetMap.getLayersInternal().get(0);
        assertEquals(Filter.EXCLUDE, layer.getFilter());
        Layer sourceLayer = sourceMap.getLayersInternal().get(0);
        CopyFeaturesCommand action=new CopyFeaturesCommand(sourceLayer, filter, layer);
        action.setMap(targetMap);
View Full Code Here

        copyFeatures(MultiPolygon.class, 2);
    }

   
    private void copyFeatures(Class<? extends Geometry> type, int expectedFeatures) throws Exception, IOException {
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Filter filter=fac.id(FeatureUtils.stringToId(fac, sourceFeatures[0].getID()));
        Layer layer = targetMap.getLayersInternal().get(0);
       
        Layer sourceLayer = sourceMap.getLayersInternal().get(0);
        CopyFeaturesCommand action=new CopyFeaturesCommand(sourceLayer, filter, layer);
View Full Code Here

        SimpleFeature[] targetFeatures = new SimpleFeature[1];
        targetFeatures[0]=SimpleFeatureBuilder.build(targetType, new Object[]{null}, "id");
        targetResource=CatalogTests.createGeoResource(targetFeatures, true);
        targetMap=MapTests.createNonDynamicMapAndRenderer(targetResource, new Dimension(100,100));

        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Filter filter=fac.id( FeatureUtils.stringToId(fac, sourceFeatures[0].getID()));
        Layer layer = targetMap.getLayersInternal().get(0);
       
        Layer sourceLayer = sourceMap.getLayersInternal().get(0);
        CopyFeaturesCommand action=new CopyFeaturesCommand(sourceLayer, filter, layer);
View Full Code Here

     * Test method for 'org.locationtech.udig.project.internal.commands.edit.CopyFeaturesCommand.rollback(IProgressMonitor)'
     */
    @Ignore
    @Test
    public void testRollback() throws Exception {
        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Filter filter=fac.id(FeatureUtils.stringToId(fac, sourceFeatures[0].getID()));
        Layer layer = targetMap.getLayersInternal().get(0);
        assertEquals(Filter.EXCLUDE, layer.getFilter());
        Layer sourceLayer = sourceMap.getLayersInternal().get(0);
        CopyFeaturesCommand action=new CopyFeaturesCommand(sourceLayer, filter, layer);

View Full Code Here

        if( feature==null ){
            ILayer layer=getLayer();
             FeatureSource<SimpleFeatureType, SimpleFeature> featureSource;
            try {
                featureSource = layer.getResource(FeatureSource.class, ProgressManager.instance().get());
                FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Id id2 = filterFactory.id(FeatureUtils.stringToId(filterFactory,featureID));
        FeatureCollection<SimpleFeatureType, SimpleFeature>  features = featureSource.getFeatures(id2);
                FeatureIterator<SimpleFeature> iter = features.features();
                try{
                    if ( iter.hasNext() )
                        feature=iter.next();
View Full Code Here

TOP

Related Classes of org.opengis.filter.FilterFactory

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.