Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gdal.ogr
Class Feature

    java.lang.Object
      org.gdal.ogr.Feature

All Implemented Interfaces:
  Cloneable

    public class Feature

extends Object
implements Cloneable

A simple feature, including geometry and attributes.

The Feature class is a binding for the C++ OGRFeature class.

Constructor Summary
`Feature(FeatureDefn feature_def)` Constructor.

Method Summary
`Object` | `clone()`
`Feature` | `Clone()` Duplicate feature.
`void` | `delete()` Delete (in memory) a feature.
`void` | `DumpReadable()` Dump this feature in a human readable form.
`boolean` | `Equal(Feature feature)` Test if two features are the same.
`boolean` | `equals(Object obj)`
`FeatureDefn` | `GetDefnRef()` Fetch feature definition.
`int` | `GetFID()` Get feature identifier.
`void` | `GetFieldAsDateTime(int ifield, int[] pnYear, int[] pnMonth, int[] pnDay, int[] pnHour, int[] pnMinute, int[] pnSecond, int[] pnTZFlag)` Fetch field value as date and time.
`double` | `GetFieldAsDouble(int ifield)` Fetch field value as a double.
`double` | `GetFieldAsDouble(String name)` Fetch field value as a double.
`double[]` | `GetFieldAsDoubleList(int ifield)` Fetch field value as a list of doubles.
`int` | `GetFieldAsInteger(int ifield)` Fetch field value as integer.
`int` | `GetFieldAsInteger(String name)` Fetch field value as integer.
`int[]` | `GetFieldAsIntegerList(int ifield)` Fetch field value as a list of integers.
`String` | `GetFieldAsString(int ifield)` Fetch field value as a string.
`String` | `GetFieldAsString(String name)` Fetch field value as a string.
`String[]` | `GetFieldAsStringList(int ifield)` Fetch field value as a list of strings.
`int` | `GetFieldCount()` Fetch number of fields on this feature.
`FieldDefn` | `GetFieldDefnRef(int ifield)` Fetch definition for this field.
`FieldDefn` | `GetFieldDefnRef(String name)` Fetch definition for this field.
`int` | `GetFieldIndex(String name)` Fetch the field index given field name.
`int` | `GetFieldType(int ifield)` Fetch the field type.
`int` | `GetFieldType(String name)` Fetch the field type.
`Geometry` | `GetGeometryRef()` Fetch pointer to feature geometry.
`String` | `GetStyleString()` Fetch style string for this feature.
`int` | `hashCode()`
`boolean` | `IsFieldSet(int ifield)` Test if a field has ever been assigned a value or not.
`boolean` | `IsFieldSet(String name)` Test if a field has ever been assigned a value or not.
`int` | `SetFID(int fid)` Set the feature identifier.
`void` | `SetField(int ifield, double val)` Set field to double value.
`void` | `SetField(int ifield, int val)` Set field to integer value.
`void` | `SetField(int ifield, int year, int month, int day, int hour, int minute, int second, int tzflag)` Set field to date.
`void` | `SetField(int ifield, String val)` Set field to string value.
`void` | `SetField(String name, double val)` Set field to double value.
`void` | `SetField(String name, int val)` Set field to integer value.
`void` | `SetField(String name, int year, int month, int day, int hour, int minute, int second, int tzflag)` Set field to date.
`void` | `SetField(String name, String val)` Set field to string value.
`void` | `SetFieldDoubleList(int ifield, double[] values)` Set field to list of doubles value.
`void` | `SetFieldIntegerList(int ifield, int[] values)` Set field to list of integers value.
`void` | `SetFieldStringList(int ifield, Vector values)` Set field to list of strings value.
`int` | `SetFrom(Feature srcFeature)` Set one feature from another.
`int` | `SetFrom(Feature srcFeature, int forgiving)` Set one feature from another.
`int` | `SetFromWithMap(Feature srcFeature, int forgiving, int[] map)` Set one feature from another.
`int` | `SetGeometry(Geometry geom)` Set feature geometry.
`int` | `SetGeometryDirectly(Geometry geom)` Set feature geometry.
`void` | `SetStyleString(String style_string)` Set feature style string.
`void` | `UnsetField(int ifield)` Clear a field, marking it as unset.
`void` | `UnsetField(String name)` Clear a field, marking it as unset.

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Feature

    public Feature(FeatureDefn feature_def)

  Constructor.

  Note that the Feature will increment the reference count of its defining FeatureDefn.

  Parameters:
    `feature_def` - feature class (layer) definition to which the feature will adhere.

