本文整理了Java中org.geotools.ysld.YamlSeq
类的一些代码示例,展示了YamlSeq
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlSeq
类的具体详情如下:
包路径:org.geotools.ysld.YamlSeq
类名称:YamlSeq
[英]Wrapper around a parsed Yaml sequence.
Wrapper requires List as sequence order is required.
[中]包装已解析的Yaml序列。
包装器需要列表,因为序列顺序是必需的。
代码示例来源:origin: geotools/geotools
@Override
public boolean matches(Object obj) {
if (!(obj instanceof YamlSeq)) return false;
YamlSeq seq = (YamlSeq) obj;
Object value = null;
try {
value = seq.map(i);
} catch (IllegalArgumentException ex1) {
try {
value = seq.seq(i);
} catch (IllegalArgumentException ex2) {
value = seq.get(i);
}
}
return (m.matches(value));
}
代码示例来源:origin: geotools/geotools
@Override
public boolean matches(Object obj) {
YamlSeq seq;
if (obj instanceof YamlSeq) {
seq = (YamlSeq) obj;
} else {
return false;
}
if (seq.raw().size() != matchers.length) {
return false;
}
for (int i = 0; i < matchers.length; i++) {
if (!matchers[i].matches(seq.get(i))) {
return false;
}
}
return true;
}
代码示例来源:origin: geotools/geotools
/**
* Quick inline sequence creation.
*
* @param values
* @return sequence of provided values.
*/
public static YamlSeq from(Object... values) {
return new YamlSeq(Arrays.asList(values));
}
代码示例来源: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 testRasterWithAlphaChannel() throws Exception {
// <UserStyle>
// <Title>SLD Cook Book: Alpha channel</Title>
// <FeatureTypeStyle>
// <Rule>
// <RasterSymbolizer>
// <ColorMap>
// <ColorMapEntry color="#008000" quantity="70" />
// <ColorMapEntry color="#008000" quantity="256" opacity="0"/>
// </ColorMap>
// </RasterSymbolizer>
// </Rule>
// </FeatureTypeStyle>
// </UserStyle>
YamlMap obj = transform("raster", "alpha-channel.sld");
YamlMap raster =
obj.seq("feature-styles")
.map(0)
.seq("rules")
.map(0)
.seq("symbolizers")
.map(0)
.map("raster");
assertEquals("(#008000,,70,)", raster.map("color-map").seq("entries").str(0));
assertEquals("(#008000,0,256,)", raster.map("color-map").seq("entries").str(1));
}
代码示例来源:origin: geotools/geotools
@Test
public void lookupTest() {
YamlMap yaml =
YamlMap.from(
"name",
"test",
"list",
YamlSeq.from(1, 2, 3, 4, 5),
"array",
new String[] {"a", "b", "c", "d"},
"map",
YamlMap.from("x", 143.23, "y", 48.9));
// fluent api access
assertEquals("test", yaml.get("name"));
assertEquals(1, yaml.seq("list").get(0));
assertEquals(143.23, yaml.map("map").get("x"));
// lazy api access
assertEquals("test", yaml.lookup("name"));
assertEquals(1, yaml.lookup("list/0"));
assertEquals(143.23, yaml.lookup("map/x"));
// extra lazy api access into array
assertEquals("a", yaml.lookup("array/0"));
// super lazy api using index into map
assertEquals("a", yaml.lookup("2/0"));
}
}
代码示例来源:origin: geotools/geotools
@SuppressWarnings("unchecked")
protected ZoomContext getZoomContext(YamlMap map) {
ZoomContext result = null;
if (map.has("name")) {
result = Util.getNamedZoomContext(map.str("name"), zCtxtFinders);
}
if (result == null && map.has("scales")) {
final List<?> raw = map.seq("scales").raw();
final List<Double> scaleDenoms = new ArrayList<>(raw.size());
for (Number s : (List<Number>) raw) {
scaleDenoms.add(s.doubleValue());
}
final int initialLevel = map.intOr("initial-level", 0);
result = new ListZoomContext(scaleDenoms, initialLevel);
}
if (result == null && map.has("initial-scale")) {
final double initialScale = map.doub("initial-scale");
final double ratio = map.doubOr("ratio", 2d);
final int initialLevel = map.intOr("initial-level", 0);
result = new RatioZoomContext(initialLevel, initialScale, ratio);
}
if (result == null) {
throw new IllegalArgumentException();
}
return result;
}
代码示例来源:origin: geotools/geotools
/**
* Double access
*
* @param i index
* @return Double access, converting as needed
*/
public Double doub(int i) {
return convert(raw.get(i), Double.class);
}
代码示例来源:origin: geotools/geotools
@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
YamlSeq seq = obj instanceof YamlMap ? YamlSeq.from(obj) : obj.seq();
for (YamlObject o : seq) {
YamlMap sym = o.map();
if (sym.has("point")) {
context.push(sym, "point", new PointParser(rule, factory));
} else if (sym.has("line")) {
context.push(sym, "line", new LineParser(rule, factory));
} else if (sym.has("polygon")) {
context.push(sym, "polygon", new PolygonParser(rule, factory));
} else if (sym.has("text")) {
context.push(sym, "text", new TextParser(rule, factory));
} else if (sym.has("raster")) {
context.push(sym, "raster", new RasterParser(rule, factory));
}
}
}
}
代码示例来源:origin: geotools/geotools
YamlSeq list = (YamlSeq) here;
if (index != -1) {
here = list.get(index);
} else {
throw new IndexOutOfBoundsException(
代码示例来源:origin: geotools/geotools
/**
* Yaml mapping.
*
* @param obj Wrapped {@link List}
* @throws IllegalArgumentException {@link List} is required
*/
public YamlSeq(Object obj) {
super(cast(obj));
}
代码示例来源:origin: geotools/geotools
@Test
public void testSymbolizerVendorOption() throws Exception {
PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer();
FeatureTypeStyle fts = fts(p);
p.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)
.seq("rules")
.map(0)
.seq("symbolizers")
.map(0)
.map("point");
assertThat(result.str("x-foo"), equalTo("bar"));
}
代码示例来源:origin: geotools/geotools
@Test
public void testRasterWithTwoColorGradient() throws Exception {
// <UserStyle>
// <Title>SLD Cook Book: Two color gradient</Title>
// <FeatureTypeStyle>
// <Rule>
// <RasterSymbolizer>
// <ColorMap>
// <ColorMapEntry color="#008000" quantity="70" />
// <ColorMapEntry color="#663333" quantity="256" />
// </ColorMap>
// </RasterSymbolizer>
// </Rule>
// </FeatureTypeStyle>
// </UserStyle>
YamlMap obj = transform("raster", "two-color-gradient.sld");
YamlMap raster =
obj.seq("feature-styles")
.map(0)
.seq("rules")
.map(0)
.seq("symbolizers")
.map(0)
.map("raster");
assertEquals("(#008000,,70,)", raster.map("color-map").seq("entries").str(0));
assertEquals("(#663333,,256,)", raster.map("color-map").seq("entries").str(1));
}
代码示例来源:origin: geotools/geotools
@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
YamlSeq seq = obj.seq();
for (Object o : seq.raw()) {
代码示例来源:origin: geotools/geotools
/**
* Integer access
*
* @param i index
* @return Integer access, converting as needed
*/
public Integer integer(int i) {
return convert(raw.get(i), Integer.class);
}
代码示例来源:origin: org.geotools/gt-ysld
@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
YamlSeq seq = obj instanceof YamlMap ? YamlSeq.from(obj) : obj.seq();
for (YamlObject o : seq) {
YamlMap sym = o.map();
if (sym.has("point")) {
context.push(sym, "point", new PointParser(rule, factory));
} else if (sym.has("line")) {
context.push(sym, "line", new LineParser(rule, factory));
} else if (sym.has("polygon")) {
context.push(sym, "polygon", new PolygonParser(rule, factory));
} else if (sym.has("text")) {
context.push(sym, "text", new TextParser(rule, factory));
} else if (sym.has("raster")) {
context.push(sym, "raster", new RasterParser(rule, factory));
}
}
}
}
代码示例来源:origin: org.geotools/gt-ysld
YamlSeq list = (YamlSeq) here;
if (index != -1) {
here = list.get(index);
} else {
throw new IndexOutOfBoundsException(
代码示例来源:origin: org.geotools/gt-ysld
/**
* Yaml mapping.
*
* @param obj Wrapped {@link List}
* @throws IllegalArgumentException {@link List} is required
*/
public YamlSeq(Object obj) {
super(cast(obj));
}
代码示例来源:origin: geotools/geotools
@Test
public void testEmptyColorMap() throws Exception {
StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
StyledLayerDescriptor sld = sld(styleFactory.createRasterSymbolizer());
StringWriter out = new StringWriter();
Ysld.encode(sld, out);
YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString()));
YamlMap symbMap =
obj.seq("feature-styles")
.map(0)
.seq("rules")
.map(0)
.seq("symbolizers")
.map(0)
.map("raster");
assertThat(symbMap, not(yHasEntry("color-map")));
}
代码示例来源:origin: geotools/geotools
@Test
public void testRasterWithThreeColorGradient() throws Exception {
// <UserStyle>
// <Title>SLD Cook Book: Three color gradient</Title>
// <FeatureTypeStyle>
// <Rule>
// <RasterSymbolizer>
// <ColorMap>
// <ColorMapEntry color="#0000FF" quantity="150" />
// <ColorMapEntry color="#FFFF00" quantity="200" />
// <ColorMapEntry color="#FF0000" quantity="250" />
// </ColorMap>
// </RasterSymbolizer>
// </Rule>
// </FeatureTypeStyle>
// </UserStyle>
YamlMap obj = transform("raster", "three-color-gradient.sld");
YamlMap raster =
obj.seq("feature-styles")
.map(0)
.seq("rules")
.map(0)
.seq("symbolizers")
.map(0)
.map("raster");
assertEquals("(#0000FF,,150,)", raster.map("color-map").seq("entries").str(0));
assertEquals("(#FFFF00,,200,)", raster.map("color-map").seq("entries").str(1));
assertEquals("(#FF0000,,250,)", raster.map("color-map").seq("entries").str(2));
}
内容来源于网络,如有侵权,请联系作者删除!