Package org.vfny.geoserver.wms

Examples of org.vfny.geoserver.wms.WmsException


    public Object parse(String value) throws Exception {
        try {
            return Color.decode(value);
        } catch (NumberFormatException nfe) {
            throw new WmsException("BGCOLOR " + value
                + " incorrectly specified (0xRRGGBB format expected)");
        }
    }
View Full Code Here


    }
   
    public StyledLayerDescriptor getStyles(GetStylesRequest request) {
        if(request.getSldVer() != null
                && "".equals(request.getSldVer()) && !"1.0.0".equals(request.getSldVer()))
            throw new WmsException("SLD version " + request.getSldVer() + " not supported");
       
        try {
            StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
            List<StyledLayer> layers = new ArrayList<StyledLayer>();
            for(String layerName : request.getLayers()) {
                NamedLayer namedLayer = factory.createNamedLayer();
                layers.add(namedLayer);
                namedLayer.setName(layerName);
                LayerGroupInfo group = wms.getLayerGroupByName(layerName);
                LayerInfo layer = wms.getLayerByName(layerName);
                if(group != null) {
                    // nothing to do, groups have no style
                } else if(layer != null) {
                    Style style = layer.getDefaultStyle().getStyle();
                    // add the default style first
                    style = cloneStyle(style);
                    style.setDefault(true);
                    style.setName(layer.getDefaultStyle().getName());
                    namedLayer.styles().add(style);
                    // add alternate styles
                    for(StyleInfo si : layer.getStyles()) {
                        style = cloneStyle(si.getStyle());
                        style.setName(si.getName());
                        namedLayer.styles().add(style);
                    }
                } else {
                    // we should really add a code and a locator...
                    throw new WmsException("Unknown layer " + layerName);
                }
            }
           
           
            StyledLayerDescriptor sld = factory.createStyledLayerDescriptor();
            sld.setStyledLayers((StyledLayer[]) layers.toArray(new StyledLayer[layers.size()]));
           
            return sld;
        } catch(IOException e) {
            throw new WmsException(e);
        }
    }
View Full Code Here

       
        CoordinateReferenceSystem reqCRS;
        try {
            reqCRS = CRS.decode(reqSRS);
        } catch(Exception e) {
            throw new WmsException(e);
        }
       
        // Ready to determine the bounds based on the layers, if not specified
        Envelope aggregateBbox = getMap.getBbox();
        boolean specifiedBbox = true;

        // If bbox is not specified by request
        if (aggregateBbox == null) {
            specifiedBbox = false;

            // Get the bounding box from the layers
            for (int i = 0; i < layers.length; i++) {
                MapLayerInfo layerInfo = layers[i];
                ReferencedEnvelope curbbox;
                try{
                    curbbox = layerInfo.getLatLongBoundingBox();
                    if(useNativeBounds){
                        ReferencedEnvelope nativeBbox = layerInfo.getBoundingBox();
                        if(nativeBbox == null){
                            try {
                                CoordinateReferenceSystem nativeCrs = layerInfo.getCoordinateReferenceSystem();
                                nativeBbox = curbbox.transform(nativeCrs, true);
                            } catch(Exception e) {
                                throw new WmsException("Best effort native bbox computation failed", "", e);
                            }
                        }
                        curbbox = nativeBbox;
                    }
                }catch(Exception e){
View Full Code Here

        WMS wms = request.getWMS();
        MapLayerInfo mli = null;
        if (layer != null) {
            LayerInfo layerInfo = wms.getLayerByName(layer);
            if (layerInfo == null) {
                throw new WmsException(layer + " layer does not exists.");
            }

            mli = new MapLayerInfo(layerInfo);

            try {
                if (layerInfo.getType() == Type.VECTOR) {
                    FeatureType featureType = mli.getFeature().getFeatureType();
                    request.setLayer(featureType);
                } else if (layerInfo.getType() == Type.RASTER) {
                    CoverageInfo coverageInfo = mli.getCoverage();

                    // it much safer to wrap a reader rather than a coverage in most cases, OOM can
                    // occur otherwise
                    final AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) coverageInfo
                            .getGridCoverageReader(new NullProgressListener(), GeoTools
                                    .getDefaultHints());
                    final FeatureCollection<SimpleFeatureType, SimpleFeature> feature = FeatureUtilities
                            .wrapGridCoverageReader(reader, null);
                    request.setLayer(feature.getSchema());
                }
            } catch (IOException e) {
                throw new WmsException(e);
            } catch (NoSuchElementException ne) {
                throw new WmsException(ne, new StringBuffer(layer)
                        .append(" layer does not exists.").toString(), ne.getLocalizedMessage());
            } catch (Exception te) {
                throw new WmsException(te, "Can't obtain the schema for the required layer.", te
                        .getLocalizedMessage());
            }
        }
       
        if (format != null && !GetLegendGraphicResponse.supportsFormat(format)) {
            throw new WmsException(new StringBuffer("Invalid graphic format: ").append(format)
                    .toString(), "InvalidFormat");
        }
        request.setFormat(format);

        try {
            parseOptionalParameters(request, mli);
        } catch (IOException e) {
            throw new WmsException(e);
        }

        return request;
    }
View Full Code Here

        try {
            URL url = new URL(sldUrl);
            in = url.openStream();
        } catch (MalformedURLException e) {
            throw new WmsException(e, "Not a valid URL to an SLD document " + sldUrl,
                    "loadRemoteStyle");
        } catch (IOException e) {
            throw new WmsException(e, "Can't open the SLD URL " + sldUrl, "loadRemoteStyle");
        }

        return parseSld(new InputStreamReader(in));
    }
