/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.31
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.gdal.ogr;

import org.gdal.osr.SpatialReference;

public class Layer {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Layer(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Layer obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      throw new UnsupportedOperationException("C++ destructor does not have public access");
    }
    swigCPtr = 0;
  }

  protected static long getCPtrAndDisown(Layer obj) {
    if (obj != null) obj.swigCMemOwn= false;
    return getCPtr(obj);
  }

  public int GetRefCount() {
    return ogrJNI.Layer_GetRefCount(swigCPtr, this);
  }

  public void SetSpatialFilter(Geometry filter) {
    ogrJNI.Layer_SetSpatialFilter(swigCPtr, this, Geometry.getCPtr(filter), filter);
  }

  public void SetSpatialFilterRect(double minx, double miny, double maxx, double maxy) {
    ogrJNI.Layer_SetSpatialFilterRect(swigCPtr, this, minx, miny, maxx, maxy);
  }

  public Geometry GetSpatialFilter() {
    long cPtr = ogrJNI.Layer_GetSpatialFilter(swigCPtr, this);
    return (cPtr == 0) ? null : new Geometry(cPtr, false);
  }

  public int SetAttributeFilter(String filter_string) {
    return ogrJNI.Layer_SetAttributeFilter(swigCPtr, this, filter_string);
  }

  public void ResetReading() {
    ogrJNI.Layer_ResetReading(swigCPtr, this);
  }

  public String GetName() {
    return ogrJNI.Layer_GetName(swigCPtr, this);
  }

  public Feature GetFeature(int fid) {
    long cPtr = ogrJNI.Layer_GetFeature(swigCPtr, this, fid);
    return (cPtr == 0) ? null : new Feature(cPtr, true);
  }

  public Feature GetNextFeature() {
    long cPtr = ogrJNI.Layer_GetNextFeature(swigCPtr, this);
    return (cPtr == 0) ? null : new Feature(cPtr, true);
  }

  public int SetNextByIndex(int new_index) {
    return ogrJNI.Layer_SetNextByIndex(swigCPtr, this, new_index);
  }

  public int SetFeature(Feature feature) {
    return ogrJNI.Layer_SetFeature(swigCPtr, this, Feature.getCPtr(feature), feature);
  }

  public int CreateFeature(Feature feature) {
    return ogrJNI.Layer_CreateFeature(swigCPtr, this, Feature.getCPtr(feature), feature);
  }

  public int DeleteFeature(int fid) {
    return ogrJNI.Layer_DeleteFeature(swigCPtr, this, fid);
  }

  public int SyncToDisk() {
    return ogrJNI.Layer_SyncToDisk(swigCPtr, this);
  }

  public FeatureDefn GetLayerDefn() {
    long cPtr = ogrJNI.Layer_GetLayerDefn(swigCPtr, this);
    return (cPtr == 0) ? null : new FeatureDefn(cPtr, false);
  }

  public int GetFeatureCount(int force) {
    return ogrJNI.Layer_GetFeatureCount(swigCPtr, this, force);
  }

  public int GetExtent(double[] argout, int force) {
    return ogrJNI.Layer_GetExtent(swigCPtr, this, argout, force);
  }

  public boolean TestCapability(String cap) {
    return ogrJNI.Layer_TestCapability(swigCPtr, this, cap);
  }

  public int CreateField(FieldDefn field_def, int approx_ok) {
    return ogrJNI.Layer_CreateField(swigCPtr, this, FieldDefn.getCPtr(field_def), field_def, approx_ok);
  }

  public int StartTransaction() {
    return ogrJNI.Layer_StartTransaction(swigCPtr, this);
  }

  public int CommitTransaction() {
    return ogrJNI.Layer_CommitTransaction(swigCPtr, this);
  }

  public int RollbackTransaction() {
    return ogrJNI.Layer_RollbackTransaction(swigCPtr, this);
  }

  public SpatialReference GetSpatialRef() {
    long cPtr = ogrJNI.Layer_GetSpatialRef(swigCPtr, this);
    return (cPtr == 0) ? null : new SpatialReference(cPtr, false);
  }

  public SWIGTYPE_p_GIntBig GetFeatureRead() {
    return new SWIGTYPE_p_GIntBig(ogrJNI.Layer_GetFeatureRead(swigCPtr, this), true);
  }

}
