Examples of WMSCapabilities


Examples of gov.nasa.worldwind.ogc.wms.WMSCapabilities

        if (o instanceof WMSCapabilities)
            return (WMSCapabilities) o;

        // The cache entry exists, but is not a Capabilities document. Attempt to parse the Capabilities docuemnt,
        // by treating the current cache entry as a source.
        WMSCapabilities caps = parseCapabilities(o, name);
        if (caps == null)
            return null;

        // If the parsing succeeded, then overwrite the existing cache entry with the newly created Capabilities.
        cache.put(cacheKey, caps);
View Full Code Here

Examples of gov.nasa.worldwind.ogc.wms.WMSCapabilities

            String message = Logging.getMessage("nullValue.CacheKeyIsNull");
            Logging.logger().severe(message);
            throw new IllegalArgumentException(message);
        }

        WMSCapabilities caps = getSessionCapabilities(cache, cacheKey, url.toString());
        if (caps != null)
            return caps;

        retrieveSessionData(url, cache, cacheKey, absentResourceList, resourceID, propertyListener, propertyName);
View Full Code Here

Examples of gov.nasa.worldwind.ogc.wms.WMSCapabilities

        }

        java.io.InputStream inputStream = null;
        try
        {
            WMSCapabilities caps = new WMSCapabilities(source);
            return caps.parse();
        }
        catch (Exception e)
        {
            String message = Logging.getMessage("generic.CannotParseCapabilities", name);
           
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

    private class WMSResourceInfo extends IGeoResourceInfo {
        @SuppressWarnings("unchecked")
        WMSResourceInfo( IProgressMonitor monitor ) throws IOException {
            WebMapServer wms = service(monitor).getWMS(monitor);
            WMSCapabilities caps = wms.getCapabilities();

            if (layer.getTitle() != null && layer.getTitle().length() != 0) {
                title = layer.getTitle();
            }

            calculateBounds();

            String parentid = service != null && service.getIdentifier() != null ? getIdentifier()
                    .toString() : ""; //$NON-NLS-1$
            name = layer.getName();
            getKeywords(caps, parentid);

            if (layer.get_abstract() != null && layer.get_abstract().length() != 0) {
                description = layer.get_abstract();
            } else {
                description = caps.getService().get_abstract();
            }
            description = caps.getService().get_abstract();

            super.icon = CatalogUIPlugin.getDefault().getImageDescriptor(
                    ISharedImages.GRID_OBJ);

            // icon = fetchIcon( monitor );
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

    private final WMSGeoResourceImpl resource;
    @SuppressWarnings("unchecked")
    WMSGeoResourceInfo( WMSGeoResourceImpl geoResourceImpl, IProgressMonitor monitor ) throws IOException {
        resource = geoResourceImpl;
        WebMapServer wms = resource.service(monitor).getWMS(monitor);
        WMSCapabilities caps = wms.getCapabilities();
       
        bounds = bbox( resource.layer );
        if( bounds == null ){
            bounds = new ReferencedEnvelope( CRS.getEnvelope( DefaultGeographicCRS.WGS84 ) );
        }

        String parentid = resource.service(monitor) != null && resource.service(monitor).getIdentifier() != null ? resource.getIdentifier()
                .toString() : ""; //$NON-NLS-1$
        name = resource.layer.getName();
        List<String> keywordsFromWMS = new ArrayList<String>();
        if (caps.getService().getKeywordList() != null) {
            keywordsFromWMS.addAll(Arrays.asList(caps.getService().getKeywordList()));
        }

        if (resource.layer.getKeywords() != null) {
            keywordsFromWMS.addAll(Arrays.asList(resource.layer.getKeywords()));
        }
        keywordsFromWMS.add("WMS"); //$NON-NLS-1$
        keywordsFromWMS.add(resource.layer.getName());
        keywordsFromWMS.add(caps.getService().getName());
        keywordsFromWMS.add(parentid);
        keywords = keywordsFromWMS.toArray(new String[keywordsFromWMS.size()]);

        if (resource.layer.get_abstract() != null && resource.layer.get_abstract().length() != 0) {
            description = resource.layer.get_abstract();
        } else {
            description = caps.getService().get_abstract();
        }
        description = caps.getService().get_abstract();

        if (resource.layer.getTitle() != null && resource.layer.getTitle().length() != 0) {
            title = resource.layer.getTitle();
        } else {
            title = caps.getService().getTitle();
        }
        super.icon = CatalogUIPlugin.getDefault().getImageDescriptor(
                ISharedImages.GRID_OBJ);
    }
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

    }

    private static void writeLayer( ILayer layer, BufferedWriter out ) throws IOException {
        Layer wmsLayer = layer.getResource( Layer.class, null );
        WebMapServer wms = layer.getResource( WebMapServer.class, null );
        WMSCapabilities caps = wms.getCapabilities();
        String version = caps.getVersion();
       
        String title = wms.getCapabilities().getService().getTitle();
        int hidden = layer.isVisible() ? 1 : 0;
        int info = layer.getInteraction(Interaction.INFO) ? 1 : 0;
        String get = caps.getRequest().getGetCapabilities().getGet().toExternalForm();
System.out.println(get); if (get.endsWith("&")) get = get.substring(0,get.length()-1); //$NON-NLS-1$
        append( 4, out, "<Layer hidden=\""+ hidden +"\" queryable=\""+info+"\">" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        append( 6, out,   "<Server service=\"OGC:WMS\" title=\""+title+"\" version=\""+version+"\">" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        append( 8, out,     "<OnlineResource method=\"GET\" xlink:href=\""+get+"\" xlink:type=\"simple\"/>" ); //$NON-NLS-1$ //$NON-NLS-2$
        append( 6, out,   "</Server>" ); //$NON-NLS-1$
        append( 6, out,   "<Name>"+wmsLayer.getName()+"</Name>"); //$NON-NLS-1$ //$NON-NLS-2$
        append( 6, out,   "<Title>"+wmsLayer.getTitle()+"</Title>");                //$NON-NLS-1$ //$NON-NLS-2$
        if( !Double.isNaN( wmsLayer.getScaleHintMin() ))
            append( 6, out,   "<sld:MinScaleDenominator>"+wmsLayer.getScaleHintMin()+"</sld:MinScaleDenominator>");         //$NON-NLS-1$ //$NON-NLS-2$
        if( !Double.isNaN( wmsLayer.getScaleHintMax() ))
            append( 6, out,   "<sld:MaxScaleDenominator>"+wmsLayer.getScaleHintMax()+"</sld:MaxScaleDenominator>");         //$NON-NLS-1$ //$NON-NLS-2$
        for( String srs : (Set<String>) wmsLayer.getSrs() ){
            append( 6, out,   "<SRS>"+srs+"</SRS>"); //$NON-NLS-1$ //$NON-NLS-2$
        }
        append( 6, out,   "<FormatList>"); //$NON-NLS-1$
       
boolean first = true; // TODO: look up preferences?
for( String format : caps.getRequest().getGetMap().getFormats() ){
    if( first ){
        append( 8, out,     "<Format current=\"1\">"+format+"</Format>");                 //$NON-NLS-1$ //$NON-NLS-2$
        first = false;
    }
        append( 8, out,   "<Format>"+format+"</Format>");     //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

           
            GetMapRequest request = wms.createGetMapRequest();
           
            // put in default exception format we understand as a client
            // (if suppoted by the server)
            WMSCapabilities capabilities = wms.getCapabilities();
            if( capabilities.getRequest().getGetMap().getFormats().contains(GetMapRequest.EXCEPTION_XML) ){
                request.setExceptions(GetMapRequest.EXCEPTION_XML);
            }
            setImageFormat(wms, request);

            if (monitor.isCanceled())
                return;

            double currScale = getContext().getViewportModel().getScaleDenominator();
            List<ILayer> layers = getLayers();
            for( int i = layers.size() - 1; i >= 0; i-- ) {
                ILayer ilayer = layers.get(i);
                Layer layer;
                double minScale = 0;
                double maxScale = Double.MAX_VALUE;
                layer = ilayer.getResource(org.geotools.data.ows.Layer.class, null);
                // check if there are min/max scale rules
                StyleBlackboard sb = (StyleBlackboard) ilayer.getStyleBlackboard();
                Style style = (Style) sb.lookup(Style.class);
                if (style != null) {
                    Rule rule = style.getFeatureTypeStyles()[0].getRules()[0];
                    minScale = rule.getMinScaleDenominator();
                    maxScale = rule.getMaxScaleDenominator();
                }

                if (currScale >= minScale && currScale <= maxScale) {
                    // check for a wms style
                    StyleImpl wmsStyle = (StyleImpl) ilayer.getStyleBlackboard().get(
                            WMSStyleContent.WMSSTYLE);
                    if (wmsStyle != null) {
                        request.addLayer(layer, wmsStyle);
                    } else {
                        request.addLayer(layer);
                    }
                }
            }

            if (monitor.isCanceled())
                return;

            List<Layer> wmsLayers = getWMSLayers();
            if (wmsLayers == null || wmsLayers.isEmpty()){
                endLayerStatus = ILayer.WARNING;
                return;
            }
           
            // figure out request CRS
            CoordinateReferenceSystem viewportCRS = getViewportCRS();
            IMap map = getContext().getMap();
           
            String requestCRScode = findRequestCRS(wmsLayers, viewportCRS, map);
           
            // TODO: make findRequestCRS more efficient (we are running CRS.decode at *least* twice)
            CoordinateReferenceSystem requestCRS = CRS.decode(requestCRScode);

            // figure out viewport
//            ReferencedEnvelope viewport;
//            Envelope viewportBBox = getViewportBBox();
//            CoordinateReferenceSystem viewportCRS = getViewportCRS();
//            if (viewportBBox == null) {
//                // change viewport to world
//                viewportBBox = new Envelope(-180, 180, -90, 90);
//                if (!DefaultGeographicCRS.WGS84.equals(viewportCRS)) { // reproject
//                    viewport = new ReferencedEnvelope(viewportBBox, DefaultGeographicCRS.WGS84);
//                    viewportBBox = viewport.transform(viewportCRS, true);
//                }
//            }


            ReferencedEnvelope requestBBox = null;
            Envelope backprojectedBBox = null; // request bbox projected to the viewport crs
//            viewport = new ReferencedEnvelope(viewportBBox, viewportCRS);
//            requestBBox = calculateRequestBBox(wmsLayers, viewport, requestCRS);
           
            requestBBox = calculateRequestBBox(wmsLayers, bounds, requestCRS, capabilities.getVersion() );

            // check that a request is needed (not out of a bounds, invalid, etc)
            if (requestBBox == NILL_BOX) {
                endLayerStatus = ILayer.WARNING;
                return;
            }
            assert requestBBox.getCoordinateReferenceSystem().equals(requestCRS);

            if (requestBBox.getCoordinateReferenceSystem().equals(viewportCRS)) {
                backprojectedBBox = (Envelope) requestBBox;
            } else {
                backprojectedBBox = (Envelope) requestBBox.transform(viewportCRS, true);
            }

            if (WMSPlugin.isDebugging(Trace.RENDER)) {
                WMSPlugin.trace("Viewport CRS: " + viewportCRS.getName()); //$NON-NLS-1$
                WMSPlugin.trace("Request CRS: " + requestCRS.getName()); //$NON-NLS-1$
                WMSPlugin.trace("Context Image bounds: " + getContext().getImageBounds()); //$NON-NLS-1$
                WMSPlugin.trace("Request BBox  bounds: " + requestBBox); //$NON-NLS-1$
                WMSPlugin.trace("Backprojected request bounds: " + backprojectedBBox); //$NON-NLS-1$
            }

            Service wmsService = capabilities.getService();
            Dimension maxDimensions = new Dimension(wmsService.getMaxWidth(), wmsService
                    .getMaxHeight());
//            Dimension imageDimensions = calculateImageDimensions(getContext().getMapDisplay()
//                    .getDisplaySize(), maxDimensions, getViewportBBox(), backprojectedBBox);
            Dimension imageDimensions = calculateImageDimensions(getContext().getImageSize(), maxDimensions, bounds, backprojectedBBox);
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

    private List<TileLayer> getLayers(WebMapServer wms, String wmsUrl, String urlVersion)
            throws GeoWebCacheException {
        List<TileLayer> layers = new LinkedList<TileLayer>();

        WMSCapabilities capabilities = wms.getCapabilities();
        if (capabilities == null) {
            throw new ConfigurationException("Unable to get capabitilies from " + wmsUrl);
        }

        WMSHttpHelper sourceHelper = new WMSHttpHelper();

        List<Layer> layerList = capabilities.getLayerList();
        Iterator<Layer> layerIter = layerList.iterator();

        while (layerIter.hasNext()) {
            Layer layer = layerIter.next();
            String name = layer.getName();
            String stylesStr = "";

            String title = layer.getTitle();

            String description = layer.get_abstract();

            LayerMetaInformation layerMetaInfo = null;
            if (title != null || description != null) {
                layerMetaInfo = new LayerMetaInformation(title, description, null, null);
            }
            boolean queryable = layer.isQueryable();

            if (name != null) {
                List<StyleImpl> styles = layer.getStyles();

                StringBuffer buf = new StringBuffer();
                if (styles != null) {
                    Iterator<StyleImpl> iter = styles.iterator();
                    boolean hasOne = false;
                    while (iter.hasNext()) {
                        if (hasOne) {
                            buf.append(",");
                        }
                        buf.append(iter.next().getName());
                        hasOne = true;
                    }
                    stylesStr = buf.toString();
                }

                double minX = layer.getLatLonBoundingBox().getMinX();
                double minY = layer.getLatLonBoundingBox().getMinY();
                double maxX = layer.getLatLonBoundingBox().getMaxX();
                double maxY = layer.getLatLonBoundingBox().getMaxY();

                BoundingBox bounds4326 = new BoundingBox(minX, minY, maxX, maxY);

                log.info("Found layer: " + layer.getName() + " with LatLon bbox "
                        + bounds4326.toString());

                BoundingBox bounds3785 = new BoundingBox(longToSphericalMercatorX(minX),
                        latToSphericalMercatorY(minY), longToSphericalMercatorX(maxX),
                        latToSphericalMercatorY(maxY));

                String[] wmsUrls = { wmsUrl };

                LinkedList<ParameterFilter> paramFilters = new LinkedList<ParameterFilter>();
                for (Dimension dimension : layer.getDimensions().values()) {
                    Extent dimExtent = layer.getExtent(dimension.getName());
                    paramFilters.add(new NaiveWMSDimensionFilter(dimension, dimExtent));
                }

                WMSLayer wmsLayer = null;
                try {
                    wmsLayer = getLayer(name, wmsUrls, bounds4326, bounds3785, stylesStr,
                            queryable, layer.getBoundingBoxes(), paramFilters);
                } catch (GeoWebCacheException gwc) {
                    log.error("Error creating " + layer.getName() + ": " + gwc.getMessage());
                }

                if (wmsLayer != null) {

                    // Finalize with some defaults
                    wmsLayer.setCacheBypassAllowed(allowCacheBypass);
                    wmsLayer.setBackendTimeout(backendTimeout);

                    wmsLayer.setMetaInformation(layerMetaInfo);

                    if (urlVersion != null) {
                        wmsLayer.setVersion(urlVersion);
                    } else {
                        String wmsVersion = capabilities.getVersion();
                        if (wmsVersion != null && wmsVersion.length() > 0) {
                            wmsLayer.setVersion(wmsVersion);
                        }
                    }
                    wmsLayer.setSourceHelper(sourceHelper);
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

//        assertNotNull(request);
//
//    }
   
    public void testCreateParser() throws Exception {
        WMSCapabilities capabilities = createCapabilities("1.1.0Capabilities.xml");
        try{
            assertEquals(capabilities.getVersion(), "1.1.0");
            assertEquals(capabilities.getService().getName(), "OGC:WMS");
            assertEquals(capabilities.getService().getTitle(), "GMap WMS Demo Server");
            assertNotNull(capabilities.getService().get_abstract());
            assertEquals(capabilities.getService().getOnlineResource(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
            assertNull(capabilities.getService().getKeywordList());
           
            assertEquals(capabilities.getRequest().getGetCapabilities().getFormats().size(), 1);
            assertEquals(capabilities.getRequest().getGetCapabilities().getFormats().get(0), "application/vnd.ogc.wms_xml");
            assertEquals(capabilities.getRequest().getGetCapabilities().getGet(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
            assertEquals(capabilities.getRequest().getGetCapabilities().getPost(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
           
            assertEquals(capabilities.getRequest().getGetMap().getFormats().size(), 7);
            assertEquals(capabilities.getRequest().getGetMap().getFormats().get(0), "image/gif");
            assertEquals(capabilities.getRequest().getGetMap().getFormats().get(3), "image/wbmp");
            assertEquals(capabilities.getRequest().getGetMap().getFormats().get(6), "image/tiff");
            assertEquals(capabilities.getRequest().getGetMap().getGet(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
            assertEquals(capabilities.getRequest().getGetMap().getPost(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
           
            assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().size(), 3);
            assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(0), "text/plain");
            assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(1), "text/html");
            assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(2), "application/vnd.ogc.gml");
           
            assertEquals(capabilities.getLayerList().size(), 12);
           
            Layer layer = (Layer) capabilities.getLayerList().get(0);
            assertNull(layer.getParent());
            assertEquals(layer.getName(), "DEMO");
            assertEquals(layer.get_abstract(), "Abstract Test");
            String[] keywords = layer.getKeywords();
            assertNotNull(keywords);
            assertEquals(keywords.length, 2);
            assertEquals(keywords[0], "word1");
            assertEquals(keywords[1], "word2");
            assertEquals(layer.getTitle(), "GMap WMS Demo Server");
            assertEquals(layer.getSrs().size(), 4);
            assertTrue(layer.getSrs().contains("EPSG:42304"));
            assertTrue(layer.getSrs().contains("EPSG:42101"));
            assertTrue(layer.getSrs().contains("EPSG:4269"));
            assertTrue(layer.getSrs().contains("EPSG:4326"));
           
            CRSEnvelope llbbox = layer.getLatLonBoundingBox();
            validateBoundingBox(llbbox, -172.367, 35.6673, -11.5624, 83.8293);
           
           
            assertEquals(layer.getBoundingBoxes().size(), 1);
            assertNotNull(layer.getBoundingBoxes().get("EPSG:42304"));
           
            Layer layer2 = (Layer) capabilities.getLayerList().get(1);
            assertEquals(layer2.getParent(), layer);
            assertEquals(layer2.getName(), "bathymetry");
            assertEquals(layer2.getTitle(), "Elevation/Bathymetry");
            assertTrue(layer2.getSrs().contains("EPSG:42304"));
            assertFalse(layer2.isQueryable());
           
            layer2 = (Layer) capabilities.getLayerList().get(2);
            assertEquals(layer2.getParent(), layer);
            assertEquals(layer2.getName(), "land_fn");
            assertEquals(layer2.getTitle(), "Foreign Lands");
           
            validateBoundingBox(layer2.getLatLonBoundingBox(),
                    -178.838, 31.8844, 179.94, 89.8254);
           
            assertTrue(layer2.getSrs().contains("EPSG:42304"));
            assertFalse(layer2.isQueryable());
            assertNotNull(layer2.getBoundingBoxes().get("EPSG:42304"));
           
            layer2 = (Layer) capabilities.getLayerList().get(3);
            assertEquals(layer2.getParent(), layer);
            assertEquals(layer2.getName(), "park");
            assertEquals(layer2.getTitle(), "Parks");
           
            validateBoundingBox(layer2.getLatLonBoundingBox(),
                    -173.433, 41.4271, -13.3643, 83.7466);
           
            assertTrue(layer2.getSrs().contains("EPSG:42304"));
            assertTrue(layer2.isQueryable());
            assertNotNull(layer2.getBoundingBoxes().get("EPSG:42304"));
           
            layer2 = (Layer) capabilities.getLayerList().get(11);
            assertEquals(layer2.getParent(), layer);
            assertEquals(layer2.getName(), "grid");
            assertEquals(layer2.getTitle(), "Grid");
           
            llbbox = layer2.getLatLonBoundingBox();
View Full Code Here

Examples of org.geotools.data.ows.WMSCapabilities

    }
   
    public void testCreateGetMapRequest() throws Exception {
        try{
            WebMapServer wms = new WebMapServer(server);
            WMSCapabilities caps = wms.getCapabilities();
            GetMapRequest request = wms.createGetMapRequest();
            request.setFormat("image/jpeg");
            //System.out.println(request.getFinalURL().toExternalForm());
           
            String externalForm = request.getFinalURL().toExternalForm();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.