org.opengis.filter.expression.Function.accept()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.opengis.filter.expression.Function.accept()方法的一些代码示例,展示了Function.accept()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.accept()方法的具体详情如下:
包路径:org.opengis.filter.expression.Function
类名称:Function
方法名:accept

Function.accept介绍

暂无

代码示例

代码示例来源:origin: geotools/geotools

public Object accept(ExpressionVisitor visitor, Object extraData) {
  return delegate.accept(visitor, extraData);
}

代码示例来源:origin: geotools/geotools

public void testVolatileFunction() {
  Function f = ff.function("random");
  Expression result = (Expression) f.accept(simpleVisitor, null);
  assertTrue(result instanceof FilterFunction_random);
}

代码示例来源:origin: geotools/geotools

function.accept(testVisitor, extraData);
Object[] functionVisited = testVisitor.functionVisited;
if (Boolean.TRUE != functionVisited[0] || extraData != functionVisited[1]) {

代码示例来源:origin: geotools/geotools

@Test
public void testFunction() {
  Function func = ff.function(("abs"), ff.literal(10));
  assertEquals(Integer.class, func.accept(visitor, null));
}

代码示例来源:origin: geotools/geotools

public void testChainBuffer() {
  // check buffer chaining
  Function innerBuffer = ff.function("buffer", ff.property("the_geom"), ff.literal(3));
  Function geomTx = ff.function("buffer", innerBuffer, ff.literal(2));
  ReferencedEnvelope re = new ReferencedEnvelope(0, 2, 0, 2, null);
  GeometryTransformationVisitor visitor = new GeometryTransformationVisitor();
  ReferencedEnvelope result = (ReferencedEnvelope) geomTx.accept(visitor, re);
  ReferencedEnvelope expected = new ReferencedEnvelope(-5, 7, -5, 7, null);
  assertEquals(expected, result);
}

代码示例来源:origin: geotools/geotools

public Object visit(org.opengis.filter.expression.Function function, Object extraData) {
  // can't optimize out volatile functions
  if (isVolatileFunction(function)) {
    return super.visit(function, extraData);
  }
  // stable function, is it using attributes?
  if (attributeExtractor == null) {
    attributeExtractor = new FilterAttributeExtractor();
  } else {
    attributeExtractor.clear();
  }
  function.accept(attributeExtractor, null);
  // if so we can replace it with a literal
  if (attributeExtractor.isConstantExpression()) {
    Object result = function.evaluate(null);
    return ff.literal(result);
  } else {
    return super.visit(function, extraData);
  }
}

代码示例来源:origin: geotools/geotools

@Test
public void testFunction() throws Exception {
  Function fe =
      ff.function(
          "strIndexOf",
          ff.property("/measurement/determinand_description"),
          ff.literal("determinand_description_1"));
  List unrolledExpressions = (List) fe.accept(visitor, null);
  Expression unmapped = (Expression) unrolledExpressions.get(0);
  assertTrue(unmapped instanceof Function);
  List params = ((Function) unmapped).getParameters();
  assertEquals(2, params.size());
  assertTrue(params.get(0) instanceof PropertyName);
  assertEquals("determinand_description", ((PropertyName) params.get(0)).getPropertyName());
}

代码示例来源:origin: org.geotools/gt-main

public Object accept(ExpressionVisitor visitor, Object extraData) {
  return delegate.accept( visitor, extraData );
}

代码示例来源:origin: geotools/geotools

public void testChainIntersection() {
    Function innerBuffer1 = ff.function("buffer", ff.property("the_geom"), ff.literal(3));
    Function innerBuffer2 = ff.function("buffer", ff.property("other_geom"), ff.literal(2));
    Function geomTx = ff.function("intersection", innerBuffer1, innerBuffer2);

    ReferencedEnvelope re = new ReferencedEnvelope(0, 2, 0, 2, null);

    GeometryTransformationVisitor visitor = new GeometryTransformationVisitor();
    ReferencedEnvelope result = (ReferencedEnvelope) geomTx.accept(visitor, re);

    ReferencedEnvelope expected = new ReferencedEnvelope(-3, 5, -3, 5, null);
    assertEquals(expected, result);
  }
}