Method Detail

### delete

    public void delete()

  Delete (in memory) a feature.

  Calling this method is not required as normal garbage collection will reclaim associated resources when the object goes out of scope. Otherwise calling delete() explicitely will help release resources sooner. Don't call any method on a deleted object !

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### clone

    public Object clone()

  Overrides:
    `clone` in class `Object`

### GetDefnRef

    public FeatureDefn GetDefnRef()

  Fetch feature definition.

  Returns:
    a reference to the feature definition object.

### SetGeometry

    public int SetGeometry(Geometry geom)

  Set feature geometry.

  This method updates the features geometry, and operate exactly as SetGeometryDirectly(), except that this method does not assume ownership of the passed geometry, but instead makes a copy of it.

  Parameters:
    `geom` - new geometry to apply to feature. Passing null value here is correct and it will result in deallocation of currently assigned geometry without assigning new one.
  Returns:
    0 if successful, or throws a RuntimeException (or an error code if DontUseExceptions() has been called) if the geometry type is illegal for the FeatureDefn (checking not yet implemented).

### SetGeometryDirectly

    public int SetGeometryDirectly(Geometry geom)

  Set feature geometry.

  This method updates the features geometry, and operate exactly as SetGeometry(), except that this method assumes ownership of the passed geometry.

  Parameters:
    `geom` - new geometry to apply to feature. Passing null value here is correct and it will result in deallocation of currently assigned geometry without assigning new one.
  Returns:
    0 if successful, or throws a RuntimeException (or an error code if DontUseExceptions() has been called) if the geometry type is illegal for the FeatureDefn (checking not yet implemented).

### GetGeometryRef

    public Geometry GetGeometryRef()

  Fetch pointer to feature geometry.

  Returns:
    internal feature geometry (or null if no geometry). This object should not be modified.

### Clone

    public Feature Clone()

  Duplicate feature.

  The newly created feature is owned by the caller, and will have its own reference to the FeatureDefn.

  Returns:
    new feature, exactly matching this feature.

### Equal

    public boolean Equal(Feature feature)

  Test if two features are the same.

  Two features are considered equal if they share the (pointer equality) same FeatureDefn, have the same field values, and the same geometry (as tested by Geometry.Equal()) as well as the same feature id.

  Parameters:
    `feature` - the other feature to test this one against.
  Returns:
    true if they are equal, otherwise false.

### GetFieldCount

    public int GetFieldCount()

  Fetch number of fields on this feature. This will always be the same as the field count for the FeatureDefn.

  Returns:
    count of fields.

### GetFieldDefnRef

    public FieldDefn GetFieldDefnRef(int ifield)

  Fetch definition for this field.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field definition (from the FeatureDefn).

### GetFieldDefnRef

    public FieldDefn GetFieldDefnRef(String name)

  Fetch definition for this field.

  Parameters:
    `name` - the name of the field to fetch.
  Returns:
    the field definition (from the FeatureDefn).

### GetFieldAsString

    public String GetFieldAsString(int ifield)

  Fetch field value as a string.

  OFTReal and OFTInteger fields will be translated to string using sprintf(), but not necessarily using the established formatting rules. Other field types, or errors will result in a return value of zero.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field value.

