com.esri.arcgis.carto
Class FeatureIndex

java.lang.Object
  extended by com.esri.arcgis.carto.FeatureIndex
All Implemented Interfaces:
IFeatureIndex, IFeatureIndex2, IIndexQuery, IIndexQuery2, com.esri.arcgis.interop.RemoteObjRef, Serializable

public class FeatureIndex
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, IFeatureIndex, IFeatureIndex2, IIndexQuery, IIndexQuery2

A feature class index.

Description

The FeatureIndex object is used to build a spatial index of features from a FeatureClass in memory for the purpose of finding the intersected features, nearest features, and within features.

Since there is a fair amount of overhead required to build this index, it is not efficient to use this object if the spatial operation is only going to be applied once. However, if many spatial queries are to be performed over the same set of features, than you may gain some performance benefits using this object.

It is important to always make sure that the Spatial References between the FeatureClass used to build the FeatureIndex and the query shape are either the same or IFeatureIndex.OutputSpatialReference has been called. Otherwise, the results will not be correct.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

See Also:
Serialized Form

Constructor Summary
FeatureIndex()
          Constructs a FeatureIndex using ArcGIS Engine.
FeatureIndex(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
FeatureIndex theFeatureIndex = (FeatureIndex) obj;
 
Method Summary
 boolean equals(Object o)
          Compare this object with another
static String getClsid()
          getClsid.
 ISpatialReference getOutputSpatialReference(String fieldName)
          The spatial reference in which to output geometry for a given field.
 IFeatureCursor getWithin(IGeometry pShape)
          Finds all features that the input shape lies within.
 int hashCode()
          the hashcode for this object
 void index(ITrackCancel pTrackCancel, IEnvelope pQueryingGeometryFullExtent)
          Creates index.
 void intersectedFeatures(IGeometry pShape, Object[] pSAIds)
          Finds all intersected features in index to the input shape.
 void nearestFeature(IGeometry pShape, int[] pClosestFeatureFID, double[] pDistance)
          Finds the nearest feature in index to the input shape.
 void nearestFeatures(IGeometry pShape, Object[] pSAIds, double[] pDistance)
          Finds all nearest features in index to the input shape (i.e.
 void setFeatureClassByRef(IFeatureClass rhs1)
          FeatureClass to index.
 void setFeatureCursorByRef(IFeatureCursor rhs1)
          Cursor on feature class, to reduce the number of feature indexed (optional).
 void setOutputSpatialReferenceByRef(String fieldName, ISpatialReference outputSpatialReference)
          The spatial reference in which to output geometry for a given field.
 int withinFeature(IGeometry pShape)
          Finds the first feature that the input shape lies within.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

FeatureIndex

public FeatureIndex()
             throws IOException,
                    UnknownHostException
Constructs a FeatureIndex using ArcGIS Engine.

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

FeatureIndex

public FeatureIndex(Object obj)
             throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
FeatureIndex theFeatureIndex = (FeatureIndex) obj;

Construct a FeatureIndex using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to FeatureIndex.

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems
Method Detail

getClsid

public static String getClsid()
getClsid.


equals

public boolean equals(Object o)
Compare this object with another

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

setFeatureClassByRef

public void setFeatureClassByRef(IFeatureClass rhs1)
                          throws IOException,
                                 AutomationException
FeatureClass to index.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
setFeatureClassByRef in interface IFeatureIndex
Specified by:
setFeatureClassByRef in interface IFeatureIndex2
Parameters:
rhs1 - A reference to a com.esri.arcgis.geodatabase.IFeatureClass (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setFeatureCursorByRef

public void setFeatureCursorByRef(IFeatureCursor rhs1)
                           throws IOException,
                                  AutomationException
Cursor on feature class, to reduce the number of feature indexed (optional).

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
setFeatureCursorByRef in interface IFeatureIndex
Specified by:
setFeatureCursorByRef in interface IFeatureIndex2
Parameters:
rhs1 - A reference to a com.esri.arcgis.geodatabase.IFeatureCursor (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

index

public void index(ITrackCancel pTrackCancel,
                  IEnvelope pQueryingGeometryFullExtent)
           throws IOException,
                  AutomationException
Creates index.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
index in interface IFeatureIndex
Specified by:
index in interface IFeatureIndex2
Parameters:
pTrackCancel - A reference to a com.esri.arcgis.system.ITrackCancel (in)
pQueryingGeometryFullExtent - A reference to a com.esri.arcgis.geometry.IEnvelope (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getOutputSpatialReference

public ISpatialReference getOutputSpatialReference(String fieldName)
                                            throws IOException,
                                                   AutomationException
The spatial reference in which to output geometry for a given field.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
getOutputSpatialReference in interface IFeatureIndex2
Parameters:
fieldName - The fieldName (in)
Returns:
A reference to a com.esri.arcgis.geometry.ISpatialReference
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setOutputSpatialReferenceByRef

public void setOutputSpatialReferenceByRef(String fieldName,
                                           ISpatialReference outputSpatialReference)
                                    throws IOException,
                                           AutomationException
The spatial reference in which to output geometry for a given field.

Description

Sets the current Output SpatialReference. It is important that this is set to the same SpatialReference as the input Shape's SpatialReference used as input in the IIndexQuery methods.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
setOutputSpatialReferenceByRef in interface IFeatureIndex2
Parameters:
fieldName - The fieldName (in)
outputSpatialReference - A reference to a com.esri.arcgis.geometry.ISpatialReference (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

nearestFeature

public void nearestFeature(IGeometry pShape,
                           int[] pClosestFeatureFID,
                           double[] pDistance)
                    throws IOException,
                           AutomationException
Finds the nearest feature in index to the input shape.

Description

Returns the nearest indexed feature and the distance to it based on the input shape.

Pass the returned long into IFeatureClass.GetFeature to get the corresponding feature.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
nearestFeature in interface IIndexQuery
Specified by:
nearestFeature in interface IIndexQuery2
Parameters:
pShape - A reference to a com.esri.arcgis.geometry.IGeometry (in)
pClosestFeatureFID - The pClosestFeatureFID (out: use single element array)
pDistance - The pDistance (out: use single element array)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getWithin

public IFeatureCursor getWithin(IGeometry pShape)
                         throws IOException,
                                AutomationException
Finds all features that the input shape lies within.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
getWithin in interface IIndexQuery
Specified by:
getWithin in interface IIndexQuery2
Parameters:
pShape - A reference to a com.esri.arcgis.geometry.IGeometry (in)
Returns:
A reference to a com.esri.arcgis.geodatabase.IFeatureCursor
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

nearestFeatures

public void nearestFeatures(IGeometry pShape,
                            Object[] pSAIds,
                            double[] pDistance)
                     throws IOException,
                            AutomationException
Finds all nearest features in index to the input shape (i.e. equal distance).

Description

Returns the nearest indexed features in a variant array and the distance to them based on the input shape.

It is similar to the NearestFeature (no final S) method except that if two or more features are found as the closest and so are exactly at the same distance from the source geometry, then all those are returned in the array.

Pass the returned array into IFeatureClass.GetFeatures to get the corresponding features.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
nearestFeatures in interface IIndexQuery2
Parameters:
pShape - A reference to a com.esri.arcgis.geometry.IGeometry (in)
pSAIds - A Variant (out: use single element array)
pDistance - The pDistance (out: use single element array)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

intersectedFeatures

public void intersectedFeatures(IGeometry pShape,
                                Object[] pSAIds)
                         throws IOException,
                                AutomationException
Finds all intersected features in index to the input shape.

Description

Returns the indexed features in an variant array that intersect the input shape.

Pass the returned array into IFeatureClass.GetFeatures to get the corresponding features

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
intersectedFeatures in interface IIndexQuery2
Parameters:
pShape - A reference to a com.esri.arcgis.geometry.IGeometry (in)
pSAIds - A Variant (out: use single element array)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

withinFeature

public int withinFeature(IGeometry pShape)
                  throws IOException,
                         AutomationException
Finds the first feature that the input shape lies within.

Description

Returns the ObjectID of the first feature in the spatial index for which the input shape is within. -1 is returned in the case where the input shape is not within any features in the index.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
withinFeature in interface IIndexQuery2
Parameters:
pShape - A reference to a com.esri.arcgis.geometry.IGeometry (in)
Returns:
The pWithinFeatureFID
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.