本文整理了Java中org.opengis.filter.FilterFactory2.intersects()
方法的一些代码示例,展示了FilterFactory2.intersects()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilterFactory2.intersects()
方法的具体详情如下:
包路径:org.opengis.filter.FilterFactory2
类名称:FilterFactory2
方法名:intersects
[英]Checks if the two geometric operands intersect.
[中]检查两个几何操作数是否相交。
代码示例来源:origin: geotools/geotools
Object cloneFilter(
BinarySpatialOperator bso, Object extraData, Expression ex1, Expression ex2) {
return ff.intersects(ex1, ex2);
}
}.transform(filter, extraData);
代码示例来源:origin: geotools/geotools
/**
*
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated modifiable
*/
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
Expression[] operands = OGCUtils.spatial(node, filterFactory, geometryFactory);
return filterFactory.intersects(operands[0], operands[1]);
}
}
代码示例来源:origin: geotools/geotools
/**
* @return new instance of {@link Intersects} operation
* @throws CQLException
*/
public Intersects buildIntersects() throws CQLException {
Expression[] params = buildParameters();
return getFilterFactory().intersects(params[0], params[1]);
}
代码示例来源:origin: geotools/geotools
public BinarySpatialOperator buildSpatialIntersectsFilter() throws CQLException {
Literal geom = this.resultStack.popLiteral();
Expression property = this.resultStack.popExpression();
FilterFactory2 ff =
(FilterFactory2)
filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation
return ff.intersects(property, geom);
}
代码示例来源:origin: geotools/geotools
public Object visit(Intersects filter, Object arg1) {
Expression[][] exps = visitBinarySpatialOp(filter);
List combinedFilters = new ArrayList(exps.length);
for (int i = 0; i < exps.length; i++) {
Expression left = exps[i][0];
Expression right = exps[i][1];
Filter unrolled = ff.intersects(left, right, filter.getMatchAction());
combinedFilters.add(unrolled);
}
Filter unrolled = combineOred(combinedFilters);
return unrolled;
}
代码示例来源:origin: geotools/geotools
private SimpleFeatureCollection filteredCollection(
Geometry currentGeom, SimpleFeatureCollection subFeatureCollection) {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
Filter intersectFilter =
ff.intersects(ff.property(dataGeomName), ff.literal(currentGeom));
SimpleFeatureCollection subFeatureCollectionIntersection =
this.subFeatureCollection.subCollection(intersectFilter);
if (subFeatureCollectionIntersection.size() == 0) {
subFeatureCollectionIntersection = subFeatureCollection;
}
return subFeatureCollectionIntersection;
}
}
代码示例来源:origin: geotools/geotools
public Object visit(Intersects filter, Object extraData) {
Expression geometry1 = visit(filter.getExpression1(), extraData);
Expression geometry2 = visit(filter.getExpression2(), extraData);
return getFactory(extraData).intersects(geometry1, geometry2, filter.getMatchAction());
}
代码示例来源:origin: geotools/geotools
static Intersects intersects() {
return f.intersects(f.property("the_geom"), f.literal(geometry()));
}
代码示例来源:origin: geotools/geotools
public static Intersects intersects() {
return f.intersects(f.property("the_geom"), f.literal(geometry()));
}
代码示例来源:origin: geotools/geotools
@Test
public void testIntersects() {
ff.intersects(ff.property("geom"), ff.literal(null)).accept(visitor, null);
assertTrue(visitor.hasSpatialFilter);
}
代码示例来源:origin: geotools/geotools
@Test
public void testReprojectedPolygon() throws Exception {
// a spatial filter in a different SRS
CoordinateReferenceSystem utm31n = CRS.decode("EPSG:32631");
CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326");
ReferencedEnvelope envWgs84 = new ReferencedEnvelope(1, 3, 5, 7, wgs84);
ReferencedEnvelope envUTM31N = envWgs84.transform(utm31n, true);
StyleBuilder sb = new StyleBuilder();
Symbolizer ps = sb.createPointSymbolizer();
Style style = sb.createStyle(ps);
Rule rule = style.featureTypeStyles().get(0).rules().get(0);
Polygon polygon = JTS.toGeometry(envUTM31N);
polygon.setUserData(utm31n);
rule.setFilter(ff.intersects(ff.property("geom"), ff.literal(polygon)));
content.addLayer(new FeatureLayer(pointFS, style));
RendererBaseTest.showRender("Reprojected polygon", renderer, TIME, bounds);
assertEquals(1, renderedIds.size());
assertEquals("point.4", renderedIds.iterator().next());
}
代码示例来源:origin: geotools/geotools
public void testBoundedBy() {
Geometry box = JTS.toGeometry(new Envelope(0, 10, 0, 10));
Intersects intersects = fac.intersects(fac.function("boundedBy"), fac.literal(box));
assertTrue(intersects.evaluate(testFeature));
}
}
代码示例来源:origin: geotools/geotools
@Test
public void testReprojectedPolygonFromDefinitionQuery() throws Exception {
// a spatial filter in a different SRS
CoordinateReferenceSystem utm31n = CRS.decode("EPSG:32631");
CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326");
ReferencedEnvelope envWgs84 = new ReferencedEnvelope(1, 3, 5, 7, wgs84);
ReferencedEnvelope envUTM31N = envWgs84.transform(utm31n, true);
// build the style
StyleBuilder sb = new StyleBuilder();
Symbolizer ps = sb.createPointSymbolizer();
Style style = sb.createStyle(ps);
// build a filter for the layer own definition query
FeatureLayer layer = new FeatureLayer(pointFS, style);
Polygon polygon = JTS.toGeometry((Envelope) envUTM31N);
polygon.setUserData(utm31n);
layer.setQuery(
new DefaultQuery(null, ff.intersects(ff.property("geom"), ff.literal(polygon))));
content.addLayer(layer);
RendererBaseTest.showRender(
"Reprojected polygon as a definition query", renderer, TIME, bounds);
assertEquals(1, renderedIds.size());
assertEquals("point.4", renderedIds.iterator().next());
}
}
代码示例来源:origin: geotools/geotools
public void testIntersectsUnreferencedGeometry() throws Exception {
GeometryFactory gf = new GeometryFactory();
LineString ls =
gf.createLineString(
new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)});
// see if coordinates gets flipped, urn forces lat/lon interpretation
Intersects original = ff.intersects(ff.property("geom"), ff.literal(ls));
Filter clone = (Filter) original.accept(reprojector, null);
assertNotSame(original, clone);
assertEquals(original, clone);
}
代码示例来源:origin: geotools/geotools
public void testIntersectsFilter() throws Exception {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
// should match only "r1"
GeometryFactory gf = new GeometryFactory();
PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
LineString ls = gf.createLineString(sf.create(new double[] {2, 1, 2, 3}, 2));
Intersects is = ff.intersects(ff.property(aname("geom")), ff.literal(ls));
FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(is);
checkSingleResult(features, "r1");
}
代码示例来源:origin: geotools/geotools
public void testIntersectsRingFilter() throws Exception {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
// should match only "r1"
GeometryFactory gf = new GeometryFactory();
PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
LineString ls = gf.createLinearRing(sf.create(new double[] {2, 1, 2, 3, 0, 3, 2, 1}, 2));
Intersects is = ff.intersects(ff.property(aname("geom")), ff.literal(ls));
FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(is);
checkSingleResult(features, "r1");
}
代码示例来源:origin: geotools/geotools
public void testIntersectsWithFunction() throws Exception {
Function function = new GeometryFunction();
// see if coordinates gets flipped, urn forces lat/lon interpretation
Intersects original = ff.intersects(ff.property("geom"), function);
Filter clone = (Filter) original.accept(reprojector, null);
assertNotSame(original, clone);
Intersects isClone = (Intersects) clone;
assertEquals(isClone.getExpression1(), original.getExpression1());
LineString clonedLs = (LineString) isClone.getExpression2().evaluate(null);
assertTrue(15 == clonedLs.getCoordinateN(0).x);
assertTrue(10 == clonedLs.getCoordinateN(0).y);
assertTrue(25 == clonedLs.getCoordinateN(1).x);
assertTrue(20 == clonedLs.getCoordinateN(1).y);
assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData());
}
代码示例来源:origin: geotools/geotools
public void testIntersectsReferencedGeometry() throws Exception {
GeometryFactory gf = new GeometryFactory();
LineString ls =
gf.createLineString(
new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)});
ls.setUserData(CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326"));
// see if coordinates gets flipped, urn forces lat/lon interpretation
Intersects original = ff.intersects(ff.property("line"), ff.literal(ls));
Filter clone = (Filter) original.accept(reprojector, null);
assertNotSame(original, clone);
Intersects isClone = (Intersects) clone;
assertEquals(isClone.getExpression1(), original.getExpression1());
LineString clonedLs = (LineString) isClone.getExpression2().evaluate(null);
assertTrue(15 == clonedLs.getCoordinateN(0).x);
assertTrue(10 == clonedLs.getCoordinateN(0).y);
assertTrue(25 == clonedLs.getCoordinateN(1).x);
assertTrue(20 == clonedLs.getCoordinateN(1).y);
assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData());
}
代码示例来源:origin: geotools/geotools
public void testIntersectsReproject(Expression geom) throws FactoryException {
GeometryFactory gf = new GeometryFactory();
LineString ls =
gf.createLineString(
new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)});
ls.setUserData(CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326"));
// see if coordinates gets flipped, urn forces lat/lon interpretation
Intersects original = ff.intersects(geom, ff.literal(ls));
Filter clone = (Filter) original.accept(reprojector, null);
assertNotSame(original, clone);
Intersects isClone = (Intersects) clone;
assertEquals(isClone.getExpression1(), original.getExpression1());
LineString clonedLs = (LineString) ((Literal) isClone.getExpression2()).getValue();
assertTrue(15 == clonedLs.getCoordinateN(0).x);
assertTrue(10 == clonedLs.getCoordinateN(0).y);
assertTrue(25 == clonedLs.getCoordinateN(1).x);
assertTrue(20 == clonedLs.getCoordinateN(1).y);
assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData());
}
代码示例来源:origin: geotools/geotools
@Test
public void testGeometryFilter() throws Exception {
mapping = createSampleDerivedAttributeMappings();
visitor = new UnmappingFilterVisitor(mapping);
targetDescriptor = mapping.getTargetFeature();
targetType = (FeatureType) targetDescriptor.getType();
Expression literalGeom =
ff.literal(new GeometryFactory().createPoint(new Coordinate(1, 1)));
Intersects gf = ff.intersects(ff.property("areaOfInfluence"), literalGeom, MatchAction.ALL);
Filter unrolled = (Filter) gf.accept(visitor, null);
assertTrue(unrolled instanceof Intersects);
assertNotSame(gf, unrolled);
assertEquals(MatchAction.ALL, ((Intersects) unrolled).getMatchAction());
Intersects newFilter = (Intersects) unrolled;
Expression left = newFilter.getExpression1();
Expression right = newFilter.getExpression2();
assertSame(right, literalGeom);
assertTrue(left instanceof Function);
Function fe = (Function) left;
assertEquals("buffer", fe.getName());
Expression arg0 = (Expression) fe.getParameters().get(0);
assertTrue(arg0 instanceof PropertyName);
assertEquals("location", ((PropertyName) arg0).getPropertyName());
}
内容来源于网络,如有侵权,请联系作者删除!