本文整理了Java中org.geotools.ysld.parse.ZoomContextFinder.get()
方法的一些代码示例,展示了ZoomContextFinder.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoomContextFinder.get()
方法的具体详情如下:
包路径:org.geotools.ysld.parse.ZoomContextFinder
类名称:ZoomContextFinder
方法名:get
[英]Get a named ZoomContext
[中]获取命名的ZoomContext
代码示例来源:origin: geotools/geotools
/**
* Finds an applicable {@link ZoomContext} based on a name
*
* @param name Name of the ZoomContext.
* @param zCtxtFinders List of finders for the {@link ZoomContext}
* @throws IllegalArgumentException If name is "EPSG:4326", "EPSG:3857", or "EPSG:900913" (These
* names cause ambiguities).
* @return {@link ZoomContext} matching the name.
*/
public static @Nullable ZoomContext getNamedZoomContext(
String name, List<ZoomContextFinder> zCtxtFinders) {
if (name.equalsIgnoreCase("EPSG:4326")) {
throw new IllegalArgumentException(
"Should not use EPSG code to refer to WGS84 zoom levels as it causes ambiguities");
}
if (name.equalsIgnoreCase("EPSG:3857") || name.equalsIgnoreCase("EPSG:900913")) {
throw new IllegalArgumentException(
"Should not use EPSG code to refer to WebMercator zoom levels");
}
for (ZoomContextFinder finder : zCtxtFinders) {
ZoomContext found = finder.get(name);
if (found != null) {
return found;
}
}
return WellKnownZoomContextFinder.getInstance().get(name);
}
代码示例来源:origin: geotools/geotools
@Test
public void testExtendedZoomContext() throws Exception {
StringBuilder builder = new StringBuilder();
builder.append("grid:\n" + " name: SIGMA:957\n");
ZoomContextFinder finder = createMock("finder", ZoomContextFinder.class);
ZoomContext zctxt = createMock("zctxt", ZoomContext.class);
expect(finder.get("SIGMA:957")).andStubReturn(zctxt);
replay(finder, zctxt);
List<MarkedYAMLException> errors =
validate(builder.toString(), Collections.singletonList(finder));
assertThat(errors.size(), is(0));
verify(finder, zctxt);
}
代码示例来源:origin: geotools/geotools
@Test
public void testZoomContextEPSG4326IsBad() throws Exception {
StringBuilder builder = new StringBuilder();
builder.append("grid:\n" + " name: EPSG:4326\n");
ZoomContextFinder finder = createMock("finder", ZoomContextFinder.class);
ZoomContext zctxt = createMock("zctxt", ZoomContext.class);
expect(finder.get("EPSG:4326")).andStubReturn(zctxt);
replay(finder, zctxt);
List<MarkedYAMLException> errors =
validate(builder.toString(), Collections.singletonList(finder));
assertThat(errors.size(), is(1));
assertThat(errors.get(0).getProblemMark(), problemOn(2));
verify(finder, zctxt);
}
代码示例来源:origin: geotools/geotools
@Test
public void testWellKnownWithCustomFinder() throws IOException {
String yaml =
"grid:\n"
+ " name: WebMercator\n"
+ "feature-styles: \n"
+ "- name: name\n"
+ " rules:\n"
+ GOOGLE_MERCATOR_TEST_RULES;
ZoomContextFinder finder = createMock(ZoomContextFinder.class);
expect(finder.get("WebMercator")).andReturn(null);
replay(finder);
StyledLayerDescriptor sld = Ysld.parse(yaml, Arrays.asList(finder), (ResourceLocator) null);
doTestForGoogleMercator(
sld); // The additional finder doesn't have a WebMercator context and so should not
// interfere.
verify(finder);
}
代码示例来源: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: 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
ZoomContext zctxt = createMock("zctxt", ZoomContext.class);
expect(finder.get("SIGMA:957")).andStubReturn(zctxt);
代码示例来源:origin: org.geotools/gt-ysld
/**
* Finds an applicable {@link ZoomContext} based on a name
*
* @param name Name of the ZoomContext.
* @param zCtxtFinders List of finders for the {@link ZoomContext}
* @throws IllegalArgumentException If name is "EPSG:4326", "EPSG:3857", or "EPSG:900913" (These
* names cause ambiguities).
* @return {@link ZoomContext} matching the name.
*/
public static @Nullable ZoomContext getNamedZoomContext(
String name, List<ZoomContextFinder> zCtxtFinders) {
if (name.equalsIgnoreCase("EPSG:4326")) {
throw new IllegalArgumentException(
"Should not use EPSG code to refer to WGS84 zoom levels as it causes ambiguities");
}
if (name.equalsIgnoreCase("EPSG:3857") || name.equalsIgnoreCase("EPSG:900913")) {
throw new IllegalArgumentException(
"Should not use EPSG code to refer to WebMercator zoom levels");
}
for (ZoomContextFinder finder : zCtxtFinders) {
ZoomContext found = finder.get(name);
if (found != null) {
return found;
}
}
return WellKnownZoomContextFinder.getInstance().get(name);
}
代码示例来源: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: 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);
}
内容来源于网络,如有侵权,请联系作者删除!