/** * Checks if the superoverlay is enabled or not * @param request * @return */ boolean computeSuperOverlayEnabled() { Map formatOptions = request.getFormatOptions(); Boolean superoverlay = (Boolean) formatOptions.get("superoverlay"); if (superoverlay == null) { superoverlay = Boolean.FALSE; } return superoverlay; }
private boolean getFormatOptionAsBoolean( final GetMapRequest request, final String formatOptionKey) { if (request.getFormatOptions().get(formatOptionKey) != null) { String formatOptionValue = (String) request.getFormatOptions().get(formatOptionKey); return (!"false".equalsIgnoreCase(formatOptionValue)); } // else key not present return true; }
/** * Returns the superoverlay mode (either specified in the request, or the default one) * @return */ String computeSuperOverlayMode() { String overlayMode = (String) request.getFormatOptions().get("superoverlay_mode"); if(overlayMode != null) { return overlayMode; } overlayMode = (String) request.getFormatOptions().get("overlayMode"); if(overlayMode != null) { return overlayMode; } else { return wms.getKmlSuperoverlayMode(); } }
private int computeKmScore() { int kmScore = wms.getKmScore(); Map fo = request.getFormatOptions(); Object kmScoreObj = fo.get("kmscore"); if (kmScoreObj != null) { kmScore = (Integer) kmScoreObj; } return kmScore; }
/** * Checks if the extended data is enabled or not * @param request * @return */ boolean computeExtendedDataEnabled() { Map formatOptions = request.getFormatOptions(); Boolean extendedData = Converters.convert(formatOptions.get("extendedData"), Boolean.class); if (extendedData == null) { extendedData = Boolean.FALSE; } return extendedData; }
/** * Returns the max rendering time taking into account the server limits and the request options * * @param request * @return */ public int getMaxRenderingTime(GetMapRequest request) { int localMaxRenderingTime = 0; Object timeoutOption = request.getFormatOptions().get("timeout"); if (timeoutOption != null) { try { localMaxRenderingTime = Integer.parseInt(timeoutOption.toString()); } catch (NumberFormatException e) { RenderedImageMapOutputFormat.LOGGER.log( Level.WARNING, "Could not parse format_option \"timeout\": " + timeoutOption, e); } } int maxRenderingTime = getMaxRenderingTime(localMaxRenderingTime); return maxRenderingTime; }
/** * Returns the the kmplacemark value (either specified in the request, or the default one) * * @param mapContent * @return */ boolean computeKmplacemark() { Object kmplacemark = request.getFormatOptions().get("kmplacemark"); if (kmplacemark != null) { return Converters.convert(kmplacemark, Boolean.class); } else { return wms.getKmlPlacemark(); } }
@Override public KmlDecorator getDecorator(Class<? extends Feature> featureClass, KmlEncodingContext context) { // this decorator makes sense only for WMS if(!(context.getService() instanceof WMSInfo)) { return null; } String selfLinks = (String) context.getRequest().getFormatOptions().get("selfLinks"); if (selfLinks != null && selfLinks.equalsIgnoreCase("true") && Placemark.class.isAssignableFrom(featureClass)) { return new PlacemarkSelfLinkDecorator(); } else { return null; } }
/** * Returns the the kmattr value (either specified in the request, or the default one) * * @param mapContent * @return */ boolean computeKMAttr() { Object kmattr = request.getFormatOptions().get("kmattr"); if (kmattr == null) { kmattr = request.getRawKvp().get("kmattr"); } if (kmattr != null) { return Converters.convert(kmattr, Boolean.class); } else { return wms.getKmlKmAttr(); } }
@Override public KmlDecorator getDecorator(Class<? extends Feature> featureClass, KmlEncodingContext context) { // this decorator makes sense only for WMS if(!(context.getService() instanceof WMSInfo)) { return null; } // see if we have to encode a legend GetMapRequest request = context.getRequest(); Boolean legend = (Boolean) request.getFormatOptions().get("legend"); if (legend != null && legend && Document.class.isAssignableFrom(featureClass)) { return new LegendDecorator(); } else { return null; } }
private boolean isExtrudeEnabled(KmlEncodingContext context) { // extrusion applies only to WMS mode if(!(context.getService() instanceof WMSInfo)) { return false; } // were we asked not to perform extrusion? Object foExtrude = context.getRequest().getFormatOptions().get("extrude"); if(foExtrude == null) { // true by default return true; } // be careful, in case someone set extrude to some funny value Boolean extrude = Converters.convert(foExtrude, Boolean.class); return extrude == Boolean.TRUE; }
@Override public KmlDecorator getDecorator(Class<? extends Feature> featureClass, KmlEncodingContext context) { // this decorator makes sense only for WMS if(!(context.getService() instanceof WMSInfo)) { return null; } // we decorate only the feature collection folders if(!(featureClass.equals(Folder.class))) { return null; } // see if we have to encode relative links GetMapRequest request = context.getRequest(); String relLinks = (String) request.getFormatOptions().get("relLinks"); // Add prev/next links if requested if(request.getMaxFeatures() != null && relLinks != null && relLinks.equalsIgnoreCase("true")) { return new FolderRelativeLinksDecorator(); } else { return null; } }
protected boolean isOL3Enabled(WMSMapContent mapContent) { GetMapRequest req = mapContent.getRequest(); // check format options Object enableOL3 = Converters.convert(req.getFormatOptions().get(ENABLE_OL3), Boolean.class); if (enableOL3 == null) { // check system property enableOL3 = GeoServerExtensions.getProperty(ENABLE_OL3); } // enable by default return enableOL3 == null || Converters.convert(enableOL3, Boolean.class); } }
/** @see org.geoserver.wms.GetMapOutputFormat#produceMap(org.geoserver.wms.WMSMapContent) */ public XMLTransformerMap produceMap(WMSMapContent mapContent) throws ServiceException, IOException { AtomGeoRSSTransformer tx = new AtomGeoRSSTransformer(wms); GetMapRequest request = mapContent.getRequest(); String geometryEncoding = (String) request.getFormatOptions().get("encoding"); if ("gml".equals(geometryEncoding)) { tx.setGeometryEncoding(GeoRSSTransformerBase.GeometryEncoding.GML); } else if ("latlong".equals(geometryEncoding)) { tx.setGeometryEncoding(GeoRSSTransformerBase.GeometryEncoding.LATLONG); } else { tx.setGeometryEncoding(GeoRSSTransformerBase.GeometryEncoding.SIMPLE); } Charset encoding = wms.getCharSet(); tx.setEncoding(encoding); XMLTransformerMap result = new XMLTransformerMap(mapContent, tx, mapContent, getMimeType()); return result; }
/** @see org.geoserver.wms.GetMapOutputFormat#produceMap(org.geoserver.wms.WMSMapContent) */ public XMLTransformerMap produceMap(WMSMapContent map) throws ServiceException, IOException { RSSGeoRSSTransformer tx = new RSSGeoRSSTransformer(wms); GetMapRequest request = map.getRequest(); String geometryEncoding = (String) request.getFormatOptions().get("encoding"); if ("gml".equals(geometryEncoding)) { tx.setGeometryEncoding(GeoRSSTransformerBase.GeometryEncoding.GML); } else if ("latlong".equals(geometryEncoding)) { tx.setGeometryEncoding(GeoRSSTransformerBase.GeometryEncoding.LATLONG); } else { tx.setGeometryEncoding(GeoRSSTransformerBase.GeometryEncoding.SIMPLE); } Charset encoding = wms.getCharSet(); tx.setEncoding(encoding); XMLTransformerMap result = new XMLTransformerMap(map, tx, map, getMimeType()); // REVISIT: is was setting "inline; filename=geoserver.xml", now it's gonna be the requested // layer names, is it ok? result.setContentDispositionHeader(map, ".xml"); return result; }
@Override protected void checkAttribute(WMSMapContent con, SimpleFeatureType ft) { // find out which attribute we're going to use Map options = con.getRequest().getFormatOptions(); attribute = (String) options.get("regionateAttr"); if (attribute == null) { attribute = MapLayerInfo.getRegionateAttribute(featureType); } if (attribute == null || ft.getDescriptor(attribute) == null) { LOGGER.log(Level.FINER, "No attribute specified, falling " + "back on geometry attribute"); attribute = ft.getGeometryDescriptor().getLocalName(); } else { // Make sure the attribute is actually there AttributeType attributeType = ft.getType(attribute); if (attributeType == null) { throw new ServiceException("Could not find regionating attribute " + attribute + " in layer " + featureType.getName()); } } // geometry size is a double h2Type = "DOUBLE"; }
public Kml buildKMLDocument() { // prepare kml, document and folder Kml kml = new Kml(); Document document = kml.createAndSetDocument(); Map formatOptions = context.getRequest().getFormatOptions(); String kmltitle = (String) formatOptions.get("kmltitle"); if(kmltitle == null) { kmltitle = context.getMapContent().getTitle(); } document.setName(kmltitle); // get the callbacks for the document and let them loose List<KmlDecorator> decorators = context.getDecoratorsForClass(Document.class); for (KmlDecorator decorator : decorators) { document = (Document) decorator.decorate(document, context); if (document == null) { throw new ServiceException("Coding error in decorator " + decorator + ", document objects cannot be set to null"); } } encodeDocumentContents(document); return kml; }
protected void checkAttribute(WMSMapContent con, SimpleFeatureType ft) { // find out which attribute we're going to use Map options = con.getRequest().getFormatOptions(); attribute = (String) options.get("regionateAttr"); if (attribute == null) attribute = checkAttribute(featureType); if (attribute == null) throw new ServiceException( "Regionating attribute has not been specified"); // Make sure the attribute is actually there AttributeDescriptor ad = ft.getDescriptor(attribute); if (ad == null) { throw new ServiceException("Could not find regionating attribute " + attribute + " in layer " + featureType.getName()); } // Make sure we know how to turn that attribute into a H2 type h2Type = getH2DataType(ad); if (h2Type == null) throw new ServiceException("Attribute type " + ad.getType() + " is not " + "supported for external sorting on " + featureType.getName() + "#" + attribute); }
private void encodeLayerSuperOverlay(Document container, int layerIndex, Envelope bounds, int zoomLevel) { Layer layer = mapContent.layers().get(layerIndex); Folder folder = container.createAndAddFolder(); folder.setName(layer.getTitle()); LookAtOptions lookAtOptions = new LookAtOptions(request.getFormatOptions()); if (bounds != null) { LookAtDecoratorFactory lookAtFactory = new LookAtDecoratorFactory(); ReferencedEnvelope layerBounds = layer.getBounds(); CoordinateReferenceSystem layerCRS = layerBounds.getCoordinateReferenceSystem(); if(layerCRS != null && !CRS.equalsIgnoreMetadata(layerCRS, DefaultGeographicCRS.WGS84)) { try { layerBounds = layerBounds.transform(DefaultGeographicCRS.WGS84, true); } catch(Exception e) { throw new ServiceException("Failed to transform the layer bounds for " + layer.getTitle() + " to WGS84", e); } } LookAt la = lookAtFactory.buildLookAt(layerBounds, lookAtOptions, false); folder.setAbstractView(la); } encodeNetworkLinks(folder, layer, bounds, zoomLevel); }
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; }