feature.html

来自「Geotools是一个开源的Java GIS工具包,可利用它来开发符合标准的地理」· HTML 代码 · 共 715 行 · 第 1/3 页

HTML
715
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.4.2_13) on Tue Jun 05 11:36:24 GMT-05:00 2007 --><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><TITLE>Feature (Geotools 2.3.x 2.3.2 API)</TITLE><META NAME="keywords" CONTENT="org.geotools.feature.Feature interface"><META NAME="keywords" CONTENT="getParent()"><META NAME="keywords" CONTENT="setParent()"><META NAME="keywords" CONTENT="getFeatureType()"><META NAME="keywords" CONTENT="getID()"><META NAME="keywords" CONTENT="getAttributes()"><META NAME="keywords" CONTENT="getAttribute()"><META NAME="keywords" CONTENT="setAttribute()"><META NAME="keywords" CONTENT="getNumberOfAttributes()"><META NAME="keywords" CONTENT="getDefaultGeometry()"><META NAME="keywords" CONTENT="setDefaultGeometry()"><META NAME="keywords" CONTENT="getBounds()"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="Feature (Geotools 2.3.x 2.3.2 API)";}</SCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Feature.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../org/geotools/feature/CollectionListener.html" title="interface in org.geotools.feature"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../org/geotools/feature/FeatureAttributeType.html" title="interface in org.geotools.feature"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="Feature.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">org.geotools.feature</FONT><BR>Interface Feature</H2><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../../org/geotools/feature/FeatureCollection.html" title="interface in org.geotools.feature">FeatureCollection</A>, <A HREF="../../../org/geotools/feature/FeatureDocument.html" title="interface in org.geotools.feature">FeatureDocument</A>, <A HREF="../../../org/geotools/feature/FeatureList.html" title="interface in org.geotools.feature">FeatureList</A>, <A HREF="../../../org/geotools/feature/IndexedFeatureCollection.html" title="interface in org.geotools.feature">IndexedFeatureCollection</A>, <A HREF="../../../org/geotools/feature/collection/RandomFeatureAccess.html" title="interface in org.geotools.feature.collection">RandomFeatureAccess</A>, <A HREF="../../../org/geotools/feature/SimpleFeature.html" title="interface in org.geotools.feature">SimpleFeature</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../org/geotools/feature/collection/AbstractFeatureCollection.html" title="class in org.geotools.feature.collection">AbstractFeatureCollection</A>, <A HREF="../../../org/geotools/feature/AbstractFeatureCollection.html" title="class in org.geotools.feature">AbstractFeatureCollection</A>, <A HREF="../../../org/geotools/feature/collection/AbstractFeatureList.html" title="class in org.geotools.feature.collection">AbstractFeatureList</A>, <A HREF="../../../org/geotools/data/store/DataFeatureCollection.html" title="class in org.geotools.data.store">DataFeatureCollection</A>, <A HREF="../../../org/geotools/feature/DefaultFeature.html" title="class in org.geotools.feature">DefaultFeature</A>, <A HREF="../../../org/geotools/feature/DefaultFeatureCollection.html" title="class in org.geotools.feature">DefaultFeatureCollection</A>, <A HREF="../../../org/geotools/data/memory/MemoryFeatureCollection.html" title="class in org.geotools.data.memory">MemoryFeatureCollection</A>, <A HREF="../../../org/geotools/feature/collection/SubFeatureCollection.html" title="class in org.geotools.feature.collection">SubFeatureCollection</A>, <A HREF="../../../org/geotools/feature/collection/SubFeatureList.html" title="class in org.geotools.feature.collection">SubFeatureList</A></DD></DL><HR><DL><DT>public interface <B>Feature</B></DL><P><p> Represents a feature of arbitrary complexity. <p> This interface answers the question: How do we store feature attributes? (The answer to the more useful question, How do we access feature attribute, is contained in the Expression class. <p> <p> Warning: We are revising the Feature Model to be more complete in the next round of GeoTools. If you do any data access in your classes please try and make use of Expression to access your information, if you do this you will not be affected by the change (beyond a few search and replace operations). </p> The most generic approach would be to pass all feature attributes as objects and use Java variable and method references to access them.  However, this is also the most useless approach because it establishes no unified methods for getting attribute information (since it is totally Object dependent), without elaborate reflection/introspection, which is inconvenient to use. Unlike its <A HREF="../../../org/geotools/feature/FeatureType.html" title="interface in org.geotools.feature"><CODE>FeatureType</CODE></A> counterpart, this interface does not attempt to serve as a typing framework.  Rather, multiple implementations of this interface should generally be for performance reasons. </p> <p> This interface serves two important purposes.  Most obviously, it gives users of features a unified, consistent framework for accessing and manipulating feature data.  Perhaps more importantly,  the <code>FeatureType</code> and <code>Feature</code> interfaces also work together to give implementers a framework for constraining and enforcing constraints (respectively) on allowed feature types. As such, this interface is as general as possible in terms of the types of objects to which it provides access. Keep in mind that creating new features is relatively difficult and should only be done to optimize performance for highly constrained schema types. For the vast majority of schemas, the generic feature implementation will  work fine. </p> <p> <b>Notes for Feature Clients:</b><br> Clients should always use feature accessor methods (getAttribute and setAttribute) to modify the state of internal attribute objects.  It is possible that some feature implementations will allow object state changes by clients outside of the class, but this is strongly discouraged. In general, feature implementations will make defensive copies of objects passed to clients and it is therefore not guaranteed that client state changes that take place outside of the feature will be reflected in the internal state of the feature object!  <i>For this reason, clients should always use the set methods to change feature attribute object states!</i> </p> <p> <b>Notes for Feature Implementers:</b><br> It is the responsibility of the implementing class to ensure that the <code>Feature</code> attributes stay synchronized with its FeatureType definition. <i>Features should never get out of synch with their declared schemas and should never alter their schemas!</i>  There are four conventions of which implementers of this interface must be aware in order to successfully manage a <code>Feature</code>: </p> <ol> <li> <b>FeatureType Reference</b><br> Features must always hold a single (immutable: see <code>FeatureType</code>) schema reference and this reference should not be altered after a feature has been created.  To ensure this, is is strongly recommended that features take a valid reference to an existing immutable schema in its constructor and declare that reference final. </li> <li> <b>Default Geometry</b><br> Each feature must have a default geometry, but this primary geometry may be null.  This means that a feature may contain no geometries, but it must always have a method for accessing a geometry object (even if it is null). It also means that a feature with multiple geometries must pick one as its default geometry.  Note that the designation of the default geometry is stored as part of the <code>FeatureType</code> and is therefore immmutable. </li> <li> <b>Attributes</b><br> All features contain zero or more attributes, which can have one or more occurrences inside the feature.  Attributes may be any valid Java object. If attributes are instances of <code>Feature</code>, they are handled specially by the <code>Feature</code> methods, in that their attributes may be accessed directly by their containing feature.  All other object variables and methods must be accessed through the objects themselves. It is up to implementers of <code>Feature</code> to make sure that each attribute value conforms to its internal schema.  A feature should never reach a state where its attributes (or sub-attributes) do not conform to their <code>FeatureType</code> definitions.  There are three ways to implement this.  The first is to simply make features immutable; however, given the ubiquity and required flexibility of features, this is likely not possible. The second (and second easiest), is to make all feature attributes immutable. For most cases, this is probably the best way to handle this issue. The third way, is to never give out a reference that would allow a client to change an attribute object's class (most obviously, an array reference). Generally speaking, features should attempt to minimize external object references by attempting to clone incoming attributes before adding them and outgoing attributes before sending them. For features with non-cloneable attributes, of course, this is not possible, so this is left to the discretion of the implementor. </li> <li> <b>Constructors</b><br> Constructors should take arguments with enough information to create a valid representation of the feature.  They should also always include a  valid schema that can be used to check the proposed attributes.  This is necessary to ensure that the feature is always in a valid state, relative to its schema. </li> <li> <b>hashCode() and equals(Object other)</b><br> Determining equality and equivalence for Feature instances is of utmost importance. This must be done in a constistent manner, as many other areas of geotools will rely on these relations. See java.lang.Object for details. </li> </ol><P><P><DL><DT><B>Author:</B></DT>  <DD>James Macgill, CCG, Rob Hranac, TOPP, Ian Schneider, USDA-ARS, dzwiers</DD><DT><B>See Also:</B><DD><A HREF="../../../org/geotools/feature/FeatureType.html" title="interface in org.geotools.feature"><CODE>FeatureType</CODE></A>, <A HREF="../../../org/geotools/feature/DefaultFeature.html" title="class in org.geotools.feature"><CODE>DefaultFeature</CODE></A><DT><B>Module:</B></DT><DD><CODE><B>module/api</B></CODE> &nbsp; (<A HREF="http://maven.geotools.fr/repository/org/geotools/gt2-api/"><CODE>gt2-api.jar</CODE></A>) (<A HREF="http://maven.geotools.fr/reports/api/index.html">Maven report</A>) (<A HREF="http://svn.geotools.org/geotools/tags/2.3.2/module/api/src/org/geotools/feature/Feature.java">SVN head</A>)</DD></DL><HR><P>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?