当前位置: 首页>>代码示例>>Java>>正文


Java Filter.INCLUDE属性代码示例

本文整理汇总了Java中org.opengis.filter.Filter.INCLUDE属性的典型用法代码示例。如果您正苦于以下问题:Java Filter.INCLUDE属性的具体用法?Java Filter.INCLUDE怎么用?Java Filter.INCLUDE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.opengis.filter.Filter的用法示例。


在下文中一共展示了Filter.INCLUDE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadShapeFile

public void loadShapeFile(String shapefileName) {
    try {
        File shapefile = new File(shapefileName);
        Map<String, Object> shapefileParams = Maps.newHashMap();
        shapefileParams.put("url", shapefile.toURI().toURL());
        DataStore dataStore = DataStoreFinder.getDataStore(shapefileParams);
        if (dataStore == null)
            throw new RuntimeException("couldn't load the damn data store: " + shapefile);
        String typeName = dataStore.getTypeNames()[0];
        FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);
        Filter filter = Filter.INCLUDE;
        FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);

        try (FeatureIterator<SimpleFeature> features = collection.features()) {
            while (features.hasNext()) {
                SimpleFeature feature = features.next();
                GeoInfo geoInfo = GeoInfo.fromSimpleFeature(feature);
                qt.insert(GeoUtils.getBoundingRectangleAsEnvelope(geoInfo.multiPolygon),
                        geoInfo);
            }
        }
        System.err.printf("loaded shapefile %s\n", shapefile);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:confluentinc,项目名称:strata-tutorials,代码行数:26,代码来源:ReverseGeocoder.java

示例2: joinFeaures

/**
 *
 * @param shapes
 * @param shapes2
 * @throws Exception
 */
