Package org.geotools.data

Examples of org.geotools.data.Query


            return null;
        }

        @Override
        public void save(IMemento memento, Object value) {
            Query viewRestriction;
            if (value instanceof Filter) {
                Filter filter = (Filter) value;
                viewRestriction = new Query("Feature", filter);
            } else if (value instanceof Query ){
                viewRestriction = (Query) value;
            }
            else {
                viewRestriction = Query.ALL;
            }
            Filter filter;
            CoordinateReferenceSystem crs;
            CoordinateReferenceSystem reproject;
            String handle;
            int maxFeature;
            URI namespace;
            String[] propertyNames;
            String typeName;
            filter = viewRestriction.getFilter();
            crs = viewRestriction.getCoordinateSystem();
            reproject = viewRestriction.getCoordinateSystemReproject();
            handle = viewRestriction.getHandle();
            maxFeature = viewRestriction.getMaxFeatures();
            namespace = viewRestriction.getNamespace();
            propertyNames = viewRestriction.getPropertyNames();
            typeName = viewRestriction.getTypeName();

            StringBuilder propertyNamesString = new StringBuilder();
            if (propertyNames != null) {
                for (String string : propertyNames) {
                    propertyNamesString.append(string);
View Full Code Here


            } else {
                propertyNames = Query.ALL_NAMES;
            }
            String typeName = decode(memento.getString(TYPENAME));

            Query query = createQuery(filter, crs, reproject, handle,
                    maxFeature, namespace, propertyNames, typeName);
            return query;
        }
View Full Code Here

            return null;
        }

        @Override
        public void save(IMemento memento, Object value) {
            Query viewRestriction;
            if (value instanceof Filter) {
                Filter filter = (Filter) value;
                viewRestriction = new Query("Feature", filter);
            } else if (value instanceof Query ){
                viewRestriction = (Query) value;
            }
            else {
                viewRestriction = Query.ALL;
            }
            Filter filter;
            CoordinateReferenceSystem crs;
            CoordinateReferenceSystem reproject;
            String handle;
            int maxFeature;
            URI namespace;
            String[] propertyNames;
            String typeName;
            filter = viewRestriction.getFilter();
            crs = viewRestriction.getCoordinateSystem();
            reproject = viewRestriction.getCoordinateSystemReproject();
            handle = viewRestriction.getHandle();
            maxFeature = viewRestriction.getMaxFeatures();
            namespace = viewRestriction.getNamespace();
            propertyNames = viewRestriction.getPropertyNames();
            typeName = viewRestriction.getTypeName();

            StringBuilder propertyNamesString = new StringBuilder();
            if (propertyNames != null) {
                for (String string : propertyNames) {
                    propertyNamesString.append(string);
View Full Code Here

            return null;
        }

        @Override
        public void save( IMemento memento, Object value ) {
            Query viewRestriction;
            if (value instanceof Filter) {
                Filter filter = (Filter) value;
                viewRestriction = new DefaultQuery("Feature", filter);
            } else {
                viewRestriction = (Query) value;
            }
            Filter filter;
            CoordinateReferenceSystem crs;
            CoordinateReferenceSystem reproject;
            String handle;
            int maxFeature;
            URI namespace;
            String[] propertyNames;
            String typeName;
            filter = viewRestriction.getFilter();
            crs = viewRestriction.getCoordinateSystem();
            reproject = viewRestriction.getCoordinateSystemReproject();
            handle = viewRestriction.getHandle();
            maxFeature = viewRestriction.getMaxFeatures();
            namespace = viewRestriction.getNamespace();
            propertyNames = viewRestriction.getPropertyNames();
            typeName = viewRestriction.getTypeName();

            StringBuilder propertyNamesString = new StringBuilder();
            if (propertyNames != null) {
                for( String string : propertyNames ) {
                    propertyNamesString.append(string);
View Full Code Here

    public void testStyleContentTestNulls() throws Exception {
        ViewStyleContent content = new ViewStyleContent();
        XMLMemento memento = XMLMemento.createWriteRoot("root");
        DefaultQuery start = new DefaultQuery();
        content.save(memento, start);
        Query loaded = (Query) content.load(memento);
        assertEquals(start, loaded);
    }
View Full Code Here

    public void testStyleContentAllNoneFilters() throws Exception {
        ViewStyleContent content = new ViewStyleContent();
        XMLMemento memento = XMLMemento.createWriteRoot("root");
        DefaultQuery start = new DefaultQuery("Feature", Filter.EXCLUDE);
        content.save(memento, start);
        Query loaded = (Query) content.load(memento);
        assertEquals(start, loaded);

        start = new DefaultQuery("Feature", Filter.INCLUDE);
        content.save(memento, start);
        loaded = (Query) content.load(memento);
View Full Code Here

        DefaultQuery start = new DefaultQuery("type", new URI(
                "http://localhost"), filter, 27, new String[] { "att" },
                "handle");
        ViewStyleContent content = new ViewStyleContent();
        content.save(memento, start);
        Query loaded = (Query) content.load(memento);
        assertEquals(start, loaded);
    }
View Full Code Here

      mergedFilter = selectedLayer.createBBoxFilter(bbox.get(index), null);
      filterOR = ff.or(filter, mergedFilter);
    }

    Query query = new Query(typename, filterOR);

    // retrieves the feature in the bbox
    FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures(query);

    List<SimpleFeature> featureList = new ArrayList<SimpleFeature>();
View Full Code Here

        layers = new Layer[1];
        CoordinateReferenceSystem layerCRS = layer.getCRS();
        SimpleFeatureType schema = featureSource.getSchema();
       
        // Original Query provided by Layer.getFilter() as adjusted by selection and edit filter
        Query query = getContext().getFeatureQuery();
        if( styleBlackboard.contains(ProjectBlackboardConstants.LAYER__STYLE_FILTER)){
            if( query == null ){
                query = new Query( schema.getTypeName() );
            }
            // Additional Filter provided as Style used to reduce onscreen clutter
            FilterStyle filterStyle = (FilterStyle) styleBlackboard.get(ProjectBlackboardConstants.LAYER__STYLE_FILTER);
            Filter styleFilter = filterStyle.toFilter(schema);
            if( styleFilter != Filter.INCLUDE ){
                Filter queryFilter = query.getFilter();
                if( queryFilter == Filter.INCLUDE ){
                    query.setFilter( styleFilter );
                }
                else {
                    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
                    Filter combinedFilter = ff.and(styleFilter, queryFilter);
                    query.setFilter( combinedFilter );
                }
            }
        }

        CoordinateReferenceSystem dataCRS = schema.getCoordinateReferenceSystem();
        if (!layerCRS.equals(dataCRS)) {
            // need to force the coordinate reference system to match the layer definition
            FeatureLayer featureLayer = new FeatureLayer(featureSource, style, layer.getName()); //$NON-NLS-1$
            if( query == null ){
                query = new Query(schema.getTypeName());
            }
            query.setCoordinateSystem(layerCRS);
            featureLayer.setQuery(query);
            // double check the implementation is respecting our layer CRS
            FeatureCollection<SimpleFeatureType, SimpleFeature> features = featureSource.getFeatures( query );
            CoordinateReferenceSystem queryCRS = features.getSchema().getCoordinateReferenceSystem();
           
View Full Code Here

   * @return a Query for the selection
   */
  private static Query getSelectionQuery(final ILayer layer) {

    final boolean queryForSelectedFeatures = true;
    final Query selectionQuery = layer.getQuery(queryForSelectedFeatures);
    final Query layerQuery = new Query(selectionQuery);
    CoordinateReferenceSystem layerCrs = layer.getCRS();
    if (ILayer.UNKNOWN_CRS == layerCrs) {
      CoordinateReferenceSystem mapCRS = MapUtil.getCRS(layer.getMap());
      layerQuery.setCoordinateSystem(mapCRS);
    }

    Filter filter = selectionQuery.getFilter();
    // no selection? perform over the whole layer
    if (Filter.EXCLUDE.equals(filter)) {
      layerQuery.setFilter(Filter.INCLUDE);
    }
    return layerQuery;
  }
View Full Code Here

TOP

Related Classes of org.geotools.data.Query

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.