001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/model/feature/AbstractFeatureCollection.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2008 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: apoth $ 058 * 059 * @version $Revision: 9343 $, $Date: 2007-12-27 14:30:32 +0100 (Do, 27 Dez 2007) $ 060 */ 061 public abstract class AbstractFeatureCollection extends AbstractFeature implements FeatureCollection { 062 063 private static final ILogger LOG = LoggerFactory.getLogger( AbstractFeatureCollection.class ); 064 065 /** 066 * @param id 067 */ 068 public AbstractFeatureCollection( String id ) { 069 super( id, null ); 070 071 PropertyType[] ftp = new PropertyType[1]; 072 QualifiedName name = null; 073 074 try { 075 ftp[0] = FeatureFactory.createPropertyType( new QualifiedName( "features" ), 076 Types.FEATURE_ARRAY_PROPERTY_NAME, true ); 077 name = new QualifiedName( CommonNamespaces.WFS_PREFIX, "FeatureCollection", CommonNamespaces.WFSNS ); 078 } catch ( UnknownTypeException e ) { 079 LOG.logError( "Unreachable point reached.", e ); 080 } 081 this.featureType = FeatureFactory.createFeatureType( name, false, ftp ); 082 083 } 084 085 /** 086 * returns a Point with position 0/0 and no CRS 087 * 088 * @return a geometry 089 */ 090 public Geometry getDefaultGeometryPropertyValue() { 091 return GeometryFactory.createPoint( 0, 0, null ); 092 } 093 094 /** 095 * returns the value of a feature collection geometry properties 096 * 097 * @return array of all geometry property values 098 */ 099 public Geometry[] getGeometryPropertyValues() { 100 return new Geometry[0]; 101 } 102 103 /** 104 * returns all properties of a feature collection 105 * 106 * @return all properties of a feature 107 */ 108 public FeatureProperty[] getProperties() { 109 return new FeatureProperty[0]; 110 } 111 112 /** 113 * returns the properties of a feature collection at the passed index position 114 * 115 * @param index 116 * @return properties at the passed index position 117 */ 118 public FeatureProperty[] getProperties( int index ) { 119 // TODO 120 // a FeatureCollection may also have properties? 121 return null; 122 } 123 124 /** 125 * returns the default property of a feature collection with the passed name 126 * 127 * @param name 128 * @return named default property 129 */ 130 public FeatureProperty getDefaultProperty( QualifiedName name ) { 131 // TODO 132 // a FeatureCollection may also have properties? 133 return null; 134 } 135 136 /** 137 * returns the named properties of a feature collection 138 * 139 * @param name 140 * @return named properties 141 */ 142 public FeatureProperty[] getProperties( QualifiedName name ) { 143 // TODO 144 // a FeatureCollection may also have properties? 145 return null; 146 } 147 148 /** 149 * sets a property of a feature collection.<br> 150 * !!! this method is not implemented yet !!! 151 * 152 * @param property 153 */ 154 public void setProperty( FeatureProperty property ) { 155 // TODO 156 // a FeatureCollection may also have properties? 157 } 158 159 /** 160 * @see org.deegree.model.feature.FeatureCollection#addAll(org.deegree.model.feature.Feature[]) 161 */ 162 public void addAll( Feature[] feature ) { 163 for ( int i = 0; i < feature.length; i++ ) { 164 add( feature[i] ); 165 } 166 } 167 168 /** 169 * @see org.deegree.model.feature.FeatureCollection#addAll(org.deegree.model.feature.FeatureCollection) 170 */ 171 public void addAll( FeatureCollection fc ) { 172 int size = fc.size(); 173 for ( int i = 0; i < size; i++ ) { 174 add( fc.getFeature( i ) ); 175 } 176 } 177 178 /** 179 * removes a feature identified by its ID from the feature collection. If no feature with the 180 * passed ID is available nothing happens and <tt>null</tt> will be returned 181 * 182 * @param id 183 * @return 184 */ 185 public Feature remove( String id ) { 186 Feature feat = getFeature( id ); 187 return remove( feat ); 188 } 189 190 }