private WMSMapContent createWMSMap(Envelope bounds) throws Exception { WMSMapContent map = new WMSMapContent(); int w = 400; int h = (int) Math.round((bounds.getHeight() * w) / bounds.getWidth()); map.setMapWidth(w); map.setMapHeight(h); map.setBgColor(BG_COLOR); map.setTransparent(true); addRasterToMap(map, MockData.TASMANIA_DEM); map.getViewport().setBounds(new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84)); return map; }
private WMSMapContent createMapContent(ReferencedEnvelope mapBounds, Rectangle renderingArea, Layer... layers) throws Exception { GetMapRequest mapRequest = createGetMapRequest(mapBounds, renderingArea); WMSMapContent map = new WMSMapContent(mapRequest); map.getViewport().setBounds(mapBounds); if (layers != null) { for (Layer l : layers) { map.addLayer(l); } } map.setMapWidth(renderingArea.width); map.setMapHeight(renderingArea.height); return map; }
WMSMapContent subContext = new WMSMapContent(); subContext.addLayer(mapLayer); subContext.setRequest(mapContent.getRequest()); subContext.setMapHeight(mapContent.getMapHeight()); subContext.setMapWidth(mapContent.getMapWidth()); subContext.getViewport().setBounds(mapContent.getRenderingArea()); subContext.setBgColor(mapContent.getBgColor()); subContext.setBuffer(mapContent.getBuffer()); subContext.setContactInformation(mapContent.getContactInformation()); subContext.setKeywords(mapContent.getKeywords()); subContext.setAbstract(mapContent.getAbstract()); subContext.setTransparent(true); imageMap = pngProducer.produceMap(subContext); } finally { subContext.dispose();
private List<String> styleNames(WMSMapContent mapContent) { if (mapContent.layers().size() != 1 || mapContent.getRequest() == null) return Collections.emptyList(); MapLayerInfo info = mapContent.getRequest().getLayers().get(0); return info.getOtherStyleNames(); }
public static double getMapScale( WMSMapContent mapContent, final ReferencedEnvelope renderingArea) { final double mapScale; try { mapScale = RendererUtilities.calculateScale( renderingArea, mapContent.getMapWidth(), mapContent.getMapHeight(), null); } catch (TransformException | FactoryException e) { throw Throwables.propagate(e); } return mapScale; }
public WMSMapContent(WMSMapContent other, boolean copyLayers) { this.mapWidth = other.mapWidth; this.mapHeight = other.mapHeight; this.bgColor = other.bgColor; this.transparent = other.transparent; this.tileSize = other.tileSize; this.angle = other.angle; this.callbacks = new ArrayList<>(other.callbacks); this.buffer = other.buffer; this.icm = other.icm; this.request = other.request; if (copyLayers) { this.layers().addAll(other.layers()); } this.getViewport().setBounds(other.getViewport().getBounds()); }
tileContext = new WMSMapContent(); tileContext.setRequest(metaTileContext.getRequest()); tileContext.setBgColor(metaTileContext.getBgColor()); tileContext.setMapWidth(tileDim.width); tileContext.setMapHeight(tileDim.height); tileContext.setPalette(metaTileContext.getPalette()); tileContext.setTransparent(tileContext.isTransparent()); long[][] tileIndexes = getTilesGridPositions(); BoundingBox tileBounds = gridSubset.boundsFromIndex(tileIndexes[tileIdx]); ReferencedEnvelope tilebbox = new ReferencedEnvelope( metaTileContext.getCoordinateReferenceSystem()); tilebbox.init(tileBounds.getMinX(), tileBounds.getMaxX(), tileBounds.getMinY(), tileBounds.getMaxY()); tileContext.getViewport().setBounds(tilebbox);
WMSMapContent mc = new WMSMapContent(getMap); try { mc.setTransparent(true); mc.setBuffer(params.getBuffer()); mc.getViewport().setBounds(new ReferencedEnvelope(getMap.getBbox(), getMap.getCrs())); mc.setMapWidth(getMap.getWidth()); mc.setMapHeight(getMap.getHeight()); FeatureLayer layer = getLayer(params, style); mc.addLayer(layer); mc.getViewport().setBounds(new ReferencedEnvelope(targetModelSpace, getMap.getCrs())); mc.setMapWidth(paintAreaSize); mc.setMapHeight(paintAreaSize); mc.dispose();
maxFilters = DefaultWebMapService.getMaxFilterRules(); transparent = mapContent.isTransparent(); buffer = mapContent.getBuffer(); angle = mapContent.getAngle(); mapWidth = mapContent.getMapWidth(); mapHeight = mapContent.getMapHeight(); bgColor = mapContent.getBgColor(); palette = mapContent.getPalette(); renderScaleMethodAccurate = StreamingRenderer.SCALE_ACCURATE.equals(mapContent.getRendererScaleMethod()); wmsIterpolationOrdinal = wms.getInterpolation().ordinal(); maxErrors = wms.getMaxRenderingErrors(); this.style = style; envelope = mapContent.getRenderingArea(); final GetMapRequest request = mapContent.getRequest(); final Object timeoutOption = request.getFormatOptions().get("timeout"); int localMaxRenderTime = 0;
private void initRenderer(final SimpleFeatureType type) { currentRenderer = new DistributedRenderMapOutputFormat(options); final WMSMapContent mapContent = new WMSMapContent(); final GetMapRequest request = new GetMapRequest(); mapContent.setBgColor(options.getBgColor()); request.setBgColor(options.getBgColor()); mapContent.setPalette(options.getPalette()); request.setPalette(options.getPalette()); mapContent.setAngle(options.getAngle()); request.setAngle(options.getAngle()); mapContent.setBuffer(options.getBuffer()); request.setBuffer(options.getBuffer()); mapContent.setMapWidth(options.getMapWidth()); request.setWidth(options.getMapWidth()); mapContent.setMapHeight(options.getMapHeight()); request.setHeight(options.getMapHeight()); mapContent.setTransparent(options.isTransparent()); request.setTransparent(options.isTransparent()); mapContent.setViewport(new MapViewport(options.getEnvelope())); request.setBbox(options.getEnvelope()); request.setInterpolations(options.getInterpolations()); mapContent.setRequest(request); queue = new Queue<>(); mapContent.addLayer( new FeatureLayer(new AsyncQueueFeatureCollection(type, queue), options.getStyle()));
private double getScaleDenominator(GetMapRequest request) { final Envelope envelope = request.getBbox(); final CoordinateReferenceSystem mapcrs = request.getCrs(); WMSMapContent mapContent = new WMSMapContent(request); if (mapcrs != null) { mapContent.getViewport().setBounds(new ReferencedEnvelope(envelope, mapcrs)); } else { mapContent .getViewport() .setBounds(new ReferencedEnvelope(envelope, DefaultGeographicCRS.WGS84)); } mapContent.setMapWidth(request.getWidth()); mapContent.setMapHeight(request.getHeight()); mapContent.setAngle(request.getAngle()); return mapContent.getScaleDenominator(true); }
public KmlEncodingContext(WMSMapContent mapContent, WMS wms, boolean kmz) { this.mapContent = fixViewport(mapContent); this.request = mapContent.getRequest(); this.wms = wms; this.mode = computeModeOption(request.getFormatOptions()); double width = mapContent.getMapWidth(); double height = mapContent.getMapHeight(); ReferencedEnvelope bbox = mapContent.getViewport().getBounds(); double bbox_width = bbox.getWidth(); double bbox_height = bbox.getHeight(); height = width / ratio; int h = (int) Math.ceil(height); mapContent.setMapHeight(h); mapContent.getRequest().setHeight(h); } else { width = height * ratio; int w = (int) Math.ceil(width); mapContent.setMapWidth(w); mapContent.getRequest().setWidth(w);
@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); }
@Override public WebMap produceMap(final WMSMapContent mapContent) throws ServiceException, IOException { checkNotNull(mapContent); checkNotNull(mapContent.getRenderingArea()); checkArgument(mapContent.getMapWidth() > 0); checkArgument(mapContent.getMapHeight() > 0); final ReferencedEnvelope renderingArea = mapContent.getRenderingArea(); int mapWidth = mapContent.getMapWidth(); int mapHeight = mapContent.getMapHeight(); Rectangle paintArea = new Rectangle(mapWidth, mapHeight); if (this.tileBuilderFactory.shouldOversampleScale()) { for (Layer layer : mapContent.layers()) { int buffer = VectorMapRenderUtils.getComputedBuffer( mapContent.getBuffer(), VectorMapRenderUtils.getFeatureStyles( layer,
@Test public void testSimpleInternal() throws Exception { WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BASIC_POLYGONS)); map.addLayer(createMapLayer(MockData.BASIC_POLYGONS)); Document document; try { // print(document); document = getRSSResponse(map, GeoRSSTransformerBase.GeometryEncoding.SIMPLE); } finally { map.dispose(); } Element element = document.getDocumentElement(); assertEquals("rss", element.getNodeName()); NodeList entries = element.getElementsByTagName("item"); int n = getFeatureSource(MockData.BASIC_POLYGONS).getCount(Query.ALL); assertEquals(n, entries.getLength()); for (int i = 0; i < entries.getLength(); i++) { Element entry = (Element) entries.item(i); assertEquals(1, entry.getElementsByTagName("georss:polygon").getLength()); } }
double scaleDenominator = mapContent.getScaleDenominator(true); Layer layer = mapContent.layers().get(layerIndex); FeatureType featureType = layer.getFeatureSource().getSchema(); Style style = layer.getStyle(); final int mapWidth = mapContent.getMapWidth(); final int mapHeight = mapContent.getMapHeight(); final ReferencedEnvelope mapEnvelope = getEastNorthEnvelope(mapContent.getRenderingArea()); final CoordinateReferenceSystem mapCRS = mapEnvelope.getCoordinateReferenceSystem(); final Rectangle mapRasterArea = new Rectangle(0, 0, mapWidth, mapHeight); final boolean transparent = mapContent.isTransparent() && isTransparencySupported(); Color bgColor = mapContent.getBgColor(); } else { LayerInfo.WMSInterpolation byLayerInterpolation = null; if (mapContent.getRequest().getLayers().size() > layerIndex) { LayerInfo layerInfo = mapContent.getRequest().getLayers().get(layerIndex).getLayerInfo(); byLayerInterpolation = getConfiguredLayerInterpolation(layerInfo); if (mapContent.getTileSize() != -1) { tileSizeX = tileSizeY = mapContent.getTileSize(); } else if (mapWidth < MAX_TILE_SIZE && mapHeight < MAX_TILE_SIZE) { tileSizeX = mapWidth; .layers() .get(0)
mapContent.getViewport().setBounds(key.getMetaTileEnvelope()); mapContent.setMapWidth(key.getTileSize() * key.getMetaFactor()); mapContent.setMapHeight(key.getTileSize() * key.getMetaFactor()); mapContent.setTileSize(key.getTileSize()); EnvFunction.setLocalValue("wms_bbox", mapContent.getViewport().getBounds()); EnvFunction.setLocalValue("wms_width", mapContent.getMapWidth()); EnvFunction.setLocalValue("wms_height", mapContent.getMapHeight());
WMSMapContent mapContent = ((PDFMap) value).getContext(); final int width = mapContent.getMapWidth(); final int height = mapContent.getMapHeight(); if (!mapContent.isTransparent()) { graphic.setColor(mapContent.getBgColor()); graphic.fillRect(0, 0, width, height); } else { mapContent.getBgColor().getRed(), mapContent.getBgColor().getGreen(), mapContent.getBgColor().getBlue(), 0); graphic.setBackground(mapContent.getBgColor()); graphic.setColor(c); graphic.fillRect(0, 0, width, height); rendererParams.put("renderingBuffer", new Integer(mapContent.getBuffer())); mapContent.getRendererScaleMethod()); Envelope dataArea = mapContent.getRenderingArea(); graphic, paintArea, mapContent.getRenderingArea(), mapContent.getRenderingTransform());
public static void setupEnvironmentVariables(WMSMapContent mapContent) { // setup some SLD variable substitution environment used by rendering transformations EnvFunction.setLocalValue("wms_bbox", mapContent.getRenderingArea()); EnvFunction.setLocalValue( "wms_crs", mapContent.getRenderingArea().getCoordinateReferenceSystem()); EnvFunction.setLocalValue("wms_srs", mapContent.getRequest().getSRS()); EnvFunction.setLocalValue("wms_width", mapContent.getMapWidth()); EnvFunction.setLocalValue("wms_height", mapContent.getMapHeight()); try { double scaleDenominator = mapContent.getScaleDenominator(true); EnvFunction.setLocalValue("wms_scale_denominator", scaleDenominator); } catch (Exception e) { LOGGER.log( Level.SEVERE, "Failed to compute the scale denominator, wms_scale_denominator env variable is unset", e); } } }
@Test public void testChannelDescription() throws Exception { WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BASIC_POLYGONS)); map.addLayer(createMapLayer(MockData.BASIC_POLYGONS)); map.layers().get(0).getUserData().put("abstract", "Test Abstract"); Document document; try { document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose(); } Element element = document.getDocumentElement(); assertEquals("rss", element.getNodeName()); Element channel = (Element) element.getElementsByTagName("channel").item(0); NodeList description = channel.getElementsByTagName("description"); assertEquals("Test Abstract", description.item(0).getChildNodes().item(0).getNodeValue()); }