private GetMap createGetMap( List<LayerRef> layers, List<StyleRef> styles, ICRS crs, Envelope envelope, Output output, Map<String, String> parameterMap, Map<String, List<?>> dimensions ) { int width = output.width; int height = output.height; String format = output.format; boolean transparent = output.transparent; Color color = output.bgcolor; return new GetMap( layers, styles, width, height, envelope, crs, format, transparent, color, parameterMap, dimensions ); }
@Override public Envelope getEnvelope() { return gm.getBoundingBox(); }
private GetFeatureInfo createGetFeatureInfo( GetMap getMap, List<String> queryLayers, int i, int j, Output output, String exceptions ) throws OWSException { HashMap<String, String> parameterMap = new HashMap<String, String>(); if ( exceptions != null ) parameterMap.put( "EXCEPTIONS", exceptions ); return new GetFeatureInfo( getMap.getLayers(), getMap.getStyles(), queryLayers, getMap.getWidth(), getMap.getHeight(), i, j, getMap.getBoundingBox(), getMap.getCoordinateSystem(), output.featureCount, output.infoFormat, parameterMap, getMap.getDimensions() ); }
private LinkedList<String> doGetMap( GetMap getMap, Map<String, String> map, Version version, OutputStream stream ) throws OWSException, IOException { checkGetMap( version, getMap ); RenderingInfo info = new RenderingInfo( getMap.getFormat(), getMap.getWidth(), getMap.getHeight(), getMap.getTransparent(), getMap.getBgColor(), getMap.getBoundingBox(), getMap.getPixelSize(), map, imageSerializers.get( getMap.getFormat() ) ); RenderContext ctx = ouputFormatProvider.getRenderers( info, stream ); LinkedList<String> headers = new LinkedList<String>(); service.getMap( getMap, headers, ctx ); ctx.close(); return headers; }
private LayerQuery buildQuery( StyleRef style, LayerRef lr, MapOptionsMaps options, List<MapOptions> mapOptions, OperatorFilter f, org.deegree.protocol.wms.ops.GetMap gm ) { for ( org.deegree.layer.Layer l : Themes.getAllLayers( themeMap.get( lr.getName() ) ) ) { insertMissingOptions( l.getMetadata().getName(), options, l.getMetadata().getMapOptions(), defaultLayerOptions ); mapOptions.add( options.get( l.getMetadata().getName() ) ); } LayerQuery query = new LayerQuery( gm.getBoundingBox(), gm.getWidth(), gm.getHeight(), style, f, gm.getParameterMap(), gm.getDimensions(), gm.getPixelSize(), options, gm.getQueryBox() ); return query; }
/** * Checks whether the given {@link GetMap} request can be processed with regard to the configured limits on image * size and layer count. * * @param request * request, must not be <code>null</code> * @param config * WMS config, must not be <code>null</code> * @throws OWSException * if the request can not be processed */ public void checkRequestedSizeAndLayerCount( final GetMap request, final DeegreeWMS config ) throws OWSException { checkWidth( request.getWidth(), toIntegerNullSafe( config.getMaxWidth() ) ); checkHeight( request.getHeight(), toIntegerNullSafe( config.getMaxHeight() ) ); int layerCount = request.getLayers() != null ? request.getLayers().size() : 0; checkLayerCount( layerCount, toIntegerNullSafe( config.getLayerLimit() ) ); }
BufferedImage getLegend( GetLegendGraphic req ) { Legends renderer = new Legends( req.getLegendOptions() ); Style style = findLegendStyle( req.getLayer(), req.getStyle() ); Pair<Integer, Integer> size; if ( renderer.getLegendOptions().isDefault() ) { size = getLegendSize( style ); } else { size = renderer.getLegendSize( style ); } if ( req.getWidth() == -1 ) { req.setWidth( size.first ); } if ( req.getHeight() == -1 ) { req.setHeight( size.second ); } boolean originalSize = req.getWidth() == size.first && req.getHeight() == size.second && renderer.getLegendOptions().isDefault(); HashMap<String, BufferedImage> legendMap = legends.get( style ); if ( originalSize && legendMap != null && legendMap.get( req.getFormat() ) != null ) { return legendMap.get( req.getFormat() ); } if ( legendMap == null ) { legendMap = new HashMap<String, BufferedImage>(); legends.put( style, legendMap ); } return buildLegend( req, renderer, style, originalSize, legendMap ); }
private void getFeatureInfo( Map<String, String> map, final HttpResponseBuffer response, Version version ) throws OWSException, IOException, MissingDimensionValue, InvalidDimensionValue { org.deegree.protocol.wms.ops.GetFeatureInfo fi = new org.deegree.protocol.wms.ops.GetFeatureInfo( map, version ); doGetFeatureInfo( map, response, version, fi ); }
/** * @param req * should be a GetMap or GetLegendGraphic * @return an empty image conforming to the request parameters */ public static BufferedImage prepareImage( Object req ) { String format = null; int width = 0, height = 0; Color bgcolor = null; boolean transparent = false; if ( req instanceof GetLegendGraphic ) { GetLegendGraphic glg = (GetLegendGraphic) req; format = glg.getFormat(); width = glg.getWidth(); height = glg.getHeight(); transparent = true; } else { return null; } return ImageUtils.prepareImage( format, width, height, transparent, bgcolor ); }
private AttachmentPart createAttachment( GetMap getMap, ByteArrayOutputStream stream, SOAPMessage message, String contentId ) { DataSource ds = new ByteArrayDataSource( stream.toByteArray() ); DataHandler dataHandler = new DataHandler( ds ); AttachmentPart attachmentPart = message.createAttachmentPart( dataHandler ); attachmentPart.setContentId( contentId ); attachmentPart.setContentType( getMap.getFormat() ); return attachmentPart; }
private void getLegendGraphic( Map<String, String> map, HttpResponseBuffer response ) throws OWSException, IOException { GetLegendGraphic glg = new GetLegendGraphic( map ); if ( !supportedImageFormats.contains( glg.getFormat() ) ) { throw new OWSException( get( "WMS.UNSUPPORTED_IMAGE_FORMAT", glg.getFormat() ), OWSException.INVALID_FORMAT ); } BufferedImage img = service.getLegend( glg ); sendImage( img, response, glg.getFormat() ); }
/** * @param map * @param version * @param service * @throws OWSException */ public GetFeatureInfo( Map<String, String> map, Version version ) throws OWSException { if ( version.equals( VERSION_111 ) ) { parse111( map ); } if ( version.equals( VERSION_130 ) ) { parse130( map ); } parameterMap.putAll( map ); scale = RenderHelper.calcScaleWMS130( width, height, bbox, crs, DEFAULT_PIXEL_SIZE ); }
/** * @param in * @param service * @param gm * filters will be added to this GetMap instance * @return a list of layers parsed from SLD * @throws XMLStreamException * @throws OWSException * @throws ParseException */ @Deprecated public static Triple<LinkedList<LayerRef>, LinkedList<StyleRef>, LinkedList<OperatorFilter>> parse( XMLStreamReader in, RequestBase gm ) throws XMLStreamException, OWSException, ParseException { StylesContainer styleInformations = parse( in ); for ( Pair<String, List<?>> dimension : styleInformations.getDimensions() ) { gm.addDimensionValue( dimension.first, dimension.second ); } LinkedList<LayerRef> layerRefs = new LinkedList<LayerRef>(); LinkedList<StyleRef> styleRefs = new LinkedList<StyleRef>(); LinkedList<OperatorFilter> filters = new LinkedList<OperatorFilter>(); List<StyleContainer> styles = styleInformations.getStyles(); for ( StyleContainer styleInformation : styles ) { layerRefs.add( styleInformation.getLayerRef() ); styleRefs.add( styleInformation.getStyleRef() ); filters.add( styleInformation.getFilter() ); } return new Triple<LinkedList<LayerRef>, LinkedList<StyleRef>, LinkedList<OperatorFilter>>( layerRefs, styleRefs, filters ); }
private void parse111( Map<String, String> map ) throws OWSException { double[] vals = handleCommon( map ); String c = map.get( "SRS" ); if ( c == null || c.trim().isEmpty() ) { throw new OWSException( "The SRS parameter is missing.", OWSException.MISSING_PARAMETER_VALUE ); } crs = GetMap.getCRS111( c ); bbox = fac.createEnvelope( new double[] { vals[0], vals[1] }, new double[] { vals[2], vals[3] }, crs ); String xs = map.get( "X" ); if ( xs == null ) { throw new OWSException( "The X parameter is missing.", MISSING_PARAMETER_VALUE ); } try { x = parseInt( xs ); } catch ( NumberFormatException e ) { throw new OWSException( "The value " + xs + " is not valid for X.", INVALID_PARAMETER_VALUE ); } String ys = map.get( "Y" ); if ( ys == null ) { throw new OWSException( "The Y parameter is missing.", MISSING_PARAMETER_VALUE ); } try { y = parseInt( ys ); } catch ( NumberFormatException e ) { throw new OWSException( "The value " + ys + " is not valid for Y.", INVALID_PARAMETER_VALUE ); } }
private void parse130( Map<String, String> map ) throws OWSException { double[] vals = handleCommon( map ); bbox = GetMap.getCRSAndEnvelope130( c, vals ); crs = bbox.getCoordinateSystem();
/** * @param fis * @return an application schema object */ public List<FeatureType> getSchema( GetFeatureInfoSchema fis ) { List<FeatureType> list = new LinkedList<FeatureType>(); for ( String l : fis.getLayers() ) { getFeatureTypes( list, l ); } return list; }
public GetFeatureInfo( List<LayerRef> layers, List<StyleRef> styles, List<String> queryLayers, int width, int height, int x, int y, Envelope envelope, ICRS crs, int featureCount, String infoFormat, HashMap<String, String> parameterMap, Map<String, List<?>> dimensions ) throws OWSException { this.layers.addAll( layers ); this.styles.addAll( styles ); cleanUpLayers( queryLayers ); this.width = width; this.height = height; this.x = x; this.y = y; this.bbox = envelope; this.crs = crs; this.featureCount = featureCount; this.infoFormat = infoFormat; this.dimensions.putAll( dimensions ); this.parameterMap.putAll( parameterMap ); this.scale = RenderHelper.calcScaleWMS130( width, height, bbox, crs, DEFAULT_PIXEL_SIZE ); }
protected void getMap( Map<String, String> map, HttpResponseBuffer response, Version version ) throws OWSException, IOException, MissingDimensionValue, InvalidDimensionValue { org.deegree.protocol.wms.ops.GetMap gm2 = new org.deegree.protocol.wms.ops.GetMap( map, version, service.getExtensions() ); doGetMap( map, response, version, gm2 ); }
private void doGetMap( Map<String, String> map, HttpResponseBuffer response, Version version, GetMap gm ) throws OWSException, IOException { LinkedList<String> headers = doGetMap( gm, map, version, response.getOutputStream() ); response.setContentType( gm.getFormat() ); addHeaders( response, headers ); }
private static Pair<SimpleRaster, String> getMapAsSimpleRaster( WMSClient client, List<String> layers, int width, int height, Envelope bbox, ICRS srs, String format, boolean transparent, boolean errorsInImage, int timeout ) throws IOException { GetMap gm = new GetMap( layers, width, height, bbox, srs, format, transparent ); Pair<BufferedImage, String> imageResponse = client.getMap( gm, null, timeout, errorsInImage ); Pair<SimpleRaster, String> response = new Pair<SimpleRaster, String>(); if ( imageResponse.first != null ) { BufferedImage img = imageResponse.first; RasterData rasterData = RasterFactory.rasterDataFromImage( img ); RasterGeoReference rasterEnv = RasterGeoReference.create( OriginLocation.OUTER, bbox, img.getWidth(), img.getHeight() ); SimpleRaster raster = new SimpleRaster( rasterData, bbox, rasterEnv, null ); response.first = raster; } else { response.second = imageResponse.second; } return response; }