public GetMapRequest createRequest() { GetMapRequest request = new GetMapRequest(); return request; } }
@SuppressWarnings("unchecked") @Override public GetMapRequest createRequest() throws Exception { GetMapRequest request = new GetMapRequest(); HttpServletRequest httpRequest = LocalHttpServletRequest.get(); if (httpRequest != null) { request.setRequestCharset(httpRequest.getCharacterEncoding()); request.setGet("GET".equalsIgnoreCase(httpRequest.getMethod())); List<String> headerNames = (List<String>) EnumerationUtils.toList(httpRequest.getHeaderNames()); for (String headerName : headerNames) { request.putHttpRequestHeader(headerName, httpRequest.getHeader(headerName)); } } return request; }
@Test public void testExpandRequestVariable() throws Exception { // setup environment Request request = new Request(); Map kvp = new CaseInsensitiveMap(new HashMap()); kvp.put("time", "2008-10-31T00:00:00.000Z"); request.setRawKvp(kvp); Dispatcher.REQUEST.set(request); TextDecoration decoration = new TextDecoration(); Map<String, String> options = new HashMap<>(); options.put( "message", "<#setting datetime_format=\"yyyy-MM-dd'T'HH:mm:ss.SSSX\">\n" + "<#setting locale=\"en_US\">\n" + "<#setting time_zone=\"GMT\">" + "<#if time??>\n" + "${time?datetime?string[\"dd.MM.yyyy\"]}" + "</#if>"); decoration.loadOptions(options); GetMapRequest getMap = new GetMapRequest(); WMSMapContent wmsMapContent = new WMSMapContent(getMap); String message = decoration.evaluateMessage(wmsMapContent); assertEquals("31.10.2008", message); } }
@Test public void testWMSReflect() throws Exception { GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); callback.operationDispatched(new Request(), op("reflect", "WMS", "1.1.1", gm)); assertEquals("acme:foo", data.getResources().get(0)); }
@Test public void testTimeDimension() throws Exception { MapLayerInfo mapLayerInfo = new MapLayerInfo(getCatalog().getLayerByName(WATTEMP_TIME.getLocalPart())); final GridCoverage2DReader reader = (GridCoverage2DReader) mapLayerInfo.getCoverageReader(); GetMapRequest req = new GetMapRequest(); req.setRawKvp(new HashMap<String, String>()); req.getRawKvp() .put( "DIM_" + CustomFormat.CUSTOM_DIMENSION_NAME, "2001-05-01T00:00:00.000Z, 2001-05-02T00:00:00.000Z"); GeneralParameterValue[] readParam = wms.getWMSReadParameters( req, mapLayerInfo, Filter.INCLUDE, null, null, reader, false); @SuppressWarnings("unchecked") ParameterValue<List<Date>> val = (ParameterValue<List<Date>>) readParam[readParam.length - 1]; assertEquals(2, val.getValue().size()); assertEquals(DF.parse("2001-05-01 00:00:00"), val.getValue().get(0)); assertEquals(DF.parse("2001-05-02 00:00:00"), val.getValue().get(1)); }
/** * See GEOS-5003 */ public void testNullsInDimensionAndTimeParameters() throws Exception { TileLayerInfoUtil.updateAcceptAllFloatParameterFilter(tileLayerInfo, "ELEVATION", true); TileLayerInfoUtil.updateAcceptAllRegExParameterFilter(tileLayerInfo, "TIME", true); tileLayer = new GeoServerTileLayer(layer, gridSetBroker, tileLayerInfo); GetMapRequest request = new GetMapRequest(); @SuppressWarnings("unchecked") Map<String, String> rawKvp = new CaseInsensitiveMap(new HashMap<String, String>()); request.setRawKvp(rawKvp); StringBuilder target = new StringBuilder(); boolean cachingPossible; request.setElevation(Arrays.asList((Object) null)); cachingPossible = mediator.isCachingPossible(tileLayer, request, target); assertTrue(cachingPossible); assertEquals(0, target.length()); request.setElevation(Collections.emptyList()); request.setTime(Arrays.asList((Object) null)); cachingPossible = mediator.isCachingPossible(tileLayer, request, target); assertTrue(cachingPossible); assertEquals(0, target.length()); }
@Test public void testWMSGetMap() throws Exception { GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(100,110,70,80); CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326"); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox(new ReferencedEnvelope(env,crs).toBounds(logCrs), data.getBbox(), 0.1); }
@Test public void testWMSGetMapDifferentCrs() throws Exception { //xMin,yMin 5988504.35,851278.90 : xMax,yMax 7585113.55,1950872.01 //xMin,yMin -95.1193,42.2802 : xMax,yMax -71.295,53.73 GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(5988504.35, 7585113.55, 851278.90, 1950872.01); CoordinateReferenceSystem crs = CRS.decode("EPSG:3348", true); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326", false); BoundingBox bbox = new ReferencedEnvelope(42.2802, 53.73, -95.1193, -71.295, logCrs); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox(bbox, data.getBbox(), 0.1); }
@Test public void testCustomDepthIntervalDimension() throws Exception { MapLayerInfo mapLayerInfo = new MapLayerInfo(getCatalog().getLayerByName(WATTEMP_DEPTH.getLocalPart())); final GridCoverage2DReader reader = (GridCoverage2DReader) mapLayerInfo.getCoverageReader(); GetMapRequest req = new GetMapRequest(); req.setRawKvp(new HashMap<String, String>()); req.getRawKvp().put("DIM_" + CustomFormat.CUSTOM_DIMENSION_NAME, "10/50"); GeneralParameterValue[] readParam = wms.getWMSReadParameters( req, mapLayerInfo, Filter.INCLUDE, null, null, reader, false); @SuppressWarnings("unchecked") ParameterValue<List<NumberRange>> val = (ParameterValue<List<NumberRange>>) readParam[readParam.length - 1]; assertEquals(new NumberRange<Double>(Double.class, 10d, 50d), val.getValue().get(0)); }
@Test public void testWMSGetMap() throws Exception { GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(100, 110, 70, 80); CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326"); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox( new ReferencedEnvelope(env, crs).toBounds(logCrs), data.getBbox(), 0.1); }
@Test public void testCustomDepthListDimension() throws Exception { MapLayerInfo mapLayerInfo = new MapLayerInfo(getCatalog().getLayerByName(WATTEMP_DEPTH.getLocalPart())); final GridCoverage2DReader reader = (GridCoverage2DReader) mapLayerInfo.getCoverageReader(); GetMapRequest req = new GetMapRequest(); req.setRawKvp(new HashMap<String, String>()); req.getRawKvp().put("DIM_" + CustomFormat.CUSTOM_DIMENSION_NAME, "10,50"); GeneralParameterValue[] readParam = wms.getWMSReadParameters( req, mapLayerInfo, Filter.INCLUDE, null, null, reader, false); @SuppressWarnings("unchecked") ParameterValue<List<Double>> val = (ParameterValue<List<Double>>) readParam[readParam.length - 1]; assertEquals(10, (Double) val.getValue().get(0), 1E-6); assertEquals(50, (Double) val.getValue().get(1), 1E-6); } }
@Test public void testWMSGetMapDifferentCrs() throws Exception { // xMin,yMin 5988504.35,851278.90 : xMax,yMax 7585113.55,1950872.01 // xMin,yMin -95.1193,42.2802 : xMax,yMax -71.295,53.73 GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(5988504.35, 7585113.55, 851278.90, 1950872.01); CoordinateReferenceSystem crs = CRS.decode("EPSG:3348", true); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326", false); BoundingBox bbox = new ReferencedEnvelope(42.2802, 53.73, -95.1193, -71.295, logCrs); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox(bbox, data.getBbox(), 0.1); }
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; }
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; }
@Before public void setUp() { GetMapRequest request = new GetMapRequest(); request.setFormat("image/png"); this.map = new WMSMapContent(); this.map.setMapWidth(256); this.map.setMapHeight(256); this.map.setTransparent(true); this.map.setRequest(request); }
@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); }
@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); }
/** 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()); }
@Test public void testSimpleGetMapQuery() throws Exception { Catalog catalog = getCatalog(); final FeatureSource fs = catalog.getFeatureTypeByName( MockData.BASIC_POLYGONS.getPrefix(), MockData.BASIC_POLYGONS.getLocalPart()) .getFeatureSource(null, null); final Envelope env = fs.getBounds(); LOGGER.info("about to create map ctx for BasicPolygons with bounds " + env); GetMapRequest request = new GetMapRequest(); final WMSMapContent map = new WMSMapContent(); map.getViewport().setBounds(new ReferencedEnvelope(env, DefaultGeographicCRS.WGS84)); map.setMapWidth(300); map.setMapHeight(300); map.setBgColor(Color.red); map.setTransparent(false); map.setRequest(request); StyleInfo styleByName = catalog.getStyleByName("Default"); Style basicStyle = styleByName.getStyle(); map.addLayer(new FeatureLayer(fs, basicStyle)); request.setFormat(getMapFormat()); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); BufferedImage image = (BufferedImage) imageMap.getImage(); imageMap.dispose(); assertNotBlank("testSimpleGetMapQuery", image); }
GetMapRequest request = new GetMapRequest();