private static SimpleFeatureCollection joinFeaures(SimpleFeatureSource shapes, SimpleFeatureSource shapes2) throws Exception {
	SimpleFeatureCollection join =null;

    SimpleFeatureType schema = shapes.getSchema();
    String typeName = schema.getTypeName();
    String geomName = schema.getGeometryDescriptor().getLocalName();

    SimpleFeatureType schema2 = shapes2.getSchema();
    String typeName2 = schema2.getTypeName();
    String geomName2 = schema2.getGeometryDescriptor().getLocalName();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    Query outerGeometry = new Query(typeName, Filter.INCLUDE, new String[] { geomName });
    SimpleFeatureCollection outerFeatures = shapes.getFeatures(outerGeometry);
    SimpleFeatureIterator iterator = outerFeatures.features();
    int max = 0;
    try {
        while (iterator.hasNext()) {
            SimpleFeature feature = iterator.next();
            try {
                Geometry geometry = (Geometry) feature.getDefaultGeometry();
                if (!geometry.isValid()) {
                    // skip bad data
                    continue;
                }
                Filter innerFilter = ff.intersects(ff.property(geomName2), ff.literal(geometry));
                Query innerQuery = new Query(typeName2, innerFilter, Query.NO_NAMES);
                join = shapes2.getFeatures(innerQuery);
                int size = join.size();
                max = Math.max(max, size);
            } catch (Exception skipBadData) {
            }
        }
    } finally {
        iterator.close();
    }
    return join;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:44,代码来源:SimpleShapefile.java

示例3: ISOGeoServerFeatureSource

/**
 * Creates a new GeoServerFeatureSource object.
 *
 * @param source GeoTools2 FeatureSource
 * @param settings Settings for this source
 */
ISOGeoServerFeatureSource(FeatureSource<SimpleFeatureType, SimpleFeature> source, Settings settings) {
    this.source = ISODataUtilities.simple(source);
    this.schema = settings.schema;
    this.definitionQuery = settings.definitionQuery;
    this.declaredCRS = settings.declaredCRS;
    this.srsHandling = ProjectionPolicy.get( settings.srsHandling );
    this.linearizationTolerance = settings.linearizationTolerance;
    this.metadata = settings.metadata;

    if (this.definitionQuery == null) {
        this.definitionQuery = Filter.INCLUDE;
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:19,代码来源:ISOGeoServerFeatureSource.java

示例4: makeDefinitionFilter

/**
 * If a definition query has been configured for the FeatureTypeInfo, makes
 * and return a new Filter that contains both the query's filter and the
 * layer's definition one, by logic AND'ing them.
 *
 * @param filter Origional user supplied Filter
 *
 * @return Filter adjusted to the limitations of definitionQuery
 *
 * @throws DataSourceException If the filter could not meet the limitations
 *         of definitionQuery
 */
protected Filter makeDefinitionFilter(Filter filter)
    throws DataSourceException {
    Filter newFilter = filter;

    try {
        if (definitionQuery != Filter.INCLUDE) {
            newFilter = ff.and(definitionQuery, filter);
        }
    } catch (Exception ex) {
        throw new DataSourceException("Can't create the definition filter", ex);
    }

    return newFilter;
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:26,代码来源:ISOGeoServerFeatureSource.java

示例5: reprojectFilter

private Query reprojectFilter(Query query) throws IOException {
    SimpleFeatureType nativeFeatureType = source.getSchema();
    final GeometryDescriptor geom = nativeFeatureType.getGeometryDescriptor();
    // if no geometry involved, no reprojection needed
    if(geom == null)
        return query;
    
    try {
        // default CRS: the CRS we can assume geometry and bbox elements in filter are
        // that is, usually the declared one, but the native one in the leave case
        CoordinateReferenceSystem defaultCRS = null;
        // we need to reproject all bbox and geometries to a target crs, which is
        // the native one usually, but it's the declared on in the force case (since in
        // that case we completely ignore the native one)
        CoordinateReferenceSystem targetCRS = null;
        CoordinateReferenceSystem nativeCRS = geom.getCoordinateReferenceSystem();
        if(srsHandling == ProjectionPolicy.FORCE_DECLARED) {
            defaultCRS = declaredCRS;
            targetCRS = declaredCRS;
            nativeFeatureType = FeatureTypes.transform(nativeFeatureType, declaredCRS);
        } else if(srsHandling == ProjectionPolicy.REPROJECT_TO_DECLARED) {
            defaultCRS = declaredCRS;
            targetCRS = nativeCRS;
        } else { // FeatureTypeInfo.LEAVE
            defaultCRS = nativeCRS;
            targetCRS = nativeCRS;
        }
        
        // now we apply a default to all geometries and bbox in the filter
        ISODefaultCRSFilterVisitor defaultCRSVisitor = new ISODefaultCRSFilterVisitor(ff, defaultCRS);
        Filter filter = query.getFilter() != null ? query.getFilter() : Filter.INCLUDE;
        Filter defaultedFilter = (Filter) filter.accept(defaultCRSVisitor, null);
        
        // and then we reproject all geometries so that the datastore receives
        // them in the native projection system (or the forced one, in case of force) 
        ISOReprojectingFilterVisitor reprojectingVisitor = new ISOReprojectingFilterVisitor(ff, nativeFeatureType);
        Filter reprojectedFilter = (Filter) defaultedFilter.accept(reprojectingVisitor, null);
        
        Query reprojectedQuery = new Query(query);
        reprojectedQuery.setFilter(reprojectedFilter);
        return reprojectedQuery;
    } catch(Exception e) {
        throw new DataSourceException("Had troubles handling filter reprojection...", e);
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:45,代码来源:ISOGeoServerFeatureSource.java

示例6: buildKvpFromRequest

KvpMap buildKvpFromRequest(GetFeatureRequest3D request) {
    
    // FILTER_LANGUAGE
    // RESOURCEID
    // BBOX
    // STOREDQUERY_ID
    KvpMap kvp = new KvpMap();
    
    // SERVICE
    // VERSION
    // REQUEST
    kvp.put("SERVICE", "WFS");
    kvp.put("REQUEST", "GetFeature");
    kvp.put("VERSION", request.getVersion());
    
    // OUTPUTFORMAT
    // RESULTTYPE
    kvp.put("OUTPUTFORMAT", request.getOutputFormat());
    kvp.put("RESULTTYPE", request.isResultTypeHits() 
        ? ResultTypeType.HITS.name() : ResultTypeType.RESULTS.name());

    // TYPENAMES
    // PROPERTYNAME
    // ALIASES
    // SRSNAME
    // FILTER
    // SORTBY
    List<Query> queries = request.getQueries();
    Query q = queries.get(0);
    if (q.getSrsName() != null) {
        kvp.put("SRSNAME", q.getSrsName().toString());
    }

    StringBuilder typeNames = new StringBuilder();
    StringBuilder propertyName = !q.getPropertyNames().isEmpty() ? new StringBuilder() : null;
    StringBuilder aliases = !q.getAliases().isEmpty() ? new StringBuilder() : null;
    StringBuilder filter = q.getFilter() != null && q.getFilter() != Filter.INCLUDE ? 
        new StringBuilder() : null;
    
    encodeQueryAsKvp(q, typeNames, propertyName, aliases, filter, true);
    if (queries.size() > 1) {
        for (int i = 1; i < queries.size(); i++) {
            encodeQueryAsKvp(queries.get(i), typeNames, propertyName, aliases, filter, true);
        }
    }

    kvp.put("TYPENAMES", typeNames.toString());
    if (propertyName != null) {
        kvp.put("PROPERTYNAME", propertyName.toString());
    }
    if (aliases != null) {
        kvp.put("ALIASES", aliases.toString());
    }
    if (filter != null) {
        kvp.put("FILTER", filter.toString());
    }
    return kvp;
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:58,代码来源:GetFeature3D.java

示例7: isValidJoinFilter

boolean isValidJoinFilter(Filter filter) {
    PostPreProcessFilterSplittingVisitor visitor = 
        new PostPreProcessFilterSplittingVisitor(joinFilterCapabilities, null, null);
    filter.accept(visitor, null);
    return visitor.getFilterPost() == null || visitor.getFilterPost() == Filter.INCLUDE;
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:6,代码来源:GetFeature3D.java

示例8: getBounds

/**
 * Retrieves the total extent of this FeatureSource.
 *
 * <p>
 * Please note this extent will reflect the provided definitionQuery.
 * </p>
 *
 * @return Extent of this FeatureSource, or <code>null</code> if no
 *         optimizations exist.
 *
 * @throws IOException If bounds of definitionQuery
 */
public ReferencedEnvelope getBounds() throws IOException {
    // since CRS is at most forced, we don't need to change this code
    if (definitionQuery == Filter.INCLUDE) {
        return source.getBounds();
    } else {
        Query query = new Query(getSchema().getTypeName(), definitionQuery);

        return source.getBounds(query);
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:22,代码来源:ISOGeoServerFeatureSource.java


注:本文中的org.opengis.filter.Filter.INCLUDE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。