@Test public void testValidKML() throws Exception { GetMapRequest req = createGetMapRequest(MockData.STREAMS); req.setWidth(256); req.setHeight(256);
int w = (int) Math.ceil(width); mapContent.setMapWidth(w); mapContent.getRequest().setWidth(w);
@Test public void testExternalImageSize() throws Exception { GetMapRequest req = createGetMapRequest(MockData.STREAMS); req.setWidth(256); req.setHeight(256); WMSMapContent mapContent = new WMSMapContent(req); mapContent.addLayer(createMapLayer(MockData.STREAMS, "big-local-image")); mapContent .getViewport() .setBounds(new ReferencedEnvelope(-180, 0, -90, 90, DefaultGeographicCRS.WGS84)); mapContent.setMapHeight(256); mapContent.setMapWidth(256); KMLMapOutputFormat of = new KMLMapOutputFormat(getWMS()); KMLMap map = of.produceMap(mapContent); ByteArrayOutputStream bout = new ByteArrayOutputStream(); new KMLEncoder().encode(map.getKml(), bout, null); Document document = dom(new ByteArrayInputStream(bout.toByteArray())); assertEquals("kml", document.getDocumentElement().getNodeName()); assertEquals(1, document.getElementsByTagName("Style").getLength()); XMLAssert.assertXpathExists("//kml:IconStyle/kml:scale", document); XPath xPath = XPathFactory.newInstance().newXPath(); initXPath(xPath); Double scale = (Double) xPath.evaluate( "//kml:IconStyle/kml:scale", document.getDocumentElement(), XPathConstants.NUMBER); assertEquals(42d / 16d, scale, 0.01); }
public GetMapRequest createRequest() { GetMapRequest request; request = new GetMapRequest(); request.setFormat(DummyRasterMapProducer.MIME_TYPE); request.setWidth(512); request.setHeight(256); Envelope envelope = new Envelope(-180, 180, -90, 90); request.setBbox(envelope); request.setSRS("EPSG:4326"); request.setCrs(DefaultGeographicCRS.WGS84); try { request.setStyles(Collections.singletonList(defaultStyle.getStyle())); } catch (IOException e) { throw new RuntimeException("shouldn't happen", e); } request.setRawKvp(new HashMap<String, String>()); request.setBaseUrl("http://example.geoserver.org/geoserver"); return request; }
request.setWidth(256); request.setHeight(256); rawKvp.put("layers", "mockLayer");
protected WMSMapContent createMapContent(double dpi) { GetMapRequest request = new GetMapRequest(); request.setWidth(1000); request.setHeight(1000); request.setRawKvp(new HashMap<String, String>()); if (dpi > 0) { request.getFormatOptions().put("dpi", dpi); } WMSMapContent map = new WMSMapContent(request); map.setMapWidth(request.getWidth()); map.setMapHeight(request.getHeight()); map.getViewport() .setBounds( new ReferencedEnvelope( new Envelope(0, 0.01, 0, 0.01), DefaultGeographicCRS.WGS84)); return map; }
request.setBuffer(options.getBuffer()); mapContent.setMapWidth(options.getMapWidth()); request.setWidth(options.getMapWidth()); mapContent.setMapHeight(options.getMapHeight()); request.setHeight(options.getMapHeight()); new DefaultWebMapService(null).setApplicationContext(null); request.setFormatOptions(formatOptions); request.setWidth(options.getMapWidth()); request.setHeight(options.getMapHeight()); request.setTiled(options.isMetatile());
request.setSRS("EPSG:4326"); request.setWidth(128); request.setHeight(256); assertDispatchMismatch(request, "request does not align to grid"); request.setWidth(256); request.setHeight(128); assertDispatchMismatch(request, "request does not align to grid"); request.setWidth(256); request.setHeight(256); assertDispatchMismatch(request, "request does not align to grid");
@Test public void testWMSGetFeatureInfo() throws Exception { GetFeatureInfoRequest gfi = new GetFeatureInfoRequest(); GetMapRequest gm = new GetMapRequest(); gm.setHeight(330); gm.setWidth(780); Envelope env = new ReferencedEnvelope(-126.81851,-115.818992,44.852958,49.5066,null); CoordinateReferenceSystem crs = CRS.decode("EPSG:4326",true); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326",false); gm.setBbox(env); gm.setCrs(crs); gfi.setGetMapRequest(gm); gfi.setXPixel(260); gfi.setYPixel(63); gfi.setVersion("1.1.1"); gfi.setQueryLayers(Arrays.asList(createMapLayer("foo", "acme"), createMapLayer("bar", "acme"))); callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", gfi)); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); BBoxAsserts.assertEqualsBbox(new ReferencedEnvelope(48.62,48.62,-123.15,-123.15,logCrs),data.getBbox(), 0.01); }
throw new IllegalArgumentException("Please use one of the test CRS's"); request.setWidth(renderingArea.width); request.setHeight(renderingArea.height); request.setRawKvp(new HashMap<String, String>());
WMSMapContent createMapContext(QName layer, String style) throws Exception { // create a map context WMSMapContent mapContent = new WMSMapContent(); mapContent.addLayer(createMapLayer(layer, style)); mapContent.setMapHeight(256); mapContent.setMapWidth(256); GetMapRequest getMapRequest = createGetMapRequest(new QName[] {layer}); getMapRequest.setWidth(256); getMapRequest.setHeight(256); mapContent.setRequest(getMapRequest); mapContent .getViewport() .setBounds(new ReferencedEnvelope(-180, 180, -90, 90, DefaultGeographicCRS.WGS84)); return mapContent; }
@Test public void testWMSGetFeatureInfo() throws Exception { GetFeatureInfoRequest gfi = new GetFeatureInfoRequest(); GetMapRequest gm = new GetMapRequest(); gm.setHeight(330); gm.setWidth(780); Envelope env = new ReferencedEnvelope(-126.81851, -115.818992, 44.852958, 49.5066, null); CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326", false); gm.setBbox(env); gm.setCrs(crs); gfi.setGetMapRequest(gm); gfi.setXPixel(260); gfi.setYPixel(63); gfi.setVersion("1.1.1"); gfi.setQueryLayers( Arrays.asList(createMapLayer("foo", "acme"), createMapLayer("bar", "acme"))); callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", gfi)); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); BBoxAsserts.assertEqualsBbox( new ReferencedEnvelope(48.62, 48.62, -123.15, -123.15, logCrs), data.getBbox(), 0.01); }
throw new IllegalArgumentException("Please use one of the test CRS's"); request.setWidth(renderingArea.width); request.setHeight(renderingArea.height); request.setRawKvp(new HashMap<String, String>());
gm.setWidth(512); Envelope env = new ReferencedEnvelope(3833170.221556,4083455.358596,1841755.690829,2048534.231783,null); CoordinateReferenceSystem crs = CRS.decode("EPSG:3348",true);
gm.setWidth(512); Envelope env = new ReferencedEnvelope(
/** Test hitArea does not overflow out of painted area. */ @Test public void testHitAreaSize() throws Exception { GetFeatureInfoRequest request = new GetFeatureInfoRequest(); GetMapRequest getMapRequest = new GetMapRequest(); List<MapLayerInfo> layers = new ArrayList<>(); layers.add(new MapLayerInfo(getCatalog().getLayerByName(MockData.BRIDGES.getLocalPart()))); getMapRequest.setLayers(layers); getMapRequest.setSRS("EPSG:4326"); getMapRequest.setBbox(new Envelope(0.0001955, 0.0002035, 0.000696, 0.000704)); getMapRequest.setWidth(100); getMapRequest.setHeight(100); getMapRequest.setFormat("image/png"); request.setGetMapRequest(getMapRequest); request.setQueryLayers(layers); // point is almost centered, but on the other side of the middle point request.setXPixel(45); request.setYPixel(45); FeatureInfoRequestParameters params = new FeatureInfoRequestParameters(request); VectorRenderingLayerIdentifier vrli = new VectorRenderingLayerIdentifier(getWMS(), null); assertEquals(0, vrli.identify(params, 10).size()); }
request.setFormat("image/png"); request.setSRS("EPSG:900913"); request.setWidth(256); request.setHeight(256); rawKvp.put("layers", tileLayer.getName());
request.setBbox(bbox); request.setHeight(mapHeight); request.setWidth(mapWidth); request.setSRS("urn:x-ogc:def:crs:EPSG:4326"); request.setFormat("image/png");
@Test public void testGetMapOnByteNodataGrayScale() throws Exception { GetMapRequest request = new GetMapRequest(); CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84; ReferencedEnvelope bbox = new ReferencedEnvelope(new Envelope(145, 146, -43, -41), crs); request.setBbox(bbox); request.setHeight(768); request.setWidth(384); request.setSRS("urn:x-ogc:def:crs:EPSG:4326"); request.setFormat("image/png"); request.setTransparent(true); final WMSMapContent map = new WMSMapContent(request); map.setMapHeight(768); map.setMapWidth(384); map.setBgColor(BG_COLOR); map.setTransparent(true); map.getViewport().setBounds(bbox); addRasterToMap(map, TAZ_BYTE); map.getViewport().setBounds(bbox); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); RenderedOp op = (RenderedOp) imageMap.getImage(); BufferedImage image = op.getAsBufferedImage(); imageMap.dispose(); // check that a pixel in nodata area is transparent assertEquals(0, image.getRaster().getSample(40, 400, 0)); assertEquals(0, image.getRaster().getSample(40, 400, 1)); }