Package org.opengis.filter

Examples of org.opengis.filter.FilterFactory2


    bounds.expandToInclude(featureBounds);
    alerts.add(featureBounds);
  }
  @SuppressWarnings("unchecked")
  private FeatureIterator<SimpleFeature> getAffectedFeatures(SimpleFeature feature) throws IOException {
    FilterFactory2 filterFactory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
    String geomAttName = feature.getFeatureType().getGeometryDescriptor().getLocalName();
    PropertyName geomPropertyExpression = filterFactory.property(geomAttName);
    Literal literalGeomExpression = filterFactory.literal(feature.getDefaultGeometry());
    Touches filter = filterFactory.touches(geomPropertyExpression, literalGeomExpression);
   
    IProgressMonitor monitor =
      getContext().getActionBars().getStatusLineManager().getProgressMonitor();
    FeatureSource<SimpleFeatureType,SimpleFeature> resource =
      getContext().getSelectedLayer().getResource(FeatureSource.class, monitor);
View Full Code Here


     */
    private SimpleFeatureIterator squares(ReferencedEnvelope bounds, double size)
            throws IOException {

        // Limit squares to bounding box
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Filter filter = ff.bbox(ff.property(GEOM), bounds);

        // Align bound to square size and expand by 150%
        bounds = align(bounds, size, 1.6);

        // Create grid for given bounds
View Full Code Here

        return null;
    }

    private org.opengis.filter.Filter createGeometryTypeFilter( String geomName, String type )
            throws IllegalFilterException {
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Function function = ff.function("geometryType", ff.property(geomName));
        return ff.equal(function, ff.literal(type)); //$NON-NLS-1$
    }
View Full Code Here

     * @see #fireChanged
     */
    private ListenerList changedListeners = new ListenerList();

    static List<Definition> createDefaultTransformDefinition(SimpleFeatureType featureType) {
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        List<Definition> list = new ArrayList<TransformProcess.Definition>();
        if (featureType != null) {
            for (AttributeDescriptor descriptor : featureType.getAttributeDescriptors()) {
                Definition definition = new Definition();

                definition.name = descriptor.getLocalName();
                definition.binding = descriptor.getType().getBinding();
                definition.expression = ff.property(descriptor.getName());

                list.add(definition);
            }
        }
        return list;
View Full Code Here

        handler.getContext().worldToScreenTransform().inverseTransform(toTransform, 0,
                toTransform, 0, 2);
        ReferencedEnvelope transformedBounds = new ReferencedEnvelope(toTransform[0], toTransform[2],
                toTransform[1], toTransform[3], handler.getContext().getCRS());

        FilterFactory2 filterFactory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
        ReferencedEnvelope layerBounds;
        try {
            MathTransform transform = layer.mapToLayerTransform();
            layerBounds = new ReferencedEnvelope(JTS.transform(transformedBounds, transform), layer.getCRS());
        } catch (Exception e) {
            layerBounds = transformedBounds;
        }
        String geomAttributeName = layer.getSchema().getGeometryDescriptor().getLocalName();
//        Geometry boundsAsGeom = new GeometryFactory().toGeometry(layerBounds);
//       
//        Intersects filter = filterFactory.intersects(filterFactory.literal(boundsAsGeom),  filterFactory.property(geomAttributeName));
        String srs;
        try {
            srs = CRS.lookupIdentifier(layerBounds.getCoordinateReferenceSystem(), false);
        } catch (FactoryException e) {
            // we cannot convert our request to the data CRS
            // so we cannot return any features
            ProjectPlugin.getPlugin().log(e);
            return null;
        }
        BBOX filter = filterFactory.bbox(geomAttributeName, layerBounds.getMinX(),
            layerBounds.getMinY(), layerBounds.getMaxX(), layerBounds.getMaxY(), srs);
        Query query=new DefaultQuery(schema.getName().getLocalPart(), filter);

        return source.getFeatures(query);
    }
View Full Code Here

     *
     * @param boundingBox in the same crs as the viewport model.
     * @return a Geometry filter in the correct CRS or null if an exception occurs.
     */
    public Filter createBBoxFilter( ReferencedEnvelope boundingBox, ILayer layer, Class<? extends Filter> filterType ) {
        FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
        if (!layer.hasResource(FeatureSource.class))
            return Filter.EXCLUDE;
        try {

            SimpleFeatureType schema = layer.getSchema();
            Name geom = getGeometryAttDescriptor(schema).getName();
           
            Filter bboxFilter =factory.bbox(factory.property(geom), boundingBox);
           

            return bboxFilter;
        } catch (Exception e) {
            ProjectPlugin.getPlugin().log(e);
View Full Code Here

            if (!fids.isEmpty()) {
                LOGGER.finer("Post process update for boundary update and featureValidation");

                Set featureIds = new HashSet();

                FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
                for (Iterator f = fids.iterator(); f.hasNext();) {
                    featureIds.add(ff.featureId((String) f.next()));
                }

                Id modified = ff.id(featureIds);

                FeatureCollection<SimpleFeatureType, SimpleFeature> changed = store.getFeatures(modified);
                listener.dataStoreChange(new TransactionEvent(TransactionEventType.POST_UPDATE,
                        elementName, changed));
            }
View Full Code Here

        // basic information about the request
        int width = getMapReq.getWidth();
        int height = getMapReq.getHeight();
        ReferencedEnvelope bbox = new ReferencedEnvelope(getMapReq.getBbox(), getMapReq.getCrs());
        double scaleDenominator = RendererUtilities.calculateOGCScale(bbox, width, new HashMap());
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());

        final int layerCount = requestedLayers.length;
        results = new ArrayList<FeatureCollection<? extends FeatureType,? extends Feature>>(layerCount);
        metas = new ArrayList<MapLayerInfo>(layerCount);
       
        try {
            for (int i = 0; i < layerCount; i++) {
                List<Rule> rules = getActiveRules(styles[i], scaleDenominator);
                if(rules.size() == 0)
                    continue;
                MapLayerInfo layerInfo = requestedLayers[i];
                if (layerInfo.getType() == MapLayerInfo.TYPE_VECTOR) {
                    CoordinateReferenceSystem dataCRS = layerInfo.getCoordinateReferenceSystem();

                    // compute the request radius
                    double radius;
                    if(buffer <= 0) {
                        // estimate the radius given the currently active rules
                        MetaBufferEstimator estimator = new MetaBufferEstimator();
                        for (Rule rule : rules) {
                            rule.accept(estimator);
                        }
                       
                        if(estimator.getBuffer() < 6.0 || !estimator.isEstimateAccurate()) {
                            radius = 3.0;
                        } else {
                            radius =  estimator.getBuffer() / 2.0;
                        }
                    } else {
                        radius = buffer;
                    }
                   
                    // make sure we don't go overboard, the admin might have set a maximum
                    int maxRadius = request.getWMS().getMaxBuffer();
                    if(maxRadius > 0 && radius > maxRadius)
                        radius = maxRadius;
                   
                    Polygon pixelRect = getEnvelopeFilter(x, y, width, height, bbox, radius);
                    if ((requestedCRS != null) && !CRS.equalsIgnoreMetadata(dataCRS, requestedCRS)) {
                        try {
                            MathTransform transform = CRS.findMathTransform(requestedCRS, dataCRS, true);
                            pixelRect = (Polygon) JTS.transform(pixelRect, transform); // reprojected
                        } catch (MismatchedDimensionException e) {
                            LOGGER.severe(e.getLocalizedMessage());
                        } catch (TransformException e) {
                            LOGGER.severe(e.getLocalizedMessage());
                        } catch (FactoryException e) {
                            LOGGER.severe(e.getLocalizedMessage());
                        }
                    }

                    final FeatureSource<? extends FeatureType, ? extends Feature> featureSource;
                    featureSource = layerInfo.getFeatureSource(false);
                    FeatureType schema = featureSource.getSchema();
                   
                    Filter getFInfoFilter = null;
                    try {
                        GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
                        String localName = geometryDescriptor.getLocalName();
                        getFInfoFilter = ff.intersects(ff.property(localName), ff.literal(pixelRect));
                    } catch (IllegalFilterException e) {
                        e.printStackTrace();
                        throw new WmsException(null, "Internal error : " + e.getMessage());
                    }

                    // include the eventual layer definition filter
                    if (filters[i] != null) {
                        getFInfoFilter = ff.and(getFInfoFilter, filters[i]);
                    }
                   
                    // see if we can include the rule filters as well, if too many we'll do them in memory
                    Filter postFilter = Filter.INCLUDE;
                    Filter rulesFilters = buildRulesFilter(ff, rules);
                    if(!(rulesFilters instanceof Or) ||
                        (rulesFilters instanceof Or && ((Or) rulesFilters).getChildren().size() <= 20)) {
                        getFInfoFilter = ff.and(getFInfoFilter, rulesFilters);
                    } else {
                        postFilter = rulesFilters;
                    }

                    String typeName = schema.getName().getLocalPart();
View Full Code Here

    if (featureId == null)
    {
      throw new LimbServiceException( "No feature id was defined in the request." );
    }
   
    FilterFactory2 filterFactory = CommonFactoryFinder.getFilterFactory2( GeoTools.getDefaultHints() );
   
    // The filter factory requires the FID to be in a Set.
    Set<Identifier> featureIdSet = new HashSet<Identifier>( 1 );
    featureIdSet.add( filterFactory.featureId( featureId ) );
   
    Filter filter = filterFactory.id( featureIdSet );
   
    try
    {
      return getFeatureLayer( layerName ).getFeatureSource( null, null ).getFeatures( filter ).getBounds();
    }
View Full Code Here

    this.editable = editable;
  }

  private Filter generateGeometryFilter(String geomtryField,
      QueryParam queryParam) {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools
        .getDefaultHints());

    Filter geometryFilter = null;
    Geometry geometry = queryParam.getGeometry();
    SpatialFilterType spatialFilterType = queryParam.getSpatialFilterType();
    if (geometry != null) {
      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
        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);
      }
    }

    return geometryFilter;
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.