Package org.opengis.filter

Examples of org.opengis.filter.FilterFactory


        EditBlackboard editBlackboard = handler.getEditBlackboard(layer);
        if (!editBlackboard.isEmpty()) {
            EditGeom newSelection = editBlackboard.getGeoms().get(0);

            FilterFactory factory = CommonFactoryFinder
                    .getFilterFactory(GeoTools.getDefaultHints());
            Id id = factory.id(Collections.singleton(factory.featureId(newSelection
                    .getFeatureIDRef().get())));

            FeatureSource<SimpleFeatureType, SimpleFeature> source = layer.getResource(FeatureSource.class, monitor);
            FeatureCollection<SimpleFeatureType, SimpleFeature>  features = source.getFeatures(id);
View Full Code Here


        // check inserts are enabled
        if (!wfs.getServiceLevel().getOps().contains(WFSInfo.Operation.TRANSACTION_UPDATE) ) {
            throw new WFSException("Transaction Update support is not enabled");
        }

        FilterFactory ff = CommonFactoryFinder.getFilterFactory( null );
       
        // check that all required properties have a specified value
        UpdateElementType update = (UpdateElementType) element;

        try {
            FeatureTypeInfo meta = (FeatureTypeInfo) typeInfos.values().iterator().next();
            FeatureType featureType = meta.getFeatureType();

            for (Iterator prop = update.getProperty().iterator(); prop.hasNext();) {
                PropertyType property = (PropertyType) prop.next();

                //check that valus that are non-nillable exist
                if (property.getValue() == null) {
                    String propertyName = property.getName().getLocalPart();
                    AttributeDescriptor attributeType = null;
                    PropertyDescriptor pd = featureType.getDescriptor(propertyName);
                    if(pd instanceof AttributeDescriptor) {
                        attributeType = (AttributeDescriptor) pd;
                    }
                    if ((attributeType != null) && (attributeType.getMinOccurs() > 0)) {
                        String msg = "Property '" + attributeType.getLocalName()
                            + "' is mandatory but no value specified.";
                        throw new WFSException(msg, "MissingParameterValue");
                    }
                }
               
                //check that property names are actually valid
                QName name = property.getName();
                PropertyName propertyName = null;
               
                if ( name.getPrefix() != null && !"".equals( name.getPrefix() )) {
                    propertyName = ff.property( name.getPrefix() + ":" + name.getLocalPart() );
                }
                else {
                    propertyName = ff.property( name.getLocalPart() );
                }
               
                if ( propertyName.evaluate( featureType ) == null ) {
                    String msg = "No such property: " + property.getName();
                    throw new WFSException( msg );
View Full Code Here

        // This okay, just means the tile is empty
        if (featuresInTile.size() == 0) {
            throw new HttpErrorCodeException(204);
        } else {
            FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
            Set<FeatureId> ids = new HashSet<FeatureId>();
            for (String fid : featuresInTile) {
                ids.add(ff.featureId(fid));
            }
            return ff.id(ids);
        }
    }
View Full Code Here

    public FeatureIterator getSortedFeatures(GeometryDescriptor geom,
        ReferencedEnvelope latLongEnv, ReferencedEnvelope nativeEnv,
        Connection cacheConn) throws Exception {
        // build the bbox filter
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        BBOX filter = ff.bbox(geom.getLocalName(), nativeEnv.getMinX(),
                nativeEnv.getMinY(), nativeEnv.getMaxX(), nativeEnv.getMaxY(), null);

        // build an optimized query (only the necessary attributes
        DefaultQuery q = new DefaultQuery();
        q.setFilter(filter);
        q.setPropertyNames(new String[] { geom.getLocalName(), attribute });
        // TODO: enable this when JTS learns how to compute centroids
        // without triggering the
        // generation of Coordinate[] out of the sequences...
        // q.setHints(new Hints(Hints.JTS_COORDINATE_SEQUENCE_FACTORY,
        // PackedCoordinateSequenceFactory.class));
        q.setSortBy(new SortBy[] { ff.sort(attribute, SortOrder.DESCENDING) });

        // return the reader
        return fs.getFeatures(q).features();
    }
View Full Code Here

                    DataStore remoteStore = factory.createDataStore(params);
                    FeatureSource fs = remoteStore.getFeatureSource(TOPP_STATES);
                    remoteStatesAvailable = Boolean.TRUE;
                    // check a basic response can be answered correctly
                    DefaultQuery dq = new DefaultQuery(TOPP_STATES);
                    FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
                    dq.setFilter(ff.greater(ff.property("PERSONS"), ff.literal(20000000)));
                    FeatureCollection fc = fs.getFeatures(dq);
                    if(fc.size() != 1) {
                        logger.log(Level.WARNING, "Remote database status invalid, there should be one and only one " +
                                "feature with more than 20M persons in topp:states");
                        remoteStatesAvailable = Boolean.FALSE;
View Full Code Here

       
        @SuppressWarnings("unchecked")
        protected List loadFeatureCollections(WMSMapContext map) throws IOException {
            ReferencedEnvelope mapArea = map.getAreaOfInterest();
            CoordinateReferenceSystem wgs84 = null;
            FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
            try {
                // this should never throw an exception, but we have to deal with it anyways
                wgs84 = CRS.decode("EPSG:4326");
            } catch(Exception e) {
                throw (IOException) (new IOException("Unable to decode WGS84...").initCause(e));
            }
           
            List featureCollections = new ArrayList();
            for (int i = 0; i < map.getLayerCount(); i++) {
                MapLayer layer = map.getLayer(i);
                DefaultQuery query = new DefaultQuery(layer.getQuery());

                FeatureCollection<SimpleFeatureType, SimpleFeature> features = null;
                try {
                    FeatureSource<SimpleFeatureType, SimpleFeature> source;
                    source = (FeatureSource<SimpleFeatureType, SimpleFeature>) layer.getFeatureSource();
                   
                    GeometryDescriptor gd = source.getSchema().getGeometryDescriptor();
                    if(gd == null) {
                        // geometryless layers...
                        features = source.getFeatures(query);
                    } else {
                        // make sure we are querying the source with the bbox in the right CRS, if
                        // not, reproject the bbox
                        ReferencedEnvelope env = new ReferencedEnvelope(mapArea);
                        CoordinateReferenceSystem sourceCRS = gd.getCoordinateReferenceSystem();
                        if(sourceCRS != null &&
                            !CRS.equalsIgnoreMetadata(mapArea.getCoordinateReferenceSystem(), sourceCRS)) {
                            env = env.transform(sourceCRS, true);
                        }
                       
                        // build the mixed query
                        Filter original = query.getFilter();
                        Filter bbox = ff.bbox(gd.getLocalName(), env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY(), null);
                        query.setFilter(ff.and(original, bbox));

                        // query and eventually reproject
                        features = source.getFeatures(query);
                        if(sourceCRS != null && !CRS.equalsIgnoreMetadata(wgs84, sourceCRS)) {
                            ReprojectingFeatureCollection coll = new ReprojectingFeatureCollection(features, wgs84);
View Full Code Here

            return second;

        if (second == null || Filter.INCLUDE.equals(second))
            return first;

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        return ff.and(first, second);
    }
View Full Code Here

                return Filter.INCLUDE;
            else
                filters.add(rule.getFilter());
        }

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        return ff.or(filters);
    }
View Full Code Here

            ReferencedEnvelope latLongEnv, ReferencedEnvelope nativeEnv,
            Connection cacheConn) throws Exception {
        FeatureSource fs = featureType.getFeatureSource(null, null);
       
        // build the bbox filter
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
       
        BBOX filter = ff.bbox(geom.getLocalName(), nativeEnv.getMinX(),
                nativeEnv.getMinY(), nativeEnv.getMaxX(), nativeEnv.getMaxY(), null);

        // build an optimized query (only the necessary attributes
        DefaultQuery q = new DefaultQuery();
        q.setFilter(filter);
View Full Code Here

        request.setStyles(null);
        assertInvalidMandatoryParam("StyleNotDefined");
    }
   
    public void testEnviroment() {
        final FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        request.setEnv(Collections.singletonMap("myParam", 23));
        DummyRasterMapProducer producer = new DummyRasterMapProducer() {
            @Override
            public void produceMap() throws WmsException {
                assertEquals(23, ff.function("env", ff.literal("myParam")).evaluate(null));
                assertEquals(10, ff.function("env", ff.literal("otherParam"), ff.literal(10)).evaluate(null));
            }
        };
        response = new GetMapResponse(Collections.singleton((GetMapProducer) producer));
        response.execute(request);
       
        // only defaults
        assertNull(ff.function("env", ff.literal("myParam")).evaluate(null));
        assertEquals(10, ff.function("env", ff.literal("otherParam"), ff.literal(10)).evaluate(null));
    }
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.