本文整理了Java中org.geotools.ysld.parse.ZoomContext.getRange()
方法的一些代码示例,展示了ZoomContext.getRange()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoomContext.getRange()
方法的具体详情如下:
包路径:org.geotools.ysld.parse.ZoomContext
类名称:ZoomContext
方法名:getRange
[英]Return a scale range covering the specified zoom level but no others.
[中]返回覆盖指定缩放级别但不覆盖其他缩放级别的缩放范围。
代码示例来源:origin: geotools/geotools
private ScaleRange parseZoom(YamlMap r, YamlParseContext context) {
if (r.has("zoom")) {
ZoomContext zCtxt = getZoomContext(context);
Object value = r.get("zoom");
Tuple t = null;
try {
t = Tuple.of(2).parse(value);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
String.format("Bad zoom value: '%s', must be of form [<min>,<max>]", value),
e);
}
@Nullable Integer min = null;
@Nullable Integer max = null;
if (t.at(0) != null) {
if (!t.strAt(0).equalsIgnoreCase("min")) {
min = Integer.parseInt(t.strAt(0));
}
}
if (t.at(1) != null) {
if (!t.strAt(1).equalsIgnoreCase("max")) {
max = Integer.parseInt(t.strAt(1));
}
}
return zCtxt.getRange(min, max);
} else {
return null;
}
}
代码示例来源:origin: geotools/geotools
@SuppressWarnings("unchecked")
@Test
public void testCustomFinderOverridesWellKnown() throws IOException {
String yaml =
"grid:\n"
+ " name: WebMercator\n"
+ "feature-styles: \n"
+ "- name: name\n"
+ " rules:\n"
+ " - zoom: "
+ tuple(0, 0);
ZoomContextFinder finder = createMock(ZoomContextFinder.class);
ZoomContext context = createMock(ZoomContext.class);
expect(finder.get("WebMercator")).andReturn(context);
expect(context.getRange(0, 0)).andReturn(new ScaleRange(42, 64));
replay(finder, context);
StyledLayerDescriptor sld = Ysld.parse(yaml, Arrays.asList(finder), (ResourceLocator) null);
FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0);
fs.rules().get(0).getMaxScaleDenominator();
assertThat(
(Iterable<Rule>) fs.rules(),
hasItems(
allOf(
Matchers.<Rule>hasProperty(
"maxScaleDenominator", Matchers.closeTo(64, 0.0000001d)),
Matchers.<Rule>hasProperty(
"minScaleDenominator", Matchers.closeTo(42, 0.0000001d)))));
verify(finder, context);
}
代码示例来源:origin: geotools/geotools
@SuppressWarnings("unchecked")
@Test
public void testNamedWithFinder() throws IOException {
String yaml =
"grid:\n"
+ " name: test\n"
+ "feature-styles: \n"
+ "- name: name\n"
+ " rules:\n"
+ " - zoom: "
+ tuple(0, 0);
ZoomContextFinder finder = createMock(ZoomContextFinder.class);
ZoomContext context = createMock(ZoomContext.class);
expect(finder.get("test")).andReturn(context);
expect(context.getRange(0, 0)).andReturn(new ScaleRange(42, 64));
replay(finder, context);
StyledLayerDescriptor sld = Ysld.parse(yaml, Arrays.asList(finder), (ResourceLocator) null);
FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0);
fs.rules().get(0).getMaxScaleDenominator();
assertThat(
(Iterable<Rule>) fs.rules(),
hasItems(
allOf(
Matchers.<Rule>hasProperty(
"maxScaleDenominator", Matchers.closeTo(64, 0.0000001d)),
Matchers.<Rule>hasProperty(
"minScaleDenominator", Matchers.closeTo(42, 0.0000001d)))));
verify(finder, context);
}
代码示例来源:origin: org.geotools/gt-ysld
private ScaleRange parseZoom(YamlMap r, YamlParseContext context) {
if (r.has("zoom")) {
ZoomContext zCtxt = getZoomContext(context);
Object value = r.get("zoom");
Tuple t = null;
try {
t = Tuple.of(2).parse(value);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
String.format("Bad zoom value: '%s', must be of form [<min>,<max>]", value),
e);
}
@Nullable Integer min = null;
@Nullable Integer max = null;
if (t.at(0) != null) {
if (!t.strAt(0).equalsIgnoreCase("min")) {
min = Integer.parseInt(t.strAt(0));
}
}
if (t.at(1) != null) {
if (!t.strAt(1).equalsIgnoreCase("max")) {
max = Integer.parseInt(t.strAt(1));
}
}
return zCtxt.getRange(min, max);
} else {
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!