Package org.opengis.filter

Examples of org.opengis.filter.FilterFactory2


    return attributesFilter;
  }

  private Filter generateIdFilter(String featureTypeName, String[] featureIds) {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools
        .getDefaultHints());

    Set<FeatureId> fids = new HashSet<FeatureId>();
    for (int i = 0, count = featureIds.length; i < count; i++) {
      String id = featureIds[i];
      FeatureId fid = ff.featureId(featureTypeName + "." + id);
      fids.add(fid);
    }
    Filter filter = ff.id(fids);

    return filter;
  }
View Full Code Here


      // layerId + "|" + featureCollection.hashCode();
      // DefaultTransaction transaction = new
      // DefaultTransaction(transactionId);
      FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
      // featureStore.setTransaction(transaction);
      FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools
          .getDefaultHints());

      for (Iterator<SimpleFeature> itr = featureCollection.iterator(); itr
          .hasNext();) {
        SimpleFeature feature = itr.next();
        FeatureId featureId = feature.getIdentifier();

        try {
          Set<FeatureId> fids = new HashSet<FeatureId>();
          fids.add(featureId);
          Filter filter = ff.id(fids);
          featureStore.modifyFeatures(feature.getDescriptor(),
              feature.getAttributes().toArray(), filter);
          // transaction.commit();

          result.put(featureId, true);
View Full Code Here

        } else if (geometryFilter == null && attributesFilter != null) {
          filter = attributesFilter;
        } else if (geometryFilter == null && attributesFilter == null) {
          // Do nothing
        } else {
          FilterFactory2 ff = CommonFactoryFinder
              .getFilterFactory2(GeoTools.getDefaultHints());
          filter = ff.and(geometryFilter, attributesFilter);
        }

        featureStore.removeFeatures(filter);
        result = true;
      } catch (Exception ex) {
View Full Code Here

    FeatureCollection<? extends FeatureType, ? extends Feature> result = null;

    FeatureSource<? extends FeatureType, ? extends Feature> featureSource = this
        .getMapLayer().getFeatureSource();
    if (featureSource != null) {
      FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools
          .getDefaultHints());

      Filter geometryFilter = null;
      Geometry geometry = queryParam.getGeometry();
      if (geometry != null) {
        SpatialFilterType spatialFilterType = queryParam
            .getSpatialFilterType();

        String geomtryField = featureSource.getSchema()
            .getGeometryDescriptor().getLocalName();
        PropertyName geometryPropertyName = ff.property(geomtryField);
        if (spatialFilterType.equals(SpatialFilterType.INTERSECTS)) {
          geometryFilter = ff.intersects(ff.literal(geometry),
              geometryPropertyName);
        } else if (spatialFilterType.equals(SpatialFilterType.CONTAINS)) {
          geometryFilter = ff.contains(ff.literal(geometry),
              geometryPropertyName);
        } else if (spatialFilterType.equals(SpatialFilterType.CROSSES)) {
          geometryFilter = ff.crosses(ff.literal(geometry),
              geometryPropertyName);
        } else if (spatialFilterType
            .equals(SpatialFilterType.ENVELOPE_INTERSECTS)) {
          geometryFilter = ff.intersects(ff.literal(geometry
              .getEnvelope()), geometryPropertyName);
        } else if (spatialFilterType
            .equals(SpatialFilterType.INDEX_INTERSECTS)) {
          // TODO
          // It is from ArcGIS, but not clear what means
          geometryFilter = ff.intersects(ff.literal(geometry),
              geometryPropertyName);
        } else if (spatialFilterType.equals(SpatialFilterType.OVERLAPS)) {
          geometryFilter = ff.overlaps(ff.literal(geometry),
              geometryPropertyName);
        } else if (spatialFilterType.equals(SpatialFilterType.TOUCHES)) {
          geometryFilter = ff.touches(ff.literal(geometry),
              geometryPropertyName);
        } else if (spatialFilterType.equals(SpatialFilterType.WITHIN)) {
          geometryFilter = ff.within(ff.literal(geometry),
              geometryPropertyName);
        }
      }

      Filter attributesFilter = null;
View Full Code Here

        }
  }

    private static Style createGreyscaleRasterStyle(GridCoverage2D cov) {
        StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
       
        ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
        SelectedChannelType sct = sf.createSelectedChannelType("1", ce);

        RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
        ChannelSelection sel = sf.channelSelection(sct);
        sym.setChannelSelection(sel);
View Full Code Here

            channelNum[BLUE] = 3;
        }
        SelectedChannelType[] sct = new SelectedChannelType[cov.getNumSampleDimensions()];
       
        StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
       
        ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
        for (int i = 0; i < 3; i++) {
            sct[i] = sf.createSelectedChannelType(String.valueOf(channelNum[i]), ce);
        }
        RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
        ChannelSelection sel = sf.channelSelection(sct[RED], sct[GREEN], sct[BLUE]);
View Full Code Here

        }
        if(!(parseResult instanceof Filter)) {
          return null;
        }
        Filter fullFilter = (org.opengis.filter.Filter) parseResult;
        final FilterFactory2 filterFactory2 = CommonFactoryFinder
                .getFilterFactory2(GeoTools.getDefaultHints());

        // -- extract spatial terms from Filter expression
        FilterVisitor visitor = new GeomExtractor(filterFactory2);
        Filter trimmedFilter = (Filter) fullFilter.accept(visitor, null);
View Full Code Here

        public Object visit(BBOX filter, Object extraData)
        {
            if(filter.getExpression2() instanceof Literal && ((Literal) filter.getExpression2()).getValue() instanceof BoundingBox) {
                BoundingBox expr2 = (BoundingBox) ((Literal) filter.getExpression2()).getValue();

                FilterFactory2 factory = getFactory(extraData);
                return factory.bbox(factory.property(geomName), expr2);

            } else if(filter.getExpression2() instanceof Literal && ((Literal) filter.getExpression2()).getValue() instanceof Polygon) {
                Polygon expr2 = (Polygon) ((Literal) filter.getExpression2()).getValue();

                if (expr2.isRectangle()) {
                    FilterFactory2 factory = getFactory(extraData);
                    BBOX bbox = factory.bbox(factory.property(geomName), JTS.toEnvelope(expr2));

                    return bbox;
                } else {
                     return filter;
                }
View Full Code Here

    public void delete(String id) throws IOException
    {
        _lock.lock();
        try {
            FilterFactory2 factory = CommonFactoryFinder
                    .getFilterFactory2(GeoTools.getDefaultHints());
            Filter filter = factory.equals(
                    factory.property(_idColumn), factory.literal(id));

            _index = null;

            _featureStore.removeFeatures(filter);
            try {
View Full Code Here

   
    public void delete(List<String> ids) throws IOException
    {
        _lock.lock();
        try {
            FilterFactory2 factory = CommonFactoryFinder
                    .getFilterFactory2(GeoTools.getDefaultHints());
           
            List<Filter> filters = new LinkedList<Filter>();
           
            for(String id : ids) {
                filters.add(factory.equals(
                    factory.property(_idColumn), factory.literal(id)));
            }
           
            _index = null;

            _featureStore.removeFeatures(factory.or(filters));
            try {
                SpatialFilter.getJCSCache().clear();
            } catch (Throwable e) {
                e.printStackTrace();
            }
View Full Code Here

TOP

Related Classes of org.opengis.filter.FilterFactory2

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.