001 //$HeadURL: svn+ssh://mschneider@svn.wald.intevation.org/deegree/base/trunk/src/org/deegree/model/feature/DefaultFeatureCollection.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 Aennchenstraße 19 030 53177 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 java.io.Serializable; 046 import java.util.HashSet; 047 import java.util.Iterator; 048 import java.util.List; 049 import java.util.Set; 050 051 import org.deegree.datatypes.QualifiedName; 052 import org.deegree.io.datastore.PropertyPathResolvingException; 053 import org.deegree.model.spatialschema.Envelope; 054 import org.deegree.model.spatialschema.GeometryException; 055 import org.deegree.ogcbase.PropertyPath; 056 057 /** 058 * Represents a {@link FeatureCollection} that only contains <code>wfs:featureTuple</code> 059 * elements (as introduced by the draft WFS 1.2 spec). 060 * <p> 061 * NOTE: Some concepts of ordinary feature collections (like adding and removing of features) do not 062 * match well to this special kind of feature collection, mostly because it uses a 063 * <code>FeatureArrayPropertyType</code> for the <code>wfs:featureTuple</code> element. Thus, 064 * many methods inherited from {@link AbstractFeatureCollection} have no clear semantic and are not 065 * available. 066 * 067 * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider</a> 068 * @version $Revision: 6840 $ $Date: 2007-05-07 10:27:43 +0200 (Mo, 07 Mai 2007) $ 069 */ 070 public class FeatureTupleCollection extends AbstractFeatureCollection implements Serializable { 071 072 private static final long serialVersionUID = 2651676067288914826L; 073 074 private int tupleLength; 075 076 private List<Feature[]> tuples; 077 078 private Set<Feature> allFeatures = new HashSet<Feature>(); 079 080 private Envelope envelope; 081 082 FeatureTupleCollection( String id, List<Feature[]> tuples, int tupleLength ) { 083 super( id ); 084 this.tuples = tuples; 085 this.tupleLength = tupleLength; 086 for ( Feature[] features : tuples ) { 087 assert features.length == tupleLength; 088 for ( Feature feature : features ) { 089 allFeatures.add( feature ); 090 } 091 } 092 } 093 094 /* 095 * (non-Javadoc) 096 * 097 * @see org.deegree.model.feature.FeatureCollection#clear() 098 */ 099 public void clear() { 100 allFeatures.clear(); 101 } 102 103 /** 104 * Returns the feature tuple at the given index. 105 * 106 * @param index 107 * @return the feature tuple at the given index 108 */ 109 public Feature[] getTuple( int index ) { 110 return this.tuples.get( index ); 111 } 112 113 /** 114 * Returns the number of feature tuples contained in this collection. 115 * 116 * @return the number of feature tuples contained in this collection 117 */ 118 public int numTuples() { 119 return this.tuples.size(); 120 } 121 122 /** 123 * Returns the length (number of features) of each tuple. 124 * 125 * @return the length (number of features) of each tuple. 126 */ 127 public int tupleLength() { 128 return this.tupleLength; 129 } 130 131 @Override 132 public synchronized Envelope getBoundedBy() 133 throws GeometryException { 134 135 Envelope combinedEnvelope = this.envelope; 136 137 if ( combinedEnvelope == null && this.allFeatures.size() > 0 ) { 138 for ( Feature feature : this.allFeatures ) { 139 Envelope nextFeatureEnvelope = feature.getBoundedBy(); 140 if ( combinedEnvelope == null ) { 141 combinedEnvelope = nextFeatureEnvelope; 142 } else if ( nextFeatureEnvelope != null ) { 143 combinedEnvelope = combinedEnvelope.merge( nextFeatureEnvelope ); 144 } 145 } 146 this.envelope = combinedEnvelope; 147 } 148 return combinedEnvelope; 149 } 150 151 public int size() { 152 return this.tuples.size(); 153 } 154 155 public void add( Feature feature ) { 156 throw new NoSuchMethodError(); 157 } 158 159 public Feature getFeature( int index ) { 160 return null; 161 } 162 163 public Feature getFeature( String id ) { 164 throw new NoSuchMethodError(); 165 } 166 167 public Iterator iterator() { 168 throw new NoSuchMethodError(); 169 } 170 171 public Feature remove( Feature feature ) { 172 throw new NoSuchMethodError(); 173 } 174 175 public Feature remove( int index ) { 176 throw new NoSuchMethodError(); 177 } 178 179 public Feature[] toArray() { 180 throw new NoSuchMethodError(); 181 } 182 183 public void addProperty( FeatureProperty property ) { 184 throw new NoSuchMethodError(); 185 } 186 187 public FeatureProperty getDefaultProperty( PropertyPath path ) 188 throws PropertyPathResolvingException { 189 throw new NoSuchMethodError(); 190 } 191 192 public void removeProperty( QualifiedName propertyName ) { 193 throw new NoSuchMethodError(); 194 } 195 196 public void replaceProperty( FeatureProperty oldProperty, FeatureProperty newProperty ) { 197 throw new NoSuchMethodError(); 198 } 199 200 public void setProperty( FeatureProperty property, int index ) { 201 throw new NoSuchMethodError(); 202 } 203 }