private void writeHeader() throws IOException { // TODO: this does not write out the doctype definition, there should be // a configuration option wether to include it or not. String viewBox = createViewBox(); String header = SVG_HEADER.replaceAll("_viewBox_", viewBox); header = header.replaceAll("_width_", String.valueOf(mapContent.getMapWidth())); header = header.replaceAll("_height_", String.valueOf(mapContent.getMapHeight())); writer.write(header); }
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; }
/** * Returns the transformation going from the map area space to the screen space taking into * account map rotation */ public AffineTransform getRenderingTransform() { Rectangle paintArea = new Rectangle(0, 0, getMapWidth(), getMapHeight()); ReferencedEnvelope dataArea = getViewport().getBounds(); AffineTransform tx; if (getAngle() != 0.0) { tx = new AffineTransform(); tx.translate(paintArea.width / 2, paintArea.height / 2); tx.rotate(Math.toRadians(getAngle())); tx.translate(-paintArea.width / 2, -paintArea.height / 2); tx.concatenate(RendererUtilities.worldToScreenTransform(dataArea, paintArea)); } else { tx = RendererUtilities.worldToScreenTransform(dataArea, paintArea); } return tx; }
/** * Filter given rules, to consider only the rules compatible * with the current scale. * @param rules * @return */ private Rule[] filterRules(Rule[] rules) { List<Rule> result=new ArrayList<Rule>(); for(int count=0;count<rules.length;count++) { Rule rule=rules[count]; double scaleDenominator; try { scaleDenominator = RendererUtilities.calculateScale(mapContent.getRenderingArea(), mapContent.getMapWidth(), mapContent.getMapHeight(),90); //is this rule within scale? if (EncodeHTMLImageMap.isWithInScale(rule,scaleDenominator)) { result.add(rule); } } catch (TransformException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FactoryException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // TODO Auto-generated method stub return result.toArray(new Rule[result.size()]); }
/** * Creates a new HTMLImageMapWriter object. * * @param out stream to encode the layer to * @param config current wms context * @throws ClassCastException * @throws UnsupportedEncodingException */ public HTMLImageMapWriter(OutputStream out, WMSMapContent mapContent) throws UnsupportedEncodingException, ClassCastException { super(out, guessCharset(mapContent)); this.mapContent=mapContent; mapEnv = mapContent.getRenderingArea(); clippingBox=envToGeometry(mapEnv); mapArea=new Rectangle(mapContent.getMapWidth(),mapContent.getMapHeight()); worldToScreen=RendererUtilities.worldToScreenTransform(mapEnv, mapArea); initWriters(); }
public static Query getStyleQuery(Layer layer, WMSMapContent mapContent) throws IOException { final Rectangle screenSize = new Rectangle(mapContent.getMapWidth(), mapContent.getMapHeight()); final double mapScale; try { mapScale = RendererUtilities.calculateScale(renderingArea, mapContent.getMapWidth(), mapContent.getMapHeight(), null); } catch (TransformException | FactoryException e) {
buffer = mapContent.getBuffer(); angle = mapContent.getAngle(); mapWidth = mapContent.getMapWidth(); mapHeight = mapContent.getMapHeight(); bgColor = mapContent.getBgColor();
getViewport().getBounds(), getMapWidth(), getMapHeight(), hints); } catch (Exception e) { throw new ServiceException("Failed to compute accurate scale denominator", e); } else { return RendererUtilities.calculateOGCScale( getViewport().getBounds(), getMapWidth(), hints);
subContext.setRequest(mapContent.getRequest()); subContext.setMapHeight(mapContent.getMapHeight()); subContext.setMapWidth(mapContent.getMapWidth()); subContext.getViewport().setBounds(mapContent.getRenderingArea()); subContext.setBgColor(mapContent.getBgColor());
checkNotNull(mapContent); checkNotNull(mapContent.getRenderingArea()); checkArgument(mapContent.getMapWidth() > 0); checkArgument(mapContent.getMapHeight() > 0); int mapWidth = mapContent.getMapWidth(); int mapHeight = mapContent.getMapHeight(); Rectangle paintArea = new Rectangle(mapWidth, mapHeight);
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); } } }
checkNotNull(mapContent); checkNotNull(mapContent.getRenderingArea()); checkArgument(mapContent.getMapWidth() > 0); checkArgument(mapContent.getMapHeight() > 0); final Rectangle paintArea = new Rectangle(mapContent.getMapWidth(), mapContent.getMapHeight());
throws ServiceException { Rectangle paintArea = new Rectangle(0, 0, mapContent.getMapWidth(), mapContent.getMapHeight());
new Rectangle(mapContent.getMapWidth(), mapContent.getMapHeight()); final double mapScale = getMapScale(mapContent, renderingArea);
double width = mapContent.getMapWidth(); double height = mapContent.getMapHeight(); ReferencedEnvelope bbox = mapContent.getViewport().getBounds();
WMSMapContent mapContent = ((PDFMap) value).getContext(); final int width = mapContent.getMapWidth(); final int height = mapContent.getMapHeight();
width = wmsMap.getMapWidth(); height = wmsMap.getMapHeight(); } else {
EnvFunction.setLocalValue("wms_width", mapContent.getMapWidth()); EnvFunction.setLocalValue("wms_height", mapContent.getMapHeight());
final int mapWidth = mapContent.getMapWidth(); final int mapHeight = mapContent.getMapHeight();