代码示例来源:origin: geotools/geotools

public void testIntersectsFilterFunctionUnreferencedGeometry() throws Exception {
  GeometryFactory gf = new GeometryFactory();
  LineString ls =
      gf.createLineString(
          new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)});
  Function intersects = ff.function("intersects", ff.property("geom"), ff.literal(ls));
  Function clone = (Function) intersects.accept(reprojector, null);
  assertNotSame(intersects, clone);
  assertEquals(clone.getParameters().get(0), intersects.getParameters().get(0));
  assertEquals(clone.getParameters().get(1), intersects.getParameters().get(1));
}

代码示例来源:origin: geotools/geotools

public void testStableFunction() {
  EnvFunction.setLocalValue("var", "123");
  Function f = ff.function("env", ff.literal("var"));
  Expression result = (Expression) f.accept(simpleVisitor, null);
  assertTrue(result instanceof Literal);
  assertEquals("123", result.evaluate(null, String.class));
}

代码示例来源:origin: geotools/geotools

public void testNestedVolatile() {
  EnvFunction.setLocalValue("power", 3);
  Function f =
      ff.function("pow", ff.function("random"), ff.function("env", ff.literal("power")));
  Function result = (Function) f.accept(simpleVisitor, null);
  // main function not simplified out
  assertEquals("pow", result.getName());
  // first argument not simplified out
  Function param1 = (Function) result.getParameters().get(0);
  assertEquals("random", param1.getName());
  // second argument simplified out
  Expression param2 = result.getParameters().get(1);
  assertTrue(param2 instanceof Literal);
  assertEquals(Integer.valueOf(3), param2.evaluate(null, Integer.class));
}

代码示例来源:origin: geotools/geotools

public void testIntersectsFilterFunctionReferencedGeometry() 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"));
  Function intersects = ff.function("intersects", ff.property("geom"), ff.literal(ls));
  Function clone = (Function) intersects.accept(reprojector, null);
  assertNotSame(intersects, clone);
  assertEquals(clone.getParameters().get(0), intersects.getParameters().get(0));
  assertFalse(clone.getParameters().get(1).equals(intersects.getParameters().get(1)));
  LineString clonedLs = (LineString) ((Literal) clone.getParameters().get(1)).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: org.geotools/gt-main

public Object visit(org.opengis.filter.expression.Function function, Object extraData) {
  // can't optimize out volatile functions
  if (function instanceof VolatileFunction) {
    return super.visit(function, extraData);
  }
  // stable function, is it using attributes?
  if (attributeExtractor == null) {
    attributeExtractor = new FilterAttributeExtractor();
  } else {
    attributeExtractor.clear();
  }
  function.accept(attributeExtractor, null);
  // if so we can replace it with a literal
  if (attributeExtractor.isConstantExpression()) {
    Object result = function.evaluate(null);
    return ff.literal(result);
  } else {
    return super.visit(function, extraData);
  }
}

代码示例来源:origin: org.geotools/gt-app-schema

@Test
public void testFunction() throws Exception {
  Function fe = ff.function("strIndexOf",
      ff.property("/measurement/determinand_description"), ff
          .literal("determinand_description_1"));
  List unrolledExpressions = (List) fe.accept(visitor, null);
  Expression unmapped = (Expression) unrolledExpressions.get(0);
  assertTrue(unmapped instanceof Function);
  List params = ((Function) unmapped).getParameters();
  assertEquals(2, params.size());
  assertTrue(params.get(0) instanceof PropertyName);
  assertEquals("determinand_description", ((PropertyName) params.get(0)).getPropertyName());
}

相关文章