001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/model/feature/AbstractFeatureCollection.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2006 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/deegree/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     This library is free software; you can redistribute it and/or
012     modify it under the terms of the GNU Lesser General Public
013     License as published by the Free Software Foundation; either
014     version 2.1 of the License, or (at your option) any later version.
015    
016     This library is distributed in the hope that it will be useful,
017     but WITHOUT ANY WARRANTY; without even the implied warranty of
018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019     Lesser General Public License for more details.
020    
021     You should have received a copy of the GNU Lesser General Public
022     License along with this library; if not, write to the Free Software
023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024    
025     Contact:
026    
027     Andreas Poth
028     lat/lon GmbH
029     Aennchenstr. 19
030     53115 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     Department of Geography
036     University of Bonn
037     Meckenheimer Allee 166
038     53115 Bonn
039     Germany
040     E-Mail: greve@giub.uni-bonn.de
041    
042     ---------------------------------------------------------------------------*/
043    package org.deegree.model.feature;
044    
045    import org.deegree.datatypes.QualifiedName;
046    import org.deegree.datatypes.Types;
047    import org.deegree.datatypes.UnknownTypeException;
048    import org.deegree.framework.log.ILogger;
049    import org.deegree.framework.log.LoggerFactory;
050    import org.deegree.model.feature.schema.PropertyType;
051    import org.deegree.model.spatialschema.Geometry;
052    import org.deegree.model.spatialschema.GeometryFactory;
053    import org.deegree.ogcbase.CommonNamespaces;
054    
055    /**
056     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
057     * @author last edited by: $Author: bezema $
058     * 
059     * @version $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
060     */
061    public abstract class AbstractFeatureCollection extends AbstractFeature implements
062                                                                           FeatureCollection {
063    
064        private static final ILogger LOG = LoggerFactory.getLogger( AbstractFeatureCollection.class );
065    
066        /**
067         * @param id
068         */
069        public AbstractFeatureCollection( String id ) {
070            super( id, null );
071    
072            PropertyType[] ftp = new PropertyType[1];
073            QualifiedName name = null;
074    
075            try {
076                ftp[0] = FeatureFactory.createPropertyType( new QualifiedName( "features" ),
077                                                            Types.FEATURE_ARRAY_PROPERTY_NAME, true );
078                name = new QualifiedName( CommonNamespaces.WFS_PREFIX, "FeatureCollection",
079                                          CommonNamespaces.WFSNS );
080            } catch ( UnknownTypeException e ) {
081                LOG.logError( "Unreachable point reached.", e );
082            }
083            this.featureType = FeatureFactory.createFeatureType( name, false, ftp );
084    
085        }
086    
087        /**
088         * returns a Point with position 0/0 and no CRS
089         * 
090         * @return a geometry
091         */
092        public Geometry getDefaultGeometryPropertyValue() {
093            return GeometryFactory.createPoint( 0, 0, null );
094        }
095    
096        /**
097         * returns the value of a feature collection geometry properties
098         * 
099         * @return array of all geometry property values
100         */
101        public Geometry[] getGeometryPropertyValues() {
102            return new Geometry[0];
103        }
104    
105        /**
106         * returns all properties of a feature collection
107         * 
108         * @return all properties of a feature
109         */
110        public FeatureProperty[] getProperties() {
111            return new FeatureProperty[0];
112        }
113    
114        /**
115         * returns the properties of a feature collection at the passed index position
116         * 
117         * @param index
118         * @return properties at the passed index position
119         */
120        public FeatureProperty[] getProperties( int index ) {
121            // TODO
122            // a FeatureCollection may also have properties?
123            return null;
124        }
125    
126        /**
127         * returns the default property of a feature collection with the passed name
128         * 
129         * @param name
130         * @return named default property
131         */
132        public FeatureProperty getDefaultProperty( QualifiedName name ) {
133            // TODO
134            // a FeatureCollection may also have properties?
135            return null;
136        }
137    
138        /**
139         * returns the named properties of a feature collection
140         * 
141         * @param name
142         * @return named properties
143         */
144        public FeatureProperty[] getProperties( QualifiedName name ) {
145            // TODO
146            // a FeatureCollection may also have properties?
147            return null;
148        }
149    
150        /**
151         * sets a property of a feature collection.<br>
152         * !!! this method is not implemented yet !!!
153         * 
154         * @param property
155         */
156        public void setProperty( FeatureProperty property ) {
157            // TODO
158            // a FeatureCollection may also have properties?
159        }
160    
161        /**
162         * @see org.deegree.model.feature.FeatureCollection#addAll(org.deegree.model.feature.Feature[])
163         */
164        public void addAll( Feature[] feature ) {
165            for ( int i = 0; i < feature.length; i++ ) {
166                add( feature[i] );
167            }
168        }
169    
170        /**
171         * @see org.deegree.model.feature.FeatureCollection#addAll(org.deegree.model.feature.FeatureCollection)
172         */
173        public void addAll( FeatureCollection fc ) {
174            int size = fc.size();
175            for ( int i = 0; i < size; i++ ) {
176                add( fc.getFeature( i ) );
177            }
178        }
179    
180        /**
181         * removes a feature identified by its ID from the feature collection. If no feature with the
182         * passed ID is available nothing happens and <tt>null</tt> will be returned
183         * 
184         * @param id
185         * @return
186         */
187        public Feature remove( String id ) {
188            Feature feat = getFeature( id );
189            return remove( feat );
190        }
191    
192    }
193    
194    /***************************************************************************************************
195     * <code>
196     Changes to this class. What the people have been up to:
197     
198     $Log$
199     Revision 1.20  2007/03/13 15:51:13  wanhoff
200     Fixed Javadoc (@param, @return)
201    
202     Revision 1.19  2006/10/11 11:22:54  poth
203     use generics
204     
205     Revision 1.18  2006/08/07 06:46:25  poth
206     comments added
207    
208     Revision 1.17  2006/06/12 14:45:17  schmitz
209     Removed some cruft (?) and extended the generic sql datastore.
210     
211     Revision 1.16  2006/04/06 20:25:27  poth
212     *** empty log message ***
213     
214     Revision 1.15  2006/03/30 21:20:26  poth
215     *** empty log message ***
216     
217     Revision 1.14  2006/02/02 22:00:24  mschneider
218     Changed default namespace prefix for feature collections to 'wfs'.
219     
220     Revision 1.13  2006/02/01 16:05:26  poth
221     *** empty log message ***
222     
223     Revision 1.11  2006/01/31 16:24:43  mschneider
224     Changes due to refactoring of org.deegree.model.feature package.
225     
226     Revision 1.10  2005/12/08 20:40:52  mschneider
227     Added 'isAbstract' field to FeatureType.
228     
229     Revision 1.9  2005/11/21 18:41:26  mschneider
230     Added methods for precise modification of the feature's properties.
231     
232     Revision 1.8  2005/11/16 13:44:59  mschneider
233     Merge of wfs development branch.
234     
235     Revision 1.7.2.6  2005/11/15 13:36:55  deshmukh
236     Modified Object to FeatureProperty
237     
238     Revision 1.7.2.5  2005/11/14 19:51:41  mschneider
239     Fixed compilation problems.
240     
241     Revision 1.7.2.4  2005/11/14 00:55:52  mschneider
242     MappedPropertyType -> PropertyType.
243     
244     Revision 1.7.2.3  2005/11/09 08:00:50  mschneider
245     More refactoring of 'org.deegree.io.datastore'.
246     
247     Revision 1.7.2.2  2005/11/07 13:09:26  deshmukh
248     Switched namespace definitions in "CommonNamespaces" to URI.
249     
250     Revision 1.7.2.1  2005/11/07 11:19:09  deshmukh
251     Refactoring of 'createPropertyType()' methods in FeatureFactory.
252     
253     Revision 1.7 2005/08/30 13:40:03 poth
254     no message Changes to this class. What
255     the people have been up to:  Revision 1.6
256     2005/08/24 16:09:26 mschneider  Renamed
257     GenericName to QualifiedName.  Changes to
258     this class. What the people have been up to: Revision 1.5 2005/07/19 15:05:13 mschneider Changes
259     to this class. What the people have been up to: Changed name of FeatureCollection from
260     'feature_collection' to 'deegreewfs:FeatureCollection'. Changes to this class. What the people
261     have been up to: Revision 1.4 2005/07/08 12:21:06 poth no message
262     
263     </code>
264     **************************************************************************************************/