View Full Code Here

        Style[] styles = null;

        try {
            styles = parser.readXML();
        } catch (RuntimeException e) {
            throw new WmsException(e);
        }

        if ((styles == null) || (styles.length == 0)) {
            throw new WmsException("Document contains no styles");
        }

        return styles;
    }
View Full Code Here

                    }
                }
            }

            if (sldRule == null) {
                throw new WmsException("Style " + sldStyle.getName()
                        + " does not contains a rule named " + rule);
            }
        }

        return sldRule;
View Full Code Here

            if (featuresPerTile == null || featuresPerTile.intValue() <= 1)
                featuresPerTile = 64;

            // sanity check, the layer is not geometryless
            if (featureType.getFeatureType().getGeometryDescriptor() == null)
                throw new WmsException(featureType.getName()
                        + " is geometryless, cannot generate KML!");

            // make sure the request is within the data bounds, allowing for a
            // small error
            ReferencedEnvelope requestedEnvelope = context.getAreaOfInterest()
                    .transform(WGS84, true);
            LOGGER.log(Level.FINE, "Requested tile: {0}", requestedEnvelope);
            dataEnvelope = featureType.getLatLonBoundingBox();

            // decide which tile we need to load/compute, and make sure
            // it's a valid tile request, that is, that is does fit with
            // the general tiling scheme (minus an eventual small error)
            Tile tile = new Tile(requestedEnvelope);
            ReferencedEnvelope tileEnvelope = tile.getEnvelope();
            if (!envelopeMatch(tileEnvelope, requestedEnvelope))
                throw new WmsException(
                        "Invalid bounding box request, it does not fit "
                                + "the nearest regionating tile. Requested area: "
                                + requestedEnvelope + ", " + "nearest tile: "
                                + tileEnvelope);

            // oki doki, let's compute the fids in the requested tile
            featuresInTile = getFeaturesForTile(dataDir, tile);
            LOGGER.log(Level.FINE, "Found "+featuresInTile.size() + " features in tile " + tile.toString());
        } catch (Throwable t) {
            LOGGER.log(Level.SEVERE,
                    "Error occurred while pre-processing regionated features",
                    t);
            throw new WmsException("Failure while pre-processing regionated features");
        }

        // This okay, just means the tile is empty
        if (featuresInTile.size() == 0) {
            throw new HttpErrorCodeException(204);
View Full Code Here

        Map options = con.getRequest().getFormatOptions();
        attribute = (String) options.get("regionateAttr");
        if (attribute == null)
            attribute = MapLayerInfo.getRegionateAttribute( featureType );
        if (attribute == null)
            throw new WmsException("Regionating attribute has not been specified");

        // Make sure the attribute is actually there
        AttributeType attributeType = type.getType(attribute);
        if (attributeType == null) {
            throw new WmsException("Could not find regionating attribute "
                    + attribute + " in layer " + featureType.getName());
        }
       
        // check we can actually sort on that attribute
        if(!fs.getQueryCapabilities().supportsSorting(new SortBy[] {ff.sort(attribute, SortOrder.DESCENDING)}))
            throw new WmsException("Native sorting on the " + attribute
                    + " is not possible for layer " + featureType.getName());
           

        // make sure a special db for this layer and attribute will be created
        return super.getDatabaseName(con, layer) + "_" + attribute;
View Full Code Here

    }

  public void produceMap() throws WmsException {
    // TODO Auto-generated method stub
    if (mapContext == null) {
      throw new WmsException("The map context is not set");
    }
  }
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.wms.WmsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.