### GetFieldAsString

    public String GetFieldAsString(String name)

  Fetch field value as a string.

  OFTReal and OFTInteger fields will be translated to string using sprintf(), but not necessarily using the established formatting rules. Other field types, or errors will result in a return value of zero.

  Parameters:
    `name` - the name of the field to fetch.
  Returns:
    the field value.

### GetFieldAsInteger

    public int GetFieldAsInteger(int ifield)

  Fetch field value as integer.

  OFTString features will be translated using atoi(). OFTReal fields will be cast to integer. Other field types, or errors will result in a return value of zero.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field value.

### GetFieldAsInteger

    public int GetFieldAsInteger(String name)

  Fetch field value as integer.

  OFTString features will be translated using atoi(). OFTReal fields will be cast to integer. Other field types, or errors will result in a return value of zero.

  Parameters:
    `name` - the name of the field to fetch.
  Returns:
    the field value.

### GetFieldAsDouble

    public double GetFieldAsDouble(int ifield)

  Fetch field value as a double.

  OFTString features will be translated using atof(). OFTInteger fields will be cast to double. Other field types, or errors will result in a return value of zero.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field value.

### GetFieldAsDouble

    public double GetFieldAsDouble(String name)

  Fetch field value as a double.

  OFTString features will be translated using atof(). OFTInteger fields will be cast to double. Other field types, or errors will result in a return value of zero.

  Parameters:
    `name` - the name of the field to fetch.
  Returns:
    the field value.

### GetFieldAsDateTime

    public void GetFieldAsDateTime(int ifield,
                                   int[] pnYear,
                                   int[] pnMonth,
                                   int[] pnDay,
                                   int[] pnHour,
                                   int[] pnMinute,
                                   int[] pnSecond,
                                   int[] pnTZFlag)

  Fetch field value as date and time.

  Currently this method only works for OFTDate, OFTTime and OFTDateTime fields.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
    `pnYear` - an allocated array of 1 integer to put the year (including century)
    `pnMonth` - an allocated array of 1 integer to put the month (1-12)
    `pnDay` - an allocated array of 1 integer to put the day (1-31)
    `pnHour` - an allocated array of 1 integer to put the hour (0-23)
    `pnMinute` - an allocated array of 1 integer to put the minute (0-59)
    `pnSecond` - an allocated array of 1 integer to put the second (0-59)
    `pnTZFlag` - an allocated array of 1 integer to put the time zone flag (0=unknown, 1=localtime, 100=GMT, see data model for details)

### GetFieldAsIntegerList

    public int[] GetFieldAsIntegerList(int ifield)

  Fetch field value as a list of integers.

  Currently this method only works for OFTIntegerList fields.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field value. The returned value may be null.
  Since:
    Java bindings 1.7.0

### GetFieldAsDoubleList

    public double[] GetFieldAsDoubleList(int ifield)

  Fetch field value as a list of doubles.

  Currently this method only works for OFTRealList fields.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field value. The returned value may be null.
  Since:
    Java bindings 1.7.0

### GetFieldAsStringList

    public String[] GetFieldAsStringList(int ifield)

  Fetch field value as a list of strings.

  Currently this method only works for OFTStringList fields.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field value. The returned value may be null.
  Since:
    Java bindings 1.7.0

### IsFieldSet

    public boolean IsFieldSet(int ifield)

  Test if a field has ever been assigned a value or not.

  Parameters:
    `ifield` - the field to test.
  Returns:
    true if the field has been set, otherwise false.

### IsFieldSet

    public boolean IsFieldSet(String name)

  Test if a field has ever been assigned a value or not.

  Parameters:
    `name` - the name of the field to test.
  Returns:
    true if the field has been set, otherwise false.

### GetFieldIndex

    public int GetFieldIndex(String name)

  Fetch the field index given field name. This is a cover for the FeatureDefn.GetFieldIndex() method.

  Parameters:
    `name` - the name of the field to search for.
  Returns:
    the field index, or -1 if no matching field is found.

