001    // $HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/ogcwebservices/wcs/configuration/DirectoryResolution.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005       Department of Geography, University of Bonn
006     and
007       lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035    ----------------------------------------------------------------------------*/
036    package org.deegree.ogcwebservices.wcs.configuration;
037    
038    import java.util.ArrayList;
039    import java.util.Arrays;
040    import java.util.Iterator;
041    import java.util.List;
042    
043    import org.deegree.model.spatialschema.Envelope;
044    
045    /**
046     * models a <tt>Resolution</tt> by describing the access to the assigned coverages through named
047     * directories containing a well defined collection of coverages.
048     *
049     * @version $Revision: 18195 $
050     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
051     * @author last edited by: $Author: mschneider $
052     *
053     * @version 1.0. $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
054     *
055     * @since 2.0
056     */
057    public class DirectoryResolution extends AbstractResolution {
058    
059        private List<Directory> directories = null;
060    
061        /**
062         * @param minScale
063         * @param maxScale
064         * @param range
065         * @throws IllegalArgumentException
066         */
067        public DirectoryResolution( double minScale, double maxScale, Range[] range, Directory[] directories )
068                                throws IllegalArgumentException {
069            super( minScale, maxScale, range );
070            setDirectories( directories );
071        }
072    
073        /**
074         * @return Returns the directories.
075         *
076         */
077        public Directory[] getDirectories() {
078            return directories.toArray( new Directory[directories.size()] );
079        }
080    
081        /**
082         * returns the <tt>Directories</tt> of a <tt>Resolution</tt> that intersects with the passed
083         * <tt>Envelope</tt>
084         *
085         * @return Returns the directories.
086         */
087        public Directory[] getDirectories( Envelope envelope ) {
088            List<Directory> list = new ArrayList<Directory>( directories.size() );
089            for ( Iterator iter = directories.iterator(); iter.hasNext(); ) {
090                Directory dir = (Directory) iter.next();
091                if ( dir.getEnvelope().intersects( envelope ) ) {
092                    list.add( dir );
093                }
094            }
095            Directory[] dirs = new Directory[list.size()];
096            return list.toArray( dirs );
097        }
098    
099        /**
100         * @param directories
101         *            The directories to set.
102         */
103        public void setDirectories( Directory[] directories ) {
104            this.directories = new ArrayList<Directory>( Arrays.asList( directories ) );
105        }
106    
107        /**
108         * adds a <tt>Directory</tt> to the <tt>Resolution</tt>
109         *
110         * @param directory
111         */
112        public void addDirectory( Directory directory ) {
113            directories.add( directory );
114        }
115    
116        /**
117         * removes a <tt>Directory</tt> from the <tt>Resolution</tt>
118         *
119         * @param directory
120         */
121        public void removeDirectory( Directory directory ) {
122            directories.remove( directory );
123        }
124    
125    }