Package org.locationtech.udig.catalog.wmsc.server

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


        return getId().compareTo( other.getId() );
    }
   
    public boolean equals(Object arg0) {
        if (arg0 instanceof Tile) {
            Tile tile = (Tile) arg0;
            // id contains scale and bounds so compare with that
            if (getId().equals(tile.getId())) {
                return true;
            }
            else {
                return false;
            }
View Full Code Here


                        Map<String, Tile> tilesInZoom = new HashMap<String, Tile>();

                        if (select != null) {

                            for( String key : allTilesInZoom.keySet() ) {
                                final Tile tile = allTilesInZoom.get(key);

                                if (select.intersects(JTS.toGeometry(tile.getBounds()))) {
                                    tilesInZoom.put(key, tile);
                                }
                            }
                        } else {
                            tilesInZoom.putAll(allTilesInZoom);
View Full Code Here

            // remove any tiles that are already loaded from disk to avoid
            // deadlock waiting for all tiles
            Map<String, Tile> loadedTiles = new HashMap<String, Tile>();
            Iterator<Entry<String, Tile>> iterator = tileRangeTiles.entrySet().iterator();
            while( iterator.hasNext() ) {
                Tile tile = iterator.next().getValue();
                if (tile.getBufferedImage() != null) {
                    loadedTiles.put(tile.getId(), tile);
                }
            }
            Iterator<Entry<String, Tile>> iterator2 = loadedTiles.entrySet().iterator();
            while( iterator2.hasNext() ) {
                Tile tile = iterator2.next().getValue();
                tileRangeTiles.remove(tile.getId());
            }

            // now load any missing tiles and send off thread requests to fetch them
            tileRangeOnDisk.loadTiles(new NullProgressMonitor());

            // block and wait until all unloaded tiles are loaded before moving forward
            while( !tileRangeTiles.isEmpty() ) {
                Tile tile = null;
                try {
                    tile = (Tile) tilesCompleted_queue.take(); // blocks until a tile is done
                } catch (InterruptedException ex) {
                    // log error?
                    // ex.printStackTrace();
                } finally {
                    // remove the tile
                    if (tile != null) {
                        tileRangeTiles.remove(tile.getId());
                    }
                }
            }

            // all tiles in chunk are now complete, so update monitor
View Full Code Here

            if (testing) {
                System.out.println("BLOCKED: "+thisid); //$NON-NLS-1$
                System.out.println("waiting on: " + notRenderedTiles.size()+" tiles"); //$NON-NLS-1$ //$NON-NLS-2$
            }
           
            Tile tile = null;
            try {
                Object element = null;
               
                /* get the next tile that is ready to render,
                 * check after 1 sec if the rendering was canceled
                 */
                while ((element = tilesToDraw_queue.poll(1000, TimeUnit.MILLISECONDS)) == null) {
                    checkCancelState(monitor, thisid, true);
                }
               
                tile = (Tile) element;

                if (testing) {
                    System.out.println("removed from queue: "+tile.getId()); //$NON-NLS-1$
                }
            } catch (InterruptedException ex) {
                if (testing) {
                    System.out.println("InterruptedException trying to take: "+ex); //$NON-NLS-1$
                }
            }
           
            if (testing) {
                System.out.println("UNBLOCKED!!!: "+thisid); //$NON-NLS-1$
            }
           
            // check that the rendering is not canceled again after block
            checkCancelState(monitor, thisid, true);
           
            // check that the tile's bounds are within the current
            // context's bounds (if it's not, don't bother drawing it) and also
            // only draw tiles that haven't already been drawn (panning fast
            // can result in listeners being notified the same tile is ready multiple
            // times but we don't want to draw it more than once per render cycle)
            //ReferencedEnvelope viewbounds = getContext().getViewportModel().getBounds();           
           
            ReferencedEnvelope viewbounds = renderJob.projectMapToTileCrs(
                    context.getViewportModel().getBounds());
           
            if (tile != null && tile.getBufferedImage() != null &&
                    viewbounds != null &&
                    viewbounds.intersects(tile.getBounds()) &&
                    !renderedTiles.contains(tile.getId()) &&
                    notRenderedTiles.contains(tile.getId())) {
                try {
                    renderedTiles.add(tile.getId());
                    renderTile(destination, (WMTTile) tile, style, renderJob);
                   
                } catch(Exception exc) {
                    WMTPlugin.log("[BasicWMTRender.render] renderTile failed (2): " + tile.getId(), exc); //$NON-NLS-1$
                }
                monitor.worked(tileWorth)// inc the monitor work by 1 tile
                setState(RENDERING); // tell renderer new data is ready               
            }
           
            // remove the tile from the not rendered list regardless
            // of whether it was actually drawn (this is to prevent
            // this render cycle from blocking endlessly waiting for tiles
            // that either didn't return or had some error)
            notRenderedTiles.remove(tile.getId());
        }
    }
View Full Code Here

            Map<String, Tile> tiles, Set<String> notRenderedTiles, Set<String> renderedTiles )
            throws Exception {
        for (String key : tiles.keySet()) {
            checkCancelState(monitor, thisid, false);
           
            Tile tile = tiles.get(key);
            if (tile != null && tile.getBufferedImage() != null && tile.getTileState() != WMSTile.INERROR) {
                try {
                    renderedTiles.add(key);
                    renderTile(destination, (WMTTile) tile, style, renderJob);
                } catch(Exception exc) {
                    WMTPlugin.log("[BasicWMTRender.render] renderTile failed (1): " + tile.getId(), exc); //$NON-NLS-1$
                }
                monitor.worked(tileWorth)// inc the monitor work by 1 tile
            }
            else {
                // set the tile blank (removing any previous content) and add it
View Full Code Here

                    if (testing) {
                        System.out.println("monitor CANCELED!!!: " + thisid); //$NON-NLS-1$
                    }
                    return;
                }
                Tile tile = tiles.get(key);
                if (tile != null && tile.getBufferedImage() != null
                        && tile.getTileState() != WMSTile.INERROR) {
                    renderTile(graphics, tile, tileset.getCoordinateReferenceSystem(), style);
                    renderedTiles.add(key);
                    monitor.worked(tileWorth); // inc the monitor work by 1 tile
                } else {
                    // set the tile blank (removing any previous content) and add it
                    // to be drawn later
                    renderBlankTile(graphics, tile, tileset.getCoordinateReferenceSystem());
                    notRenderedTiles.add(key);
                }
            }
            setState(RENDERING);

            // if the tilerange is not already completed, then load
            // the missing tiles
            if (!notRenderedTiles.isEmpty()) {
                if (monitor.isCanceled()) {
                    setState(CANCELLED);
                    if (testing) {
                        System.out.println("monitor CANCELED!!!: " + thisid); //$NON-NLS-1$
                    }
                    return;
                }

                // set the listener on the tile range
                range.addListener(listener);

                // load the missing tiles by sending requests for them
                range.loadTiles(monitor);

                // block until all the missing tiles have come through (and draw them
                // as they are added to the blocking queue
                while( !notRenderedTiles.isEmpty() ) {
                    // check that the rendering is not canceled
                    if (monitor.isCanceled()) {
                        setState(CANCELLED);
                        if (testing) {
                            System.out.println("monitor CANCELED!!!: " + thisid); //$NON-NLS-1$
                        }
                        tilesToDraw_queue.clear();
                        return;
                    }

                    if (testing) {
                        System.out.println("BLOCKED: " + thisid); //$NON-NLS-1$
                        System.out.println("waiting on: " + notRenderedTiles.size() + " tiles"); //$NON-NLS-1$ //$NON-NLS-2$
                    }

                    Tile tile = null;
                    try {
                        tile = (Tile) tilesToDraw_queue.take(); // blocks until a tile is ready to
                                                                // take
                        if (testing) {
                            System.out.println("removed from queue: " + tile.getId()); //$NON-NLS-1$
                        }
                    } catch (InterruptedException ex) {
                        if (testing) {
                            System.out.println("InterruptedException trying to take: " + ex); //$NON-NLS-1$
                        }
                    }

                    if (testing) {
                        System.out.println("UNBLOCKED!!!: " + thisid); //$NON-NLS-1$
                    }

                    // check that the rendering is not canceled again after block
                    if (monitor.isCanceled()) {
                        setState(CANCELLED);
                        if (testing) {
                            System.out.println("monitor CANCELED!!!: " + thisid); //$NON-NLS-1$
                        }

                        tilesToDraw_queue.clear();
                        return;
                    }

                    // check that the tile's bounds are within the current
                    // context's bounds (if it's not, don't bother drawing it) and also
                    // only draw tiles that haven't already been drawn (panning fast
                    // can result in listeners being notified the same tile is ready multiple
                    // times but we don't want to draw it more than once per render cycle)
                    // ReferencedEnvelope viewbounds = getContext().getViewportModel().getBounds();
                    ReferencedEnvelope viewbounds = getContext().getImageBounds();
                    if (tile != null && tile.getBufferedImage() != null && viewbounds != null
                            && viewbounds.intersects(tile.getBounds())
                            && !renderedTiles.contains(tile.getId())) {

                        renderTile(graphics, tile, tileset.getCoordinateReferenceSystem(), style);
                        renderedTiles.add(tile.getId());
                        monitor.worked(tileWorth); // inc the monitor work by 1 tile
                        setState(RENDERING); // tell renderer new data is ready
                    }

                    // remove the tile from the not rendered list regardless
                    // of whether it was actually drawn (this is to prevent
                    // this render cycle from blocking endlessly waiting for tiles
                    // that either didn't return or had some error)
                    notRenderedTiles.remove(tile.getId());
                }
            }

            if (testing) {
                System.out.println("DONE!!!: " + thisid); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.locationtech.udig.catalog.wmsc.server.Tile

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.