Package org.opengis.filter

Examples of org.opengis.filter.FilterFactory2


    }
  }

  @Test
  public void nullFilter() throws Exception {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
    Filter filter = ff.isNull(ff.property(PARAM_DATE_ATTR));
    Iterator<?> it = layer.getElements(filter, 0, 0);

    int t = 0;
    while (it.hasNext()) {
      Assert.assertTrue("Returned object must be a SimpleFeature", it.next() instanceof SimpleFeature);
View Full Code Here


    }
  }

  @Test
  public void nullFilter() throws Exception {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
    Filter filter = ff.isNull(ff.property(PARAM_DATE_ATTR));
    Iterator<?> it = layer.getElements(filter, 0, 0);

    int t = 0;
    while (it.hasNext()) {
      Assert.assertTrue("Returned object must be a HibernateTestFeature",
View Full Code Here

            } catch (FactoryException notSupported) {
                return filter; // unable to use this bounds
            }
        }
       
        FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(null);
       
        String geomProperty = layer.getSchema().getGeometryDescriptor().getLocalName();
        Filter aoiFilter = ff.intersects(ff.property(geomProperty), ff.literal(geometry));
       
        return ff.and(aoiFilter, filter );
    }
View Full Code Here

        CoordinateReferenceSystem crs = layer.getCRS();

        if (!bbox.getCoordinateReferenceSystem().equals(crs)) {
            bbox = bbox.transform(crs, true);
        }
        FilterFactory2 factory = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools
                .getDefaultHints());
        Geometry geom = new GeometryFactory().toGeometry(bbox);
        Intersects filter = factory.intersects(factory.property(type.getGeometryDescriptor()
                .getName()), factory.literal(geom));

        layer.getQuery(false);
        final FeatureCollection<SimpleFeatureType, SimpleFeature> results = source
                .getFeatures(filter);
View Full Code Here

    @Test
    public void testSVGGraphicsFactory() throws Exception {
        URL url = GeoToolsTest.class.getResource("example.svg");
       
        SVGGraphicFactory svgFactory = new SVGGraphicFactory();
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Literal expr = ff.literal( url.toExternalForm() );
       
        Icon icon = svgFactory.getIcon(null, expr, "image/svg",16 );
        assertNotNull( icon );
       
    }
View Full Code Here

    throws SplitFeaturesCommandException {

    try {

          Filter filter = selectedLayer.getFilter();
          FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
          Intersects intersectsFilter;

      final CoordinateReferenceSystem layerCrs = LayerUtil.getCrs(selectedLayer);
      final Geometry splitLineGeom = reprojectSplitLine(splittingLine, layerCrs);

      SimpleFeatureType schema = selectedLayer.getSchema();
      String geomName = schema.getGeometryDescriptor().getLocalName();

      intersectsFilter = ff.intersects(ff.property(geomName), ff.literal(splitLineGeom));

      if (Filter.EXCLUDE.equals(filter)) {
              filter = intersectsFilter;
          } else {
              filter = ff.and(filter, intersectsFilter);
          }
          return filter;
         
        } catch (IllegalFilterException e) {
            e.printStackTrace();
View Full Code Here

     * we show everything unless otherwise instructed).
     * <p>
     * This method takes into account {@link #isAoiFilter()} and {@link #getFilter()}
     */
    public Filter toFilter( FeatureType schema){
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Filter filter = getFilter(); // start with user supplied filter!
        if( filter == Filter.INCLUDE ){
            filter = null; // please ignore the user they want it all
        }
        if( isAoiFilter() ){
            try {
                IAOIService aoiService = PlatformGIS.getAOIService();
                ReferencedEnvelope extent = aoiService.getExtent();
                if( extent != null ){
                    CoordinateReferenceSystem crs = extent.getCoordinateReferenceSystem();
                    Geometry geometry = aoiService.getGeometry();
                    CoordinateReferenceSystem dataCRS = schema.getCoordinateReferenceSystem();
                    if (!CRS.equalsIgnoreMetadata(crs,dataCRS)) {
                        MathTransform transform = CRS.findMathTransform(crs, dataCRS);
                        geometry = JTS.transform(geometry, transform);
                    }
                    String the_geom = schema.getGeometryDescriptor().getName().getLocalPart();
                    Filter spatialFilter = ff.intersects( ff.property(the_geom), ff.literal( geometry ) );
                    if( filter != null ){
                        return ff.and( filter, spatialFilter );
                    }
                    else {
                        return spatialFilter;
                    }
                }
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(Envelope boundingBox, IProgressMonitor monitor) {
        FilterFactory2 factory = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools
                .getDefaultHints());
        Filter bboxFilter = null;
        if (!hasResource(FeatureSource.class))
            return Filter.EXCLUDE;
        try {

            Envelope bbox;
            try {
                MathTransform transform = mapToLayerTransform();
                bbox = JTS.transform(boundingBox, transform);
            } catch (Exception e) {
                bbox = boundingBox;
            }
            String geom = getSchema().getGeometryDescriptor().getName().getLocalPart();
            Object bboxGeom = new GeometryFactory().toGeometry(bbox);
            bboxFilter = factory.intersects(factory.property(geom), factory.literal(bboxGeom));

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

                        // must be a grid coverage or something
                        continue;
                    }
                    String targetGeomName = targetType.getGeometryDescriptor().getLocalName();
   
                    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2( GeoTools.getDefaultHints() );
                    Filter cut= ff.not( ff.within( ff.property( targetGeomName ), ff.literal(hole) ) );
                   
                    //put it on style blackboard
                    //Key:  ProjectBlackboardConstants    String LAYER__DATA_QUERY = "org.locationtech.udig.project.view"; //$NON-NLS-1$
                    IStyleBlackboard styleBlackboard = layer.getStyleBlackboard();
                    styleBlackboard.put(ProjectBlackboardConstants.LAYER__DATA_QUERY, cut);
View Full Code Here

    public List<FeatureId> addFeatures( FeatureCollection<SimpleFeatureType, SimpleFeature> features )
            throws IOException {
        setTransactionInternal();
        List<FeatureId> ids = wrapped.addFeatures(features);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Id filter = ff.id( new HashSet<FeatureId>( ids ) );
       
        fireLayerEditEvent( FeatureEvent.Type.CHANGED, null, Filter.INCLUDE );
       
        return ids;
    }
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.