001 //$HeadURL: http://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/model/feature/Feature.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 037 package org.deegree.model.feature; 038 039 import java.util.Map; 040 041 import org.deegree.datatypes.QualifiedName; 042 import org.deegree.io.datastore.PropertyPathResolvingException; 043 import org.deegree.model.feature.schema.FeatureType; 044 import org.deegree.model.spatialschema.Envelope; 045 import org.deegree.model.spatialschema.Geometry; 046 import org.deegree.model.spatialschema.GeometryException; 047 import org.deegree.ogcbase.PropertyPath; 048 049 /** 050 * Features are, according to the Abstract Specification, digital representations of real world 051 * entities. Feature Identity thus refers to mechanisms to identify such representations: not to 052 * identify the real world entities that are the subject of a representation. Thus two different 053 * representations of a real world entity (say the Mississippi River) will be two different features 054 * with distinct identities. Real world identification systems, such as title numbers, while 055 * possibly forming a sound basis for an implementation of a feature identity mechanism, are not of 056 * themselves such a mechanism. 057 * 058 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 059 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider</a> 060 * @version $Revision: 29966 $ $Date: 2011-03-09 15:19:04 +0100 (Wed, 09 Mar 2011) $ 061 */ 062 public interface Feature { 063 064 /** 065 * Returns the qualified name of the feature. 066 * 067 * @return the qualified name of the feature 068 */ 069 QualifiedName getName(); 070 071 /** 072 * Returns the id of the feature. 073 * 074 * @return the id of the feature 075 */ 076 String getId(); 077 078 /** 079 * Sets the id of the feature. 080 * 081 * @param fid 082 * the id of the feature to be set 083 */ 084 void setId( String fid ); 085 086 /** 087 * Returns the feature type of this feature. 088 * 089 * @return the feature type of this feature 090 */ 091 FeatureType getFeatureType(); 092 093 /** 094 * Sets the feature type of this feature. 095 * 096 * @param ft 097 * feature type to set 098 */ 099 void setFeatureType( FeatureType ft ); 100 101 /** 102 * Returns all properties of the feature in their original order. 103 * 104 * @return all properties of the feature 105 */ 106 FeatureProperty[] getProperties(); 107 108 /** 109 * Returns the first property of the feature with the given name. 110 * 111 * @param name 112 * name of the property to look up 113 * @return the first property of the feature with the given name or null if the feature has no 114 * such property 115 */ 116 FeatureProperty getDefaultProperty( QualifiedName name ); 117 118 /** 119 * Returns the property of the feature identified by the given {@link PropertyPath}. 120 * 121 * NOTE: Current implementation does not handle multiple properties (on the path) or index 122 * addressing in the path. 123 * 124 * @param path 125 * the path of the property to look up 126 * @return the property of the feature identified by the given PropertyPath 127 * @throws PropertyPathResolvingException 128 * 129 * @see PropertyPath 130 */ 131 FeatureProperty getDefaultProperty( PropertyPath path ) 132 throws PropertyPathResolvingException; 133 134 /** 135 * Returns the properties of the feature with the given name in their original order. 136 * 137 * @param name 138 * name of the properties to look up 139 * @return the properties of the feature with the given name or null if the feature has no 140 * property with that name 141 */ 142 FeatureProperty[] getProperties( QualifiedName name ); 143 144 145 /** 146 * Returns the values of all geometry properties of the feature. 147 * 148 * @return the values of all geometry properties of the feature, or a zero-length array if the 149 * feature has no geometry properties 150 */ 151 Geometry[] getGeometryPropertyValues(); 152 153 /** 154 * Returns the value of the default geometry property of the feature. If the feature has no 155 * geometry property, this is a Point at the coordinates (0,0). 156 * 157 * @return default geometry or Point at (0,0) if feature has no geometry 158 */ 159 Geometry getDefaultGeometryPropertyValue(); 160 161 /** 162 * Sets the value for the given property. The index is needed to specify the occurences of the 163 * property that is to be replaced. Set to 0 for properties that may only occur once. 164 * 165 * @param property 166 * property name and the property's new value 167 * @param index 168 * position of the property that is to be replaced 169 */ 170 void setProperty( FeatureProperty property, int index ); 171 172 /** 173 * Adds the given property to the feature's properties. The position of the property is 174 * determined by the feature type. If the feature already has a property with this name, it is 175 * inserted behind it. 176 * 177 * @param property 178 * property to insert 179 */ 180 void addProperty( FeatureProperty property ); 181 182 /** 183 * Removes the properties with the given name. 184 * 185 * @param propertyName 186 * name of the properties to remove 187 */ 188 void removeProperty( QualifiedName propertyName ); 189 190 /** 191 * Replaces the given property with a new one. 192 * 193 * @param oldProperty 194 * property to be replaced 195 * @param newProperty 196 * new property 197 */ 198 void replaceProperty( FeatureProperty oldProperty, FeatureProperty newProperty ); 199 200 /** 201 * Returns the envelope / bounding box of the feature. 202 * 203 * @return the envelope / bounding box of the feature 204 * @throws GeometryException 205 */ 206 Envelope getBoundedBy() 207 throws GeometryException; 208 209 /** 210 * Returns the owner of the feature. This is the feature property that has this feature as value 211 * or null if this feature is a root feature. 212 * 213 * @return the owner of the feature, or null if the feature does not belong to a feature 214 * property 215 */ 216 FeatureProperty getOwner(); 217 218 /** 219 * Returns the attribute value of the attribute with the specified name. 220 * 221 * @param name 222 * name of the attribute 223 * @return the attribute value 224 */ 225 String getAttribute( String name ); 226 227 /** 228 * Returns all attributes of the feature. 229 * 230 * @return all attributes, keys are names, values are attribute values 231 */ 232 Map<String, String> getAttributes(); 233 234 /** 235 * Sets the value of the attribute with the given name. 236 * 237 * @param name 238 * name of the attribute 239 * @param value 240 * value to set 241 */ 242 void setAttribute( String name, String value ); 243 244 /** 245 * Signals that the envelopes of the geometry properties have been updated. 246 */ 247 public void setEnvelopesUpdated(); 248 249 /** 250 * @return a shallow clone of a feature. Property values will not be cloned except for 251 * properties that are features (DefaultFeature) or feature collections 252 * (DefaultFeatureCollection) 253 */ 254 public Object clone() throws CloneNotSupportedException; 255 256 /** 257 * @return a deep clone of a feature. All not simple properties (incl. geometries) will be cloned 258 */ 259 public Feature cloneDeep() throws CloneNotSupportedException; 260 261 }