gpt4 book ai didi

org.geotools.ysld.Ysld.parse()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 11:37:31 26 4
gpt4 key购买 nike

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

Ysld.parse介绍

[英]Parses a Ysld stream into GeoTools style objects.
[中]将Ysld流解析为GeoTools样式的对象。

代码示例

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

@Test
public void testBadExpression() throws Exception {
  String yaml = "polygon: \n" + "  stroke-width: ${round(foo) 1000}\n";
  try {
    Ysld.parse(yaml);
    fail("Bad expression should have thrown exception");
  } catch (IllegalArgumentException e) {
    // expected
  }
}

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

@Test
public void testParseSymbolizers() throws Exception {
  String ysld =
      "symbolizers:\n"
          + "- point:\n"
          + "    symbols:\n"
          + "    - mark:\n"
          + "       shape: triangle";
  assertSLD(Ysld.parse(ysld));
}

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

@Test
public void testZoomDefault() throws IOException {
  String yaml = "feature-styles: \n" + "- name: name\n" + "  rules:\n" + WGS84_TEST_RULES;
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  doTestForWGS84(sld);
}

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

@Test
public void testParseRules() throws Exception {
  String ysld =
      "rules:\n"
          + "- symbolizers:\n"
          + "  - point:\n"
          + "      symbols:\n"
          + "      - mark:\n"
          + "         shape: triangle";
  assertSLD(Ysld.parse(ysld));
}

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

@Test
  public void testDeserializationAttempt() throws Exception {
    try {
      String yaml = "!!java.util.Date\n" + "date: 25\n" + "month: 12\n" + "year: 2016";
      Ysld.parse(yaml);
      fail("Expected parsing to fail");
    } catch (ConstructorException e) {
      assertThat(e.getMessage(), containsString("could not determine a constructor"));
    }
  }
}

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

@Test
public void testExpressionAttribute() throws Exception {
  String yaml = "text: \n" + "  geometry: ${testAttribute}\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0);
  TextSymbolizer symb = (TextSymbolizer) fs.rules().get(0).symbolizers().get(0);
  Expression expr = symb.getGeometry();
  assertThat(expr, attribute("testAttribute"));
}

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

@Test
public void testMultiplyCompositeOnFeatureTypeStyle() throws Exception {
  String yaml = "feature-styles:\n" + "- name: name\n" + "  x-composite: multiply\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  FeatureTypeStyle fts = SLD.featureTypeStyles(sld)[0];
  assertThat(fts, hasProperty("options", hasEntry("composite", "multiply")));
}

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

@Test
public void testEvilExpression1() throws Exception {
  String yaml =
      "point: \n" + "  symbols: \n" + "  - mark: \n" + "      fill-color: \\$\\}\\\\\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(equalTo("$}\\")));
}

代码示例来源: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 testMultiplyCompositeBaseOnSymbolizer() throws Exception {
  String yaml = "line:\n" + "  x-composite-base: true\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld));
  assertThat(p, hasProperty("options", hasEntry("composite-base", "true")));
}

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

@Test
public void testAnchor() throws Exception {
  String yaml =
      "blue: &blue rgb(0,0,255)\n"
          + "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: *blue\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertEquals(Color.BLUE, SLD.color(SLD.fill(p)));
}

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

@Test
public void testNamedColor() throws Exception {
  String yaml = "point: \n" + "  symbols: \n" + "  - mark: \n" + "      fill-color: blue\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertEquals(Color.BLUE, SLD.color(SLD.fill(p)));
}

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

@Test
public void testDynamicColor() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: ${colourAttribute}\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), attribute("colourAttribute"));
}

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

@Test
public void testUomFoot() throws Exception {
  String yaml = "line:\n" + "  uom: foot\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld));
  assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.FOOT.getUnit())));
}

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

@Test
public void testUomMetre() throws Exception {
  String yaml = "line:\n" + "  uom: metre\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld));
  assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.METRE.getUnit())));
}

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

@Test
public void testUomSymbol() throws Exception {
  String yaml = "line:\n" + "  uom: m\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld));
  assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.METRE.getUnit())));
}

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

@Test
public void testRasterBandSelectionGray() throws Exception {
  String yaml = "raster:\n" + "  channels:\n" + "    gray:\n" + "      name: foo\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  RasterSymbolizer r = SLD.rasterSymbolizer(SLD.defaultStyle(sld));
  SelectedChannelType grayChannel = r.getChannelSelection().getGrayChannel();
  assertThat(grayChannel.getChannelName().evaluate(null, String.class), equalTo("foo"));
  assertThat(grayChannel.getContrastEnhancement(), nullContrast());
}

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

@Test
public void testRasterBandSelectionGrayTerse() throws Exception {
  String yaml = "raster:\n" + "  channels:\n" + "    gray: 1\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  RasterSymbolizer r = SLD.rasterSymbolizer(SLD.defaultStyle(sld));
  SelectedChannelType grayChannel = r.getChannelSelection().getGrayChannel();
  assertThat(grayChannel.getChannelName().evaluate(null, String.class), equalTo("1"));
  assertThat(grayChannel.getContrastEnhancement(), nullContrast());
}

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

@SuppressWarnings("unchecked")
@Test
public void testTextDisplacement() throws Exception {
  String yaml = "text: \n" + "  displacement: " + tuple(10, 42) + "\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  TextSymbolizer p = SLD.textSymbolizer(SLD.defaultStyle(sld));
  assertThat(
      ((PointPlacement) p.getLabelPlacement()).getDisplacement(),
      allOf(
          hasProperty("displacementX", literal(10)),
          hasProperty("displacementY", literal(42))));
}

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

@Test
public void testUomSEURL() throws Exception {
  String yaml = "line:\n" + "  uom: " + UomOgcMapping.FOOT.getSEString() + "\n" + "";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld));
  assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.FOOT.getUnit())));
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com