gpt4 book ai didi

org.geotools.ysld.Ysld类的使用及代码示例

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

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

Ysld介绍

[英]Parses, encodes, and transforms Ysld.
[中]解析、编码和转换Ysld。

代码示例

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

/**
 * Encodes a GeoTools style object as Ysld.
 *
 * @param sld The sld to encode.
 * @param output The output object, anything accepted by {@link #writer(Object)}
 */
public static void encode(StyledLayerDescriptor sld, Object output) throws IOException {
  encode(sld, output, new UomMapper());
}

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

/**
 * Parses a Ysld stream into GeoTools style objects.
 *
 * @param ysld The Ysld content, anything accepted by {@link #reader(Object)}.
 * @return The GeoTools SLD object.
 */
public static StyledLayerDescriptor parse(Object ysld) throws IOException {
  return parse(ysld, (List<ZoomContextFinder>) null, (ResourceLocator) null, new UomMapper());
}

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

/**
 * Validates a Ysld stream.
 *
 * @param ysld The Ysld.
 * @return List of marked exceptions corresponding to validation errors.
 */
public static List<MarkedYAMLException> validate(Object ysld) throws IOException {
  return validate(ysld, Collections.<ZoomContextFinder>emptyList(), new UomMapper());
}

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

/**
 * Creates an XML reader from an input object.
 *
 * @param input THe input object, see {@link #reader(Object)} for details.
 */
public static XMLStreamReader xmlReader(Object input) throws IOException {
  YsldInput in = reader(input);
  try {
    XMLInputFactory xmlFactory = XMLInputFactory.newFactory();
    try {
      return xmlFactory.createXMLStreamReader(in.reader);
    } catch (XMLStreamException e) {
      throw new IOException(e);
    }
  } finally {
    in.close();
  }
}

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

/**
 * Encodes a GeoTools style object as Ysld.
 *
 * @param sld The sld to encode.
 * @param output The output object, anything accepted by {@link #writer(Object)}
 */
public static void encode(StyledLayerDescriptor sld, Object output, UomMapper uomMapper)
    throws IOException {
  YsldEncoder e = new YsldEncoder(writer(output), uomMapper);
  e.encode(sld);
}

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

Style parse(String dir, String file) throws IOException {
  StringWriter writer = new StringWriter();
  transform(YsldTests.sld(dir, file), writer);
  // System.out.println(writer.toString());
  YsldParser p = new YsldParser(new StringReader(writer.toString()));
  return SLD.defaultStyle(p.parse());
}

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

/**
 * Parses a Ysld stream into GeoTools style objects.
 *
 * @param ysld The Ysld content, anything accepted by {@link #reader(Object)}.
 * @param locator Resource locator for resolving relative URIs.
 * @return The GeoTools SLD object.
 */
public static StyledLayerDescriptor parse(
    Object ysld,
    @Nullable List<ZoomContextFinder> zCtxtFinders,
    @Nullable ResourceLocator locator,
    @Nullable UomMapper uomMapper)
    throws IOException {
  YsldInput in = reader(ysld);
  try {
    YsldParser parser = new YsldParser(in.reader);
    if (zCtxtFinders != null) {
      parser.setZoomContextFinders(zCtxtFinders);
    }
    if (locator != null) {
      parser.setResourceLocator(locator);
    }
    if (uomMapper != null) {
      parser.setUomMapper(uomMapper);
    }
    return parser.parse();
  } finally {
    in.close();
  }
}

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

/**
 * Encodes a GeoTools style object as Ysld.
 *
 * @param sld The sld to encode.
 * @param output The output object, anything accepted by {@link #writer(Object)}
 */
public static void encode(StyledLayerDescriptor sld, Object output, UomMapper uomMapper)
    throws IOException {
  YsldEncoder e = new YsldEncoder(writer(output), uomMapper);
  e.encode(sld);
}

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

/**
 * Transforms an SLD stream to Ysld.
 *
 * @param sld SLD xml reader.
 * @param ysld Ysld writer.
 */
public static void transform(InputStream sld, Writer ysld) throws IOException {
  SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(), sld);
  StyledLayerDescriptor style = parser.parseSLD();
  Ysld.encode(style, ysld);
}

代码示例来源: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

List<MarkedYAMLException> validate(String ysld, List<ZoomContextFinder> ctxts)
    throws IOException {
  // return dump(Ysld.validate(ysld));
  return Ysld.validate(ysld, ctxts, new UomMapper());
}

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

@Test
  public void readerTest() throws IOException {
    InputStream inputStream = YsldTest.class.getResourceAsStream("point.yml");
    YsldInput reader = Ysld.reader(inputStream);
    reader.close();
    try {
      inputStream.read();
      fail("inputStream should be closed");
    } catch (IOException e) {
      // expect IOException reading from a closed reader
    }
  }
}

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

@Test
public void testFTSVendorOption() throws Exception {
  PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer();
  FeatureTypeStyle fts = fts(p);
  fts.getOptions().put("foo", "bar");
  StringWriter out = new StringWriter();
  Ysld.encode(sld(fts), out);
  System.out.append(out.toString());
  YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString()));
  YamlMap result = obj.seq("feature-styles").map(0);
  assertThat(result.str("x-foo"), equalTo("bar"));
}

代码示例来源: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: org.geotools/gt-ysld

/**
 * Validates a Ysld stream.
 *
 * @param ysld The Ysld.
 * @return List of marked exceptions corresponding to validation errors.
 */
public static List<MarkedYAMLException> validate(Object ysld) throws IOException {
  return validate(ysld, Collections.<ZoomContextFinder>emptyList(), new UomMapper());
}

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

/**
 * Validates a Ysld stream.
 *
 * @param ysld The Ysld.
 * @param zContextFinders additional zoom context finders in order of priority.
 * @return List of marked exceptions corresponding to validation errors.
 */
public static List<MarkedYAMLException> validate(
    Object ysld, List<ZoomContextFinder> zContextFinders, UomMapper uomMapper)
    throws IOException {
  YsldInput in = reader(ysld);
  try {
    YsldValidator validator = new YsldValidator();
    validator.setZCtxtFinders(zContextFinders);
    return validator.validate(in.reader);
  } finally {
    in.close();
  }
}

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

@Test
public void testExpressionNil() throws Exception {
  PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer();
  p.getGraphic().setSize(Expression.NIL);
  StringWriter out = new StringWriter();
  Ysld.encode(sld(p), out);
  // System.out.println(out.toString());
}

代码示例来源: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: org.geoserver.community/gs-ysld

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public List<Exception> validate(Object input, Version version, EntityResolver entityResolver) throws IOException {
  return (List) Ysld.validate(toReader(input), Collections.singletonList(zoomFinder), uomMapper);
}

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

/**
 * Creates an XML reader from an input object.
 *
 * @param input THe input object, see {@link #reader(Object)} for details.
 */
public static XMLStreamReader xmlReader(Object input) throws IOException {
  YsldInput in = reader(input);
  try {
    XMLInputFactory xmlFactory = XMLInputFactory.newFactory();
    try {
      return xmlFactory.createXMLStreamReader(in.reader);
    } catch (XMLStreamException e) {
      throw new IOException(e);
    }
  } finally {
    in.close();
  }
}

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