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


Java Filter类代码示例

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


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

示例1: testUpdateExtent

import org.opengis.filter.Filter; //导入依赖的package包/类
/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#updateExtent(org.geotools.styling.FeatureTypeConstraint)}.
 */
@Test
public void testUpdateExtent() {
    ExtentModel model = new ExtentModel(null);

    Extent[] extentArray = null;
    model.populate(extentArray);

    extentArray = new Extent[2];
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
    extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
    model.populate(extentArray);

    FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint("feature type name",
            Filter.INCLUDE, null);

    model.updateExtent(null);
    model.updateExtent(ftc);

    assertNotNull(ftc.getExtents());
    assertEquals(2, ftc.getExtents().length);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:27,代码来源:ExtentModelTest.java

示例2: testNotFilter

import org.opengis.filter.Filter; //导入依赖的package包/类
@Test
public void testNotFilter() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();

    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);

    ExtractAttributes extract = new ExtractAttributes();
    Rule rule = DefaultSymbols.createNewRule();
    // Try with NOT
    extract = new ExtractAttributes();
    Filter filter = ff.not(ff.greater(ff.literal(42.1), ff.property("dble")));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    extract.extractDefaultFields(sld);

    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(Double.class, dataSourceField.getType());
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:ExtractAttributesTest.java

示例3: createFilter

import org.opengis.filter.Filter; //导入依赖的package包/类
static Filter createFilter(String geomField, double x0, double y0, double x1, double y1,
                           String dateField, String t0, String t1,
                           String attributesQuery)
        throws CQLException, IOException {

    // there are many different geometric predicates that might be used;
    // here, we just use a bounding-box (BBOX) predicate as an example.
    // this is useful for a rectangular query area
    String cqlGeometry = "BBOX(" + geomField + ", " +
            x0 + ", " + y0 + ", " + x1 + ", " + y1 + ")";

    // there are also quite a few temporal predicates; here, we use a
    // "DURING" predicate, because we have a fixed range of times that
    // we want to query
    String cqlDates = "(" + dateField + " DURING " + t0 + "/" + t1 + ")";

    // there are quite a few predicates that can operate on other attribute
    // types; the GeoTools Filter constant "INCLUDE" is a default that means
    // to accept everything
    String cqlAttributes = attributesQuery == null ? "INCLUDE" : attributesQuery;

    String cql = cqlGeometry + " AND " + cqlDates  + " AND " + cqlAttributes;
    return CQL.toFilter(cql);
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:25,代码来源:CassandraQuickStart.java

示例4: loadShapeFile

import org.opengis.filter.Filter; //导入依赖的package包/类
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,代码行数:27,代码来源:ReverseGeocoder.java

示例5: testIsBetween

import org.opengis.filter.Filter; //导入依赖的package包/类
@Test
public void testIsBetween() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();

    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);

    Rule rule = DefaultSymbols.createNewRule();

    // Try isBetween
    Filter filter = ff.between(ff.property("test"), ff.literal("1.23"), ff.literal(4));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    ExtractAttributes extract = new ExtractAttributes();
    extract.extractDefaultFields(sld);

    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(Double.class, dataSourceField.getType());
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:ExtractAttributesTest.java

示例6: createFilter

import org.opengis.filter.Filter; //导入依赖的package包/类
/**
 * Creates the filter.
 *
 * @param parameterList the parameter list
 * @return the filter
 */