### GetFID

    public int GetFID()

  Get feature identifier.

  Returns:
    feature id or OGRNullFID if none has been assigned.

### SetFID

    public int SetFID(int fid)

  Set the feature identifier.

  For specific types of features this operation may fail on illegal features ids. Generally it always succeeds. Feature ids should be greater than or equal to zero, with the exception of OGRNullFID (-1) indicating that the feature id is unknown.

  Parameters:
    `fid` - the new feature identifier value to assign.
  Returns:
    0 on success. Otherwise throws a RuntimeException (or an error code if DontUseExceptions() has been called).

### DumpReadable

    public void DumpReadable()

  Dump this feature in a human readable form.

  This dumps the attributes, and geometry; however, it doesn't definition information (other than field types and names), nor does it report the geometry spatial reference system. The standard output will be used.

### UnsetField

    public void UnsetField(int ifield)

  Clear a field, marking it as unset.

  Parameters:
    `ifield` - the field to unset, from 0 to GetFieldCount()-1.

### UnsetField

    public void UnsetField(String name)

  Clear a field, marking it as unset.

  Parameters:
    `name` - the name of the field to unset.

### SetField

    public void SetField(int ifield,
                         String val)

  Set field to string value.

  OFTInteger fields will be set based on an atoi() conversion of the string. OFTReal fields will be set based on an atof() conversion of the string. Other field types may be unaffected.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
    `val` - the value to assign.

### SetField

    public void SetField(String name,
                         String val)

  Set field to string value.

  OFTInteger fields will be set based on an atoi() conversion of the string. OFTReal fields will be set based on an atof() conversion of the string. Other field types may be unaffected.

  Parameters:
    `name` - the name of the field to set.
    `val` - the value to assign.

### SetField

    public void SetField(int ifield,
                         int val)

  Set field to integer value.

  OFTInteger and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
    `val` - the value to assign.

### SetField

    public void SetField(String name,
                         int val)

  Set field to integer value.

  OFTInteger and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

  Parameters:
    `name` - the name of the field to set.
    `val` - the value to assign.

### SetField

    public void SetField(int ifield,
                         double val)

  Set field to double value.

  OFTInteger and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
    `val` - the value to assign.

### SetField

    public void SetField(String name,
                         double val)

  Set field to double value.

  OFTInteger and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

  Parameters:
    `name` - the name of the field to set.
    `val` - the value to assign.

### SetField

    public void SetField(int ifield,
                         int year,
                         int month,
                         int day,
                         int hour,
                         int minute,
                         int second,
                         int tzflag)

  Set field to date.

  This method currently only has an effect for OFTDate, OFTTime and OFTDateTime fields.

  Parameters:
    `ifield` - the field to set, from 0 to GetFieldCount()-1.
    `year` - (including century)
    `month` - (1-12)
    `day` - (1-31)
    `hour` - (0-23)
    `minute` - (0-59)
    `second` - (0-59)
    `tzflag` - (0=unknown, 1=localtime, 100=GMT, see data model for details)

### SetField

    public void SetField(String name,
                         int year,
                         int month,
                         int day,
                         int hour,
                         int minute,
                         int second,
                         int tzflag)

  Set field to date.

  This method currently only has an effect for OFTDate, OFTTime and OFTDateTime fields.

  Parameters:
    `name` - the name of the field to set.
    `year` - (including century)
    `month` - (1-12)
    `day` - (1-31)
    `hour` - (0-23)
    `minute` - (0-59)
    `second` - (0-59)
    `tzflag` - (0=unknown, 1=localtime, 100=GMT, see data model for details)

### SetFieldIntegerList

    public void SetFieldIntegerList(int ifield,
                                    int[] values)

  Set field to list of integers value.

  This method currently on has an effect of OFTIntegerList fields.

  Parameters:
    `ifield` - the field to set, from 0 to GetFieldCount()-1.
    `values` - the values to assign.

