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


Java FilterFactory2类代码示例

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


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

示例1: addDeleteNewFeature

import org.opengis.filter.FilterFactory2; //导入依赖的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

示例2: getFeatureFilterFromStyle

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
/**
 * Retrieve Filter information from the Layer Style.
 * TODO maybe there is a better method to do that e.g. using a {@link org.geotools.styling.StyleVisitor}
 *
 * @param style the style of the layer
 * @param ff the filter factory to create (concat) filters
 * @param currentScaleDenominator the current scale denominator of the reuquested tiles
 *
 * @return The filter containing all relevant filters for the current solutions or null if no filter is difined.
 */
private Filter getFeatureFilterFromStyle(Style style, FilterFactory2 ff, double currentScaleDenominator) {
    List<Filter> filter = new ArrayList<>();
    for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
        for (Rule rule : featureTypeStyle.rules()) {
            if ((rule.getMaxScaleDenominator() < Double.POSITIVE_INFINITY && currentScaleDenominator < rule.getMaxScaleDenominator())
                    || (rule.getMinScaleDenominator() > 0 && currentScaleDenominator > rule.getMinScaleDenominator())) {
                if (rule.getFilter() != null) {
                    filter.add(rule.getFilter());
                }
            } else if (rule.getMinScaleDenominator() == 0 && rule.getMaxScaleDenominator() == Double.POSITIVE_INFINITY) {
                //No Scale denominator defined so render all
                if (rule.getFilter() == null) {
                    return null;
                } else {
                    filter.add(rule.getFilter());
                }
            }
        }
    }
    return filter.isEmpty() ? null : ff.or(filter);
}
 
开发者ID:stefan0722,项目名称:gs-mvt,代码行数:32,代码来源:StreamingMVTMap.java

示例3: testDisjointFilter

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
@Test
public void testDisjointFilter() throws Exception {
    init("not-active","geo3");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    Point ls = gf.createPoint(sf.create(new double[] { 0, 0 }, 2));
    Disjoint f = ff.disjoint(ff.property("geo3"), ff.literal(ls));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(2, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.12");
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.13");
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例4: testDWithinFilter

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
@Test
public void testDWithinFilter() throws Exception {
    init();
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    Point ls = gf.createPoint(sf.create(new double[] { 0, 0 }, 2));
    DWithin f = ff.dwithin(ff.property("geo"), ff.literal(ls), 3, SI.METRE.getSymbol());
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(2, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.01");
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.10");
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例5: testAlternateGeometry

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
@Test
public void testAlternateGeometry() throws Exception {
    init("active", "geo2");
    SimpleFeatureType schema = featureSource.getSchema();
    GeometryDescriptor gd = schema.getGeometryDescriptor();
    assertNotNull(gd);
    assertEquals("geo2", gd.getLocalName());

    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo2", 6.5, 23.5, 7.5, 24.5, "EPSG:4326");
    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.09");
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例6: testOgrStyleGeoPoint

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
@Test
public void testOgrStyleGeoPoint() throws Exception {
    init("not-active","geo4.coordinates");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo4.coordinates", 0, 0, 5, 5, "EPSG:4326");
    assertNotNull(featureSource.getSchema().getDescriptor("geo4.coordinates"));
    assertNull(featureSource.getSchema().getDescriptor("geo4.type"));

    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    SimpleFeature feature = fsi.next();
    assertEquals(feature.getID(), "active.13");
    assertNotNull(feature.getDefaultGeometry());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例7: logical

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
public void logical() {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    Filter filter;
    // logical start

    // you can use *not* to invert the test; this is especially handy
    // with like filters (allowing you to select content that does not
    // match the provided pattern)
    filter = ff.not(ff.like(ff.property("code"), "230%"));

    // you can also combine filters to narrow the results returned
    filter = ff.and(ff.greater(ff.property("rainfall"), ff.literal(70)),
            ff.equal(ff.property("land_use"), ff.literal("urban"), false));

    filter = ff.or(ff.equal(ff.property("code"), ff.literal("approved")),
            ff.greater(ff.property("funding"), ff.literal(23000)));

    // logical end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:20,代码来源:FilterExamples.java

示例8: temporal

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
void temporal() throws Exception {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // temporal start

    // use the default implementations from gt-main

    DateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    Date date1 = FORMAT.parse("2001-07-05T12:08:56.235-0700");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));

    // Simple check if property is after provided temporal instant
    Filter after = ff.after(ff.property("date"), ff.literal(temporalInstant));

    // can also check of property is within a certain period
    Date date2 = FORMAT.parse("2001-07-04T12:08:56.235-0700");
    Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2));
    Period period = new DefaultPeriod(temporalInstant, temporalInstant2);

    Filter within = ff.toverlaps(ff.property("constructed_date"),
            ff.literal(period));
    // temporal end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:24,代码来源:FilterExamples.java

示例9: caseSensitive

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
void caseSensitive() throws Exception {
    // caseSensitive start
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // default is matchCase = true
    Filter filter = ff.equal(ff.property("state"), ff.literal("queensland"));

    // You can override this default with matchCase = false
    filter = ff.equal(ff.property("state"), ff.literal("new south wales"),
            false);

    // All property comparisons allow you to control case sensitivity
    Filter welcome = ff.greater(ff.property("zone"), ff.literal("danger"),
            false);
    // caseSensitive end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:17,代码来源:FilterExamples.java

示例10: grabFeaturesInBoundingBox

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
/**
 * What features on in this bounding Box?
 * 
 * You can make a bounding box query as shown below:
 * 
 * @param x1
 * @param y1
 * @param x2
 * @param y2
 * @return
 * @throws Exception
 */
// grabFeaturesInBoundingBox start
SimpleFeatureCollection grabFeaturesInBoundingBox(double x1, double y1, double x2, double y2)
        throws Exception {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    FeatureType schema = featureSource.getSchema();
    
    // usually "THE_GEOM" for shapefiles
    String geometryPropertyName = schema.getGeometryDescriptor().getLocalName();
    CoordinateReferenceSystem targetCRS = schema.getGeometryDescriptor()
            .getCoordinateReferenceSystem();
    
    ReferencedEnvelope bbox = new ReferencedEnvelope(x1, y1, x2, y2, targetCRS);
    
    Filter filter = ff.bbox(ff.property(geometryPropertyName), bbox);
    return featureSource.getFeatures(filter);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:29,代码来源:FilterExamples.java

示例11: click1

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
SimpleFeatureCollection click1(MapMouseEvent ev) throws Exception {
    // Construct a 3x3 pixel rectangle centred on the mouse click position
    java.awt.Point screenPos = ev.getPoint();
    
    Rectangle screenRect = new Rectangle(screenPos.x - 1, screenPos.y - 1, 3, 3);
    CoordinateReferenceSystem worldCRS = mapFrame.getMapContent().getCoordinateReferenceSystem();
    // Transform the screen rectangle into a bounding box in the 
    // coordinate reference system of our map content.
    AffineTransform screenToWorld = mapFrame.getMapPane().getScreenToWorldTransform();
    Rectangle2D worldRect = screenToWorld.createTransformedShape(screenRect).getBounds2D();
    ReferencedEnvelope worldBBox = new ReferencedEnvelope(worldRect, worldCRS);
    
    // transform from world to target CRS
    SimpleFeatureType schema = featureSource.getSchema();
    CoordinateReferenceSystem targetCRS = schema.getCoordinateReferenceSystem();
    String geometryAttributeName = schema.getGeometryDescriptor().getLocalName();
    
    ReferencedEnvelope bbox = worldBBox.transform(targetCRS, true, 10);
    
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // Option 1 BBOX
    Filter filter = ff.bbox(ff.property(geometryAttributeName), bbox);
    
    // Option 2 Intersects
    // Filter filter = ff.intersects(ff.property(geometryAttributeName), ff.literal(bbox));
    
    return featureSource.getFeatures(filter);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:FilterExamples.java

示例12: quickPointSymbolizer

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
private void quickPointSymbolizer() {
    // quickPointSymbolizer start
    // "testPoint" feature type style
    StyleBuilder sb = new StyleBuilder();
    FilterFactory2 ff = sb.getFilterFactory();
    
    Mark testMark = sb.createMark(sb.attributeExpression("name"), sb.createFill(Color.RED, 0.5),
            null);
    Graphic graph = sb.createGraphic(null, // An external graphics if needed
            new Mark[] { testMark }, // a Mark if not an external graphics
            null, // aSymbol
            ff.literal(1), // opacity
            ff.property("size"), // read from feature "size" attribute
            ff.property("rotation")); // rotation, here read into the feature
    PointSymbolizer aPointSymbolizer = sb.createPointSymbolizer(graph);
    
    // creation of the style
    Style style = sb.createStyle(aPointSymbolizer);
    // quickPointSymbolizer end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:21,代码来源:StyleExamples.java

示例13: classiferExample

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
public void classiferExample() {
    SimpleFeatureCollection collection = null;
    SimpleFeature feature = null;
    // classiferExample start
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    Function classify = ff.function("Quantile", ff.property("name"), ff.literal(2));
    
    Classifier groups = (Classifier) classify.evaluate(collection);
    // classiferExample end
    // classiferExample2 start
    groups.setTitle(0, "Group A");
    groups.setTitle(1, "Group B");
    // classiferExample2 end
    
    // classiferExample3 start
    // groups is a classifier with "Group A" and "Group B"
    Function sort = ff.function("classify", ff.property("name"), ff.literal(groups));
    int slot = (Integer) sort.evaluate(feature);
    
    System.out.println(groups.getTitle(slot)); // ie. "Group A"
    // classiferExample3 end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:BrewerExamples.java

示例14: visit

import org.opengis.filter.FilterFactory2; //导入依赖的package包/类
@Override
public void visit(DWithinCriterion criterion, Object context) {
	FilterContext fc = (FilterContext) context;
	String name = criterion.getAttributeName();
	if (name == null) {
		name = fc.getDefaultGeometryName();
	}
	Geometry geometry;
	try {
		geometry = converterService.toInternal(criterion.getValue());
		geometry = check(geometry);
		FilterFactory2 ff = (FilterFactory2) filterService.getFilterFactory();
		Expression nameExpression = ff.property(name);
		Literal geomLiteral = ff.literal(geometry);
		Filter filter = ff.dwithin(nameExpression, geomLiteral, criterion.getDistance(), criterion.getUnits());
		fc.setFilter(filter);
	} catch (GeomajasException e) {
		throw new IllegalArgumentException("Unparseable geometry in filter");
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:21,代码来源:DefaultCriterionFilterConverter.java

示例15: joinFeaures

import org.opengis.filter.FilterFactory2; //导入依赖的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


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