@Override
public Filter createFilter(List<Expression> parameterList) {
    IsLessThenOrEqualToImpl filter = null;

    if ((parameterList == null) || (parameterList.size() != 3)) {
        filter = new IsLessThanOrEqualToExtended();
    } else {
        LiteralExpressionImpl matchCase = (LiteralExpressionImpl) parameterList.get(2);

        filter = new IsLessThanOrEqualToExtended(parameterList.get(0), parameterList.get(1),
                (Boolean) matchCase.getValue());
    }

    return filter;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:IsLessThanEqualTo.java

示例7: createFilter

import org.opengis.filter.Filter; //导入依赖的package包/类
/**
 * Creates the filter.
 *
 * @param parameterList the parameter list
 * @return the filter
 */
@Override
public Filter createFilter(List<Expression> parameterList) {
    IsNotEqualToImpl filter = null;

    if ((parameterList == null) || (parameterList.size() != 3)) {
        filter = new IsNotEqualToExtended();
    } else {
        LiteralExpressionImpl matchCase = (LiteralExpressionImpl) parameterList.get(2);

        filter = new IsNotEqualToExtended(parameterList.get(0), parameterList.get(1),
                (Boolean) matchCase.getValue());
    }

    return filter;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:IsNotEqualTo.java

示例8: addDeleteNewFeature

import org.opengis.filter.Filter; //导入依赖的package包/类
public static void addDeleteNewFeature(SimpleFeatureType sft, FeatureStore producerFS)
        throws InterruptedException, IOException {
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(sft);
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
    final Random random = new Random();

    String id = "1000";

    builder.add("Antoninus"); // name
    builder.add((int) Math.round(random.nextDouble()*110)); // age
    builder.add(new Date()); // dtg
    builder.add(WKTUtils$.MODULE$.read("POINT(-1 -1)")); // geom
    SimpleFeature feature = builder.buildFeature(id);

    featureCollection.add(feature);
    producerFS.addFeatures(featureCollection);

    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    Filter idFilter = ff.id(ff.featureId(id));
    producerFS.removeFeatures(idFilter);
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:22,代码来源:KafkaQuickStart.java

示例9: getFilterConfig

import org.opengis.filter.Filter; //导入依赖的package包/类
/**
 * Gets the filter config.
 *
 * @param filter the filter
 * @return the filter config
 */
@Override
public FilterConfigInterface getFilterConfig(Filter filter) {
    if (filter == null) {
        return null;
    }

    Class<?> filterClassTypeName = null;

    if (filter instanceof FilterExtendedInterface) {
        filterClassTypeName = ((FilterExtendedInterface) filter).getOriginalFilter();
    } else {
        filterClassTypeName = filter.getClass();
    }

    return filterTypeMap.get(filterClassTypeName);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:23,代码来源:FilterManager.java

示例10: testIsNull

import org.opengis.filter.Filter; //导入依赖的package包/类
@Test
public void testIsNull() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();

    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);

    Rule rule = DefaultSymbols.createNewRule();

    // Try isNull
    Filter filter = ff.isNull(ff.property("test"));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    ExtractAttributes extract = new ExtractAttributes();
    extract.extractDefaultFields(sld);

    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(String.class, dataSourceField.getType());
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:ExtractAttributesTest.java

示例11: showFilterDialog

import org.opengis.filter.Filter; //导入依赖的package包/类
/**
 * Show filter dialog.
 *
 * @param type the type
 * @param filter the filter
 * @return true, if successful
 */
private boolean showFilterDialog(Class<?> type, Filter filter) {

    btnOk.setEnabled(false);
    rootNode = new FilterNode();
    if (model != null) {
        model.setRoot(rootNode);
        FilterNode filterNode = (FilterNode) rootNode;
        filterNode.setType(type);

        if (filter != null) {
            populateFilter((FilterNode) rootNode, filter);
        }
    }

    setVisible(true);
    return okButtonPressed;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:25,代码来源:FilterPanelv2.java

示例12: testBinaryTemporalFilter

import org.opengis.filter.Filter; //导入依赖的package包/类
@Test
public void testBinaryTemporalFilter() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();

    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);

    Rule rule = DefaultSymbols.createNewRule();

    // Try begins
    Filter filter = ff.begins(ff.property("test"), ff.literal("1234"));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    ExtractAttributes extract = new ExtractAttributes();
    extract.extractDefaultFields(sld);

    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(Integer.class, dataSourceField.getType());
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:ExtractAttributesTest.java

示例13: joinFeaures

import org.opengis.filter.Filter; //导入依赖的package包/类
/**
 *
 * @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,代码行数:45,代码来源:SimpleShapefile.java

示例14: getLayerGroupsFor

import org.opengis.filter.Filter; //导入依赖的package包/类
private Iterable<LayerGroupInfo> getLayerGroupsFor(final FeatureTypeInfo featureType) {
    List<LayerGroupInfo> layerGroups = new ArrayList<LayerGroupInfo>();
    
    // get the layers whose default style is that style, they might be in layer groups
    // using their default style
    Iterable<LayerInfo> layers = catalog.getLayers(featureType);

    // build a query retrieving the first list of candidates
    List<Filter> filters = new ArrayList<>();
    for (LayerInfo layer : layers) {
        filters.add(ff.equal(ff.property("layers.id"), ff.literal(layer.getId()), true, MatchAction.ANY));
        filters.add(ff.equal(ff.property("rootLayer.id"), ff.literal(layer.getId()), true));
    }
    Or groupFilter = ff.or(filters);
    
    try(CloseableIterator<LayerGroupInfo> it = catalog.list(LayerGroupInfo.class, groupFilter)) {
        while(it.hasNext()) {
            LayerGroupInfo lg = it.next();
            layerGroups.add(lg);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "Failed to load groups associated with feature type " + featureType.prefixedName(), e);
    }
    
    loadGroupParents(layerGroups); 
    
    return layerGroups;
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:29,代码来源:BoundsUpdateTransactionListener.java

示例15: mockLayerGroupList

import org.opengis.filter.Filter; //导入依赖的package包/类
void mockLayerGroupList(List<LayerGroupInfo> groups) {
    Capture<Filter> filterCapture = new Capture<>();
    EasyMock.expect(catalog.list(EasyMock.eq(LayerGroupInfo.class), EasyMock.capture(filterCapture)))
        .andStubAnswer(()->{
            List<LayerGroupInfo> matchingGroups = groups.stream()
                .filter(x->filterCapture.getValue().evaluate(x))
                .collect(Collectors.toList());
            return new CloseableIteratorAdapter<LayerGroupInfo>(
                matchingGroups
                    .iterator()
                    );
            });
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:14,代码来源:BoundsUpdateTransactionListenerTest.java


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