org.geotools.styling.Rule.getFilter()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(151)

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

Rule.getFilter介绍

[英]This is the filter used to select content for this rule to display
[中]这是用于选择此规则要显示的内容的筛选器

代码示例

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

/**
 * Retrieves all filters defined in a rule
 *
 * @param rule the rule
 * @return array of filters
 */
public static Filter[] filters(Rule[] rule) {
  Filter[] filter = new Filter[rule.length];
  for (int i = 0; i < rule.length; i++) {
    filter[i] = rule[0].getFilter();
  }
  return filter;
}

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

if (!Filter.INCLUDE.equals(r.getFilter()) && hasEnvVariables(r.getFilter())) {
  DuplicatingStyleVisitor cloner =
      new DuplicatingStyleVisitor() {
  r.accept(cloner);
  Rule copy = (Rule) cloner.getCopy();
  if (!Filter.EXCLUDE.equals(copy.getFilter())) {
    ruleList.add(copy);

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

public void visit(Rule rule) {
  Filter filter = rule.getFilter();
  if (filter != null) {
    filter.accept(this, null);
  }
  Symbolizer[] symbolizers = rule.getSymbolizers();
  if (symbolizers != null) {
    for (int i = 0; i < symbolizers.length; i++) {
      Symbolizer symbolizer = symbolizers[i];
      symbolizer.accept(this);
    }
  }
}

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

/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Rule) */
public void visit(Rule rule) {
  Filter filter = rule.getFilter();
  if (filter != null) {
    filter.accept(this, null);
  }
  Symbolizer[] symbolizers = rule.getSymbolizers();
  if (symbolizers != null) {
    for (int i = 0; i < symbolizers.length; i++) {
      Symbolizer symbolizer = symbolizers[i];
      symbolizer.accept(this);
    }
  }
}

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

if (r.getFilter() == null) return; // uh-oh has no filter (want all rows)
filtersToDS.add(r.getFilter());

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

/**
 * Reprojects spatial filters so that they match the feature source native CRS, and assuming all
 * literal geometries are specified in the specified declaredCRS
 */
private Rule reprojectSpatialFilters(
    Rule rule, CoordinateReferenceSystem declaredCRS, FeatureType schema) {
  // NPE avoidance
  Filter filter = rule.getFilter();
  if (filter == null) {
    return rule;
  }
  // try to reproject the filter
  Filter reprojected = reprojectSpatialFilter(declaredCRS, schema, filter);
  if (reprojected == filter) {
    return rule;
  }
  // clone the rule (the style can be reused over and over, we cannot alter it) and set the
  // new filter
  Rule rr = new RuleImpl(rule);
  rr.setFilter(reprojected);
  return rr;
}

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

public RuleBuilder reset(Rule rule) {
  if (rule == null) {
    return unset();
  }
  name = rule.getName();
  title = rule.getTitle();
  ruleAbstract = rule.getAbstract();
  minScaleDenominator = rule.getMinScaleDenominator();
  maxScaleDenominator = rule.getMaxScaleDenominator();
  filter = rule.getFilter();
  elseFilter = rule.isElseFilter();
  symbolizers.clear();
  symbolizers.addAll(rule.symbolizers()); // TODO: unpack into builders in order to "copy"
  symbolizerBuilder = null;
  unset = false;
  legend.reset(rule.getLegend());
  return this;
}

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

for (LiteFeatureTypeStyle lft : lfts) {
  for (Rule r : lft.ruleList) {
    if (r.getFilter() != null) {
      r.getFilter().accept(extractorOther, null);

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

Rule[] rule = fts.getRules();
Rule thisRule = rule[ruleIndex];
Filter filter = thisRule.getFilter();

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

if (rule.getFilter() != null) {
  Filter filter = rule.getFilter();
  filterCopy = copy(filter);

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

@Test
public void testFilterFunctionNoMarker() throws Exception {
  String yaml = "rules: \n" + "- filter: strEndsWith(foo,'bar') = true\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  Rule r = SLD.defaultStyle(sld).featureTypeStyles().get(0).rules().get(0);
  PropertyIsEqualTo f = (PropertyIsEqualTo) r.getFilter();
  Function func = (Function) f.getExpression1();
  assertEquals("strEndsWith", func.getName());
  assertTrue(func.getParameters().get(0) instanceof PropertyName);
  assertTrue(func.getParameters().get(1) instanceof Literal);
  Literal lit = (Literal) f.getExpression2();
}

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

@Test
public void testFilterFunctionWithMarker() throws Exception {
  String yaml = "rules: \n" + "- filter: ${strEndsWith(foo,'bar') = true}\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  Rule r = SLD.defaultStyle(sld).featureTypeStyles().get(0).rules().get(0);
  PropertyIsEqualTo f = (PropertyIsEqualTo) r.getFilter();
  Function func = (Function) f.getExpression1();
  assertEquals("strEndsWith", func.getName());
  assertTrue(func.getParameters().get(0) instanceof PropertyName);
  assertTrue(func.getParameters().get(1) instanceof Literal);
  Literal lit = (Literal) f.getExpression2();
}

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

for (int t = 0; t < length; t++) {
  r = ruleList[t];
  filter = r.getFilter();

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

@Test
public void testFilterWithEscape() throws Exception {
  String yaml = "rules: \n" + "- filter: ${foo = '\\$\\}'}\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  Rule r = SLD.defaultStyle(sld).featureTypeStyles().get(0).rules().get(0);
  Filter f = r.getFilter();
  assertThat(f, Matchers.instanceOf(PropertyIsEqualTo.class));
  assertThat(((PropertyIsEqualTo) f).getExpression1(), attribute("foo"));
  assertThat(((PropertyIsEqualTo) f).getExpression2(), literal("$}"));
}

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

@Test
public void testFilterFunctionWithMarker2() throws Exception {
  String yaml = "rules: \n" + "- filter: ${scalerank < 4}\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  Rule r = SLD.defaultStyle(sld).featureTypeStyles().get(0).rules().get(0);
  Filter f = r.getFilter();
  assertThat(f, Matchers.instanceOf(PropertyIsLessThan.class));
  assertThat(((PropertyIsLessThan) f).getExpression1(), attribute("scalerank"));
  assertThat(((PropertyIsLessThan) f).getExpression2(), literal(4));
}

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

if (rule.getFilter() != null && rule.getFilter() != Filter.INCLUDE) {
  put(
      "filter",
      String.format("${%s}", escapeForEmbededCQL(ECQL.toCQL(rule.getFilter()))));

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

assertEquals("pop < '50000'", ECQL.toCQL(rule.getFilter()));
assertEquals("pop >= '50000' AND pop < '100000'", ECQL.toCQL(rule.getFilter()));
assertEquals("pop >= '100000'", ECQL.toCQL(rule.getFilter()));

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

assertEquals("pop < '200000'", ECQL.toCQL(rule.getFilter()));
assertEquals("pop >= '200000' AND pop < '500000'", ECQL.toCQL(rule.getFilter()));
assertEquals("pop > '500000'", ECQL.toCQL(rule.getFilter()));

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

Rule rule = featureStyle.rules().get(0);
assertEquals("local-road", rule.getName());
assertEquals("type = 'local-road'", ECQL.toCQL(rule.getFilter()));
rule = featureStyle.rules().get(0);
assertEquals("secondary", rule.getName());
assertEquals("type = 'secondary'", ECQL.toCQL(rule.getFilter()));
rule = featureStyle.rules().get(0);
assertEquals("highway", rule.getName());
assertEquals("type = 'highway'", ECQL.toCQL(rule.getFilter()));

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

Filter filter = rule.getFilter();
if (filter != null && filter != Filter.INCLUDE) {
  visit(filter);

相关文章