### SetFieldDoubleList

    public void SetFieldDoubleList(int ifield,
                                   double[] values)

  Set field to list of doubles value.

  This method currently on has an effect of OFTRealList fields.

  Parameters:
    `ifield` - the field to set, from 0 to GetFieldCount()-1.
    `values` - the values to assign.

### SetFieldStringList

    public void SetFieldStringList(int ifield,
                                   Vector values)

  Set field to list of strings value.

  This method currently on has an effect of OFTStringList fields.

  Parameters:
    `ifield` - the field to set, from 0 to GetFieldCount()-1.
    `values` - the values to assign (vector of strings).
  Since:
    Java bindings 1.7.0

### SetFrom

    public int SetFrom(Feature srcFeature,
                       int forgiving)

  Set one feature from another.

  Overwrite the contents of this feature from the geometry and attributes of another. The srcFeature does not need to have the same FeatureDefn. Field values are copied by corresponding field names. Field types do not have to exactly match. SetField() method conversion rules will be applied as needed.

  Parameters:
    `srcFeature` - the feature from which geometry, and field values will be copied.
    `forgiving` - 1 if the operation should continue despite lacking output fields matching some of the source fields.
  Returns:
    0 if the operation succeeds, even if some values are not transferred, otherwise throws a RuntimeException (or an error code if DontUseExceptions() has been called).
  See Also:
    `SetFromWithMap(org.gdal.ogr.Feature srcFeature, int forgiving, int[] map)`

### SetFrom

    public int SetFrom(Feature srcFeature)

  Set one feature from another.

  Same as below with forgiving == 1

  Since:
    Java bindings 1.7.0
  See Also:
    `SetFrom(Feature srcFeature, int forgiving)`

### SetFromWithMap

    public int SetFromWithMap(Feature srcFeature,
                              int forgiving,
                              int[] map)

  Set one feature from another.

  Overwrite the contents of this feature from the geometry and attributes of another. The hOtherFeature does not need to have the same OGRFeatureDefn. Field values are copied according to the provided indices map. Field types do not have to exactly match. SetField() function conversion rules will be applied as needed. This is more efficient than SetFrom(Feature, int) in that this doesn't lookup the fields by their names. Particularly useful when the field names don't match.

  Parameters:
    `srcFeature` - the feature from which geometry, and field values will be copied.
    `forgiving` - 1 if the operation should continue despite lacking output fields matching some of the source fields.
    `map` - Array of the indices of the destination feature's fields stored at the corresponding index of the source feature's fields. A value of -1 should be used to ignore the source's field. The array should not be null and be as long as the number of fields in the source feature.
  Returns:
    0 if the operation succeeds, even if some values are not transferred, otherwise throws a RuntimeException (or an error code if DontUseExceptions() has been called).
  Since:
    OGR 1.8.0
  See Also:
    `SetFrom(org.gdal.ogr.Feature srcFeature, int forgiving)`

### GetStyleString

    public String GetStyleString()

  Fetch style string for this feature.

  Set the OGR Feature Style Specification for details on the format of this string, and ogr_featurestyle.h for services available to parse it.

  Returns:
    a reference to a representation in string format, or null if there isn't one.

### SetStyleString

    public void SetStyleString(String style_string)

  Set feature style string.

  Parameters:
    `style_string` - the style string to apply to this feature, cannot be null.

### GetFieldType

    public int GetFieldType(int ifield)

  Fetch the field type.

  This is a cover for the FeatureDefn.GetFieldType() method.

  Parameters:
    `ifield` - the field to fetch, from 0 to GetFieldCount()-1.
  Returns:
    the field type (like ogr.OFTInteger, etc.)

### GetFieldType

    public int GetFieldType(String name)

  Fetch the field type.

  This is a cover for the FeatureDefn.GetFieldType() method.

  Parameters:
    `name` - the name of the field to fetch.
  Returns:
    the field type (like ogr.OFTInteger, etc.)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD