Examples of WMSTileSet


Examples of org.locationtech.udig.catalog.wmsc.server.WMSTileSet

        //go through all the layers looking for a tiled resource
        List<Layer> layers = mainmap.getLayersInternal();
        for( Layer layer : layers ) {
            if (layer.getGeoResource().canResolve(WMSTileSet.class)){
                try {
                    WMSTileSet tiles = layer.getGeoResource().resolve(WMSTileSet.class,new NullProgressMonitor());
                   
                    double currres = mainMapEnvelope.getWidth() / mainMapDisplay.getWidth();
                   
                    double[] res = tiles.getResolutions();
                    //find the closest matching resolution
                    double diff = Math.abs(currres - res[0]);
                    int index = 0;
                    for( int i = 0; i < res.length; i++ ) {
                        if (Math.abs(currres - res[i]) < diff) {
View Full Code Here

Examples of org.locationtech.udig.catalog.wmsc.server.WMSTileSet

                return null;
            }
            IGeoResourceInfo info = resource.getInfo( new SubProgressMonitor(monitor, 50));
   
            String srs = CRS.toSRS(info.getCRS());
            TileSet tileset = new WMSTileSet();
   
            ReferencedEnvelope bounds = info.getBounds();
            if (bounds == null ) { //$NON-NLS-1$
                WmsPlugin.log("Bounds required for TileSet definition", new NullPointerException("Bounds required for tileset definitio")); //$NON-NLS-1$
                return null;
            }
            double minX = bounds.getMinimum(0);
            double maxX = bounds.getMaximum(0);
            double minY = bounds.getMinimum(1);
            double maxY = bounds.getMaximum(1);
   
            CRSEnvelope bbox = new CRSEnvelope(srs, minX, minY, maxX, maxY);
            tileset.setBoundingBox(bbox);
            tileset.setCoorindateReferenceSystem(srs);
   
            Map<String, Serializable> properties = resource.getPersistentProperties();
            Integer width = Integer.parseInt((String) properties.get(PreferenceConstants.P_TILESET_WIDTH));
            Integer height = Integer.parseInt((String) properties.get(PreferenceConstants.P_TILESET_HEIGHT));
   
            if (width == null) {
                width = PreferenceConstants.DEFAULT_TILE_SIZE;
            }
   
            if (height == null) {
                height = PreferenceConstants.DEFAULT_TILE_SIZE;
            }
   
            tileset.setWidth(width);
            tileset.setHeight(height);
   
            String imageType = (String) properties.get(PreferenceConstants.P_TILESET_IMAGE_TYPE);
   
            if (imageType == null || "".equals(imageType)) { //$NON-NLS-1$
                imageType = PreferenceConstants.DEFAULT_IMAGE_TYPE;
            }
   
            tileset.setFormat(imageType);
   
            /*
             * The layer ID
             */
            tileset.setLayers(info.getName());
   
            String scales = (String) properties.get(PreferenceConstants.P_TILESET_SCALES);
   
            String resolutions = workoutResolutions(scales, new ReferencedEnvelope(bbox), width);
   
            /*
             * If we have no resolutions to try - we wont.
             */
            if ("".equals(resolutions)) { //$NON-NLS-1$
                WmsPlugin.log("Resolutions are required for TileSet generation", new ServiceNotFoundException()); //$NON-NLS-1$
                return null;
            }
            tileset.setResolutions(resolutions);
   
            /*
             * The styles
             */
            String style = ""; //$NON-NLS-1$
            if (resource.canResolve(Layer.class)) {
                Layer layer = resource.resolve(Layer.class, new SubProgressMonitor(monitor, 50));
                StringBuilder sb = new StringBuilder(""); //$NON-NLS-1$
                for( StyleImpl layerStyle : layer.getStyles() ) {
                    sb.append(layerStyle.getName()+","); //$NON-NLS-1$
                }
                style = sb.toString();
            }
            if (style.length()>0){
                tileset.setStyles(style.substring(0, style.length()-1));
            } else {
                tileset.setStyles(style);
            }
   
            /*
             * The server is where tiles can be retrieved
             */
            tileset.setServer(server);
            return tileset;
        }
        finally {
             monitor.done();
        }
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.