本文整理了Java中org.geotools.ysld.parse.ZoomContext
类的一些代码示例,展示了ZoomContext
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoomContext
类的具体详情如下:
包路径:org.geotools.ysld.parse.ZoomContext
类名称:ZoomContext
[英]Represents a mapping between zoom level and scale.
[中]表示缩放级别和比例之间的映射。
代码示例来源: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
@Test
public void testWGS84Scales() throws Exception {
ZoomContext context = WellKnownZoomContextFinder.getInstance().get("DEFAULT");
for (int i = 0; i < WGS84_SCALE_DENOMS.length; i++) {
assertThat(
context.getScaleDenominator(i), mCloseTo(WGS84_SCALE_DENOMS[i], 0.00000001d));
}
}
代码示例来源:origin: geotools/geotools
@Override
protected void validateParsed(Integer parsed, ScalarEvent evt, YsldValidateContext context) {
if (!context.getZCtxt().isInRange(parsed)) {
context.error(
String.format("Zoom level %d is out of range", parsed), evt.getStartMark());
}
}
}
代码示例来源: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: org.geoserver.community/gs-ysld
@Test
public void testScaleNegativeLevel() throws Exception {
GridSetBroker broker = createMock(GridSetBroker.class);
GridSet set = createMock(GridSet.class);
expect(broker.get("test")).andStubReturn(set);
expect(set.getNumLevels()).andStubReturn(5);
replay(broker, set);
ZoomContextFinder finder = new GWCZoomContextFinder(broker);
ZoomContext zContext = finder.get("test");
double denom = zContext.getScaleDenominator(-1);
assertThat(denom, is(Double.POSITIVE_INFINITY));
verify(broker, set);
}
代码示例来源:origin: geotools/geotools
expect(zctxt.isInRange(0)).andStubReturn(true);
expect(zctxt.isInRange(2)).andStubReturn(true);
expect(zctxt.isInRange(5)).andStubReturn(true);
expect(zctxt.isInRange(-1)).andStubReturn(false);
expect(zctxt.isInRange(6)).andStubReturn(false);
代码示例来源: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.geoserver.community/gs-ysld
@Test
public void testScalePastEnd() throws Exception {
GridSetBroker broker = createMock(GridSetBroker.class);
GridSet set = createMock(GridSet.class);
expect(broker.get("test")).andStubReturn(set);
expect(set.getNumLevels()).andStubReturn(5);
replay(broker, set);
ZoomContextFinder finder = new GWCZoomContextFinder(broker);
ZoomContext zContext = finder.get("test");
double denom = zContext.getScaleDenominator(5);
assertThat(denom, is(0d));
verify(broker, set);
}
代码示例来源:origin: org.geotools/gt-ysld
@Override
protected void validateParsed(Integer parsed, ScalarEvent evt, YsldValidateContext context) {
if (!context.getZCtxt().isInRange(parsed)) {
context.error(
String.format("Zoom level %d is out of range", parsed), evt.getStartMark());
}
}
}
代码示例来源: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;
}
}
内容来源于网络,如有侵权,请联系作者删除!