Package org.geotools.data.wms

Examples of org.geotools.data.wms.WebMapServer


    }

    @SuppressWarnings("unchecked")
    private static ImageDescriptor requestImage( IProgressMonitor monitor, Layer layer,
            WMSServiceImpl service ) throws IOException {
        WebMapServer wms = service.getWMS(monitor);

        if (wms.getCapabilities().getRequest().getGetLegendGraphic() == null) {
            return CatalogUIPlugin.getDefault().getImageDescriptor(
                    ISharedImages.GRID_OBJ);
        }

        ImageDescriptor imageDescriptor = null;
        try {
            GetLegendGraphicRequest request = wms.createGetLegendGraphicRequest();
            request.setLayer(layer.getName());
            request.setWidth("16"); //$NON-NLS-1$
            request.setHeight("16"); //$NON-NLS-1$

            List<String> formats = wms.getCapabilities().getRequest().getGetLegendGraphic()
                    .getFormats();

            Collections.sort(formats, new Comparator<String>(){

                public int compare( String format1, String format2 ) {
View Full Code Here


    }

    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();
            }
View Full Code Here

        }
        if( !wmslayer.isQueryable() ){
            return null;
        }
        // TODO: Fix wmslayer so we can ask who its "source" is.
        final WebMapServer wms = layer.getResource( WebMapServer.class, null );       
        if( wms == null ) {
            throw new IllegalArgumentException("Provided layer cannot resolve to a wms" ); //$NON-NLS-1$
        }
        String desiredFormat = desiredInfoFormat( wms );               
        if( desiredFormat == null ){
            return null;
        }
        GetMapRequest getmap = wms.createGetMapRequest();       
        String code = BasicWMSRenderer2.findRequestCRS(
                Collections.singletonList( wmslayer ), map.getViewportModel().getCRS(), map );

        getmap.setBBox( bbox );
        String srs = CRS.toSRS(bbox.getCoordinateReferenceSystem() );
        //getmap.setSRS( code != null ? code : srs );
       
        getmap.setProperty( GetMapRequest.LAYERS, wmslayer.getName() );
        int width = map.getRenderManager().getMapDisplay().getWidth();
        int height = map.getRenderManager().getMapDisplay().getHeight();
        getmap.setDimensions(width, height);
        //getmap.setSRS(code);
       
        List<String> formats = wms.getCapabilities().getRequest().getGetMap().getFormats();
        if (formats.contains("image/png")) { //$NON-NLS-1$
            getmap.setProperty(GetMapRequest.FORMAT, "image/png"); //$NON-NLS-1$
        } else if (formats.contains("image/gif")) { //$NON-NLS-1$
            getmap.setProperty(GetMapRequest.FORMAT, "image/gif"); //$NON-NLS-1$
        } else if (formats.contains("image/jpeg")) { //$NON-NLS-1$
            getmap.setProperty(GetMapRequest.FORMAT, "image/jpeg"); //$NON-NLS-1$
        } else if (formats.contains("image/bmp")) { //$NON-NLS-1$
            getmap.setProperty(GetMapRequest.FORMAT, "image/bmp"); //$NON-NLS-1$
        }
       
        StyleImpl wmsStyle = (StyleImpl) layer.getStyleBlackboard().get(WMSStyleContent.WMSSTYLE);
        if (wmsStyle != null) {
            getmap.setProperty(GetMapRequest.STYLES, wmsStyle.getName());
        }
        else {
            // supply an empty String as per UDIG-1507
            getmap.setProperty(GetMapRequest.STYLES, "");
        }
       
        final GetFeatureInfoRequest request = wms.createGetFeatureInfoRequest( getmap );                      
        request.setInfoFormat( desiredFormat );
        request.setQueryPoint( centre.x, centre.y );               
        request.setQueryLayers( Collections.singleton( wmslayer ) );
               
        LayerPointInfo info = new LayerPointInfo( layer ){
                   
            private GetFeatureInfoResponse response;
            /** Lazy request */
                   
            protected GetFeatureInfoResponse getResponse() throws IOException {
                if (this.response == null) {
                    try {
                        System.out.println(request.getFinalURL());
                        this.response = wms.issueRequest( request );
                    } catch (SAXException e) {
                        throw new IOException(
                                "Unable to parse the returned response from the server. Reason unknown."); //$NON-NLS-1$
                    }
                }
View Full Code Here

    }
    public ImageDescriptor createWMSGylph( Layer target ) {
        if (target.isType(WebMapServer.class))
            return null;
        try {
            WebMapServer wms = target.getResource(WebMapServer.class, null);
            org.geotools.data.ows.Layer layer = target.getResource(
                    org.geotools.data.ows.Layer.class, null);

            if (wms.getCapabilities().getRequest().getGetLegendGraphic() != null) {

                GetLegendGraphicRequest request = wms.createGetLegendGraphicRequest();
                request.setLayer(layer.getName());

                String desiredFormat = null;
                List formats = wms.getCapabilities().getRequest()
                        .getGetLegendGraphic().getFormats();
                if (formats.contains("image/png")) { //$NON-NLS-1$
                    desiredFormat = "image/png"; //$NON-NLS-1$
                }
                if (desiredFormat == null && formats.contains("image/gif")) { //$NON-NLS-1$
View Full Code Here

        append( 4, out, "</SimpleFeatureType>" ); //$NON-NLS-1$
    }

    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$
View Full Code Here

    /** WMSResourceInfo resource field */
    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 ) );
        }
View Full Code Here

    @Override
    public WMSServiceInfo getInfo( IProgressMonitor monitor ) throws IOException {
        return (WMSServiceInfo) super.getInfo(monitor);
    }
    protected WMSServiceInfo createInfo( IProgressMonitor monitor ) throws IOException {
        WebMapServer webMapServer = getWMS(monitor);
        if (webMapServer == null) {
            return null; // could not connect
        }
        rLock.lock();
        try {
View Full Code Here

            if (monitor.isCanceled())
                return;

            getContext().setStatus(ILayer.WAIT);

            WebMapServer wms = getWMS();
           
            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);
View Full Code Here

     * @return the layers described at the given URL
     */
    private synchronized List<TileLayer> getTileLayers(boolean reload) throws GeoWebCacheException {
        List<TileLayer> layers = null;

        WebMapServer wms = getWMS();
        if (wms == null) {
            throw new ConfigurationException("Unable to connect to " + this.url);
        }

        String wmsUrl = getWMSUrl(wms);
View Full Code Here

                metaWidthHeight, this.vendorParameters, queryable);
    }

    private WebMapServer getWMS() {
        try {
            return new WebMapServer(new URL(url));
        } catch (IOException ioe) {
            log.error(url + " -> " + ioe.getMessage());
        } catch (ServiceException se) {
            log.error(se.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.geotools.data.wms.WebMapServer

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.