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-2007 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 * Returns the feature tuple at the given index. 096 * 097 * @param index 098 * @return the feature tuple at the given index 099 */ 100 public Feature[] getTuple( int index ) { 101 return this.tuples.get( index ); 102 } 103 104 /** 105 * Returns the number of feature tuples contained in this collection. 106 * 107 * @return the number of feature tuples contained in this collection 108 */ 109 public int numTuples() { 110 return this.tuples.size(); 111 } 112 113 /** 114 * Returns the length (number of features) of each tuple. 115 * 116 * @return the length (number of features) of each tuple. 117 */ 118 public int tupleLength() { 119 return this.tupleLength; 120 } 121 122 @Override 123 public synchronized Envelope getBoundedBy() 124 throws GeometryException { 125 126 Envelope combinedEnvelope = this.envelope; 127 128 if ( combinedEnvelope == null && this.allFeatures.size() > 0 ) { 129 for ( Feature feature : this.allFeatures ) { 130 Envelope nextFeatureEnvelope = feature.getBoundedBy(); 131 if ( combinedEnvelope == null ) { 132 combinedEnvelope = nextFeatureEnvelope; 133 } else if ( nextFeatureEnvelope != null ) { 134 combinedEnvelope = combinedEnvelope.merge( nextFeatureEnvelope ); 135 } 136 } 137 this.envelope = combinedEnvelope; 138 } 139 return combinedEnvelope; 140 } 141 142 public int size() { 143 return this.tuples.size(); 144 } 145 146 public void add( Feature feature ) { 147 throw new NoSuchMethodError(); 148 } 149 150 public Feature getFeature( int index ) { 151 return null; 152 } 153 154 public Feature getFeature( String id ) { 155 throw new NoSuchMethodError(); 156 } 157 158 public Iterator iterator() { 159 throw new NoSuchMethodError(); 160 } 161 162 public Feature remove( Feature feature ) { 163 throw new NoSuchMethodError(); 164 } 165 166 public Feature remove( int index ) { 167 throw new NoSuchMethodError(); 168 } 169 170 public Feature[] toArray() { 171 throw new NoSuchMethodError(); 172 } 173 174 public void addProperty( FeatureProperty property ) { 175 throw new NoSuchMethodError(); 176 } 177 178 public FeatureProperty getDefaultProperty( PropertyPath path ) 179 throws PropertyPathResolvingException { 180 throw new NoSuchMethodError(); 181 } 182 183 public void removeProperty( QualifiedName propertyName ) { 184 throw new NoSuchMethodError(); 185 } 186 187 public void replaceProperty( FeatureProperty oldProperty, FeatureProperty newProperty ) { 188 throw new NoSuchMethodError(); 189 } 190 191 public void setProperty( FeatureProperty property, int index ) { 192 throw new NoSuchMethodError(); 193 } 194 }