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

namespace OSGeo.OGR {

using System;
using System.Runtime.InteropServices;

public class SpatialReference : IDisposable {
  private HandleRef swigCPtr;
  protected object swigCMemOwner;

  internal SpatialReference(IntPtr cPtr, object cMemoryOwner) {
    swigCMemOwner = cMemoryOwner;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(SpatialReference obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }
  internal static HandleRef getCPtrAndDisown(SpatialReference obj, object cMemoryOwner) {
    obj.swigCMemOwner = cMemoryOwner;
    return getCPtr(obj);
  }

  ~SpatialReference() {
    Dispose();
  }

  public virtual void Dispose() {
  lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwner == null) {
        swigCMemOwner = new object();
        osrPINVOKE.delete_SpatialReference(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
    }
  }

  public SpatialReference(string wkt) : this(osrPINVOKE.new_SpatialReference(wkt), null) {
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
  }

  public string __str__() {
    string ret = osrPINVOKE.SpatialReference___str__(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int IsSame(SpatialReference rhs) {
    int ret = osrPINVOKE.SpatialReference_IsSame(swigCPtr, SpatialReference.getCPtr(rhs));
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int IsSameGeogCS(SpatialReference rhs) {
    int ret = osrPINVOKE.SpatialReference_IsSameGeogCS(swigCPtr, SpatialReference.getCPtr(rhs));
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int IsGeographic() {
    int ret = osrPINVOKE.SpatialReference_IsGeographic(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int IsProjected() {
    int ret = osrPINVOKE.SpatialReference_IsProjected(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int IsLocal() {
    int ret = osrPINVOKE.SpatialReference_IsLocal(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetAttrValue(string name, int child) {
    string ret = osrPINVOKE.SpatialReference_GetAttrValue(swigCPtr, name, child);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetAttrValue(string name, string value) {
    int ret = osrPINVOKE.SpatialReference_SetAttrValue(swigCPtr, name, value);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetAngularUnits(string name, double to_radians) {
    int ret = osrPINVOKE.SpatialReference_SetAngularUnits(swigCPtr, name, to_radians);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double GetAngularUnits() {
    double ret = osrPINVOKE.SpatialReference_GetAngularUnits(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetLinearUnits(string name, double to_meters) {
    int ret = osrPINVOKE.SpatialReference_SetLinearUnits(swigCPtr, name, to_meters);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double GetLinearUnits() {
    double ret = osrPINVOKE.SpatialReference_GetLinearUnits(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetLinearUnitsName() {
    string ret = osrPINVOKE.SpatialReference_GetLinearUnitsName(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetAuthorityCode(string target_key) {
    string ret = osrPINVOKE.SpatialReference_GetAuthorityCode(swigCPtr, target_key);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetAuthorityName(string target_key) {
    string ret = osrPINVOKE.SpatialReference_GetAuthorityName(swigCPtr, target_key);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetUTM(int zone, int north) {
    int ret = osrPINVOKE.SpatialReference_SetUTM(swigCPtr, zone, north);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetStatePlane(int zone, int is_nad83, string unitsname, double units) {
    int ret = osrPINVOKE.SpatialReference_SetStatePlane(swigCPtr, zone, is_nad83, unitsname, units);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int AutoIdentifyEPSG() {
    int ret = osrPINVOKE.SpatialReference_AutoIdentifyEPSG(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetProjection(string arg) {
    int ret = osrPINVOKE.SpatialReference_SetProjection(swigCPtr, arg);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetProjParm(string name, double val) {
    int ret = osrPINVOKE.SpatialReference_SetProjParm(swigCPtr, name, val);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double GetProjParm(string name, double default_val) {
    double ret = osrPINVOKE.SpatialReference_GetProjParm(swigCPtr, name, default_val);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetNormProjParm(string name, double val) {
    int ret = osrPINVOKE.SpatialReference_SetNormProjParm(swigCPtr, name, val);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double GetNormProjParm(string name, double default_val) {
    double ret = osrPINVOKE.SpatialReference_GetNormProjParm(swigCPtr, name, default_val);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetACEA(double stdp1, double stdp2, double clat, double clong, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetACEA(swigCPtr, stdp1, stdp2, clat, clong, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetAE(double clat, double clon, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetAE(swigCPtr, clat, clon, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetCS(double clat, double clong, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetCS(swigCPtr, clat, clong, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetBonne(double clat, double clong, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetBonne(swigCPtr, clat, clong, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetEC(double stdp1, double stdp2, double clat, double clong, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetEC(swigCPtr, stdp1, stdp2, clat, clong, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetEckertIV(double cm, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetEckertIV(swigCPtr, cm, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetEckertVI(double cm, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetEckertVI(swigCPtr, cm, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetEquirectangular(double clat, double clong, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetEquirectangular(swigCPtr, clat, clong, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetGS(double cm, double fe, double fn) {
    int ret = osrPINVOKE.SpatialReference_SetGS(swigCPtr, cm, fe, fn);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetWellKnownGeogCS(string name) {
    int ret = osrPINVOKE.SpatialReference_SetWellKnownGeogCS(swigCPtr, name);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetFromUserInput(string name) {
    int ret = osrPINVOKE.SpatialReference_SetFromUserInput(swigCPtr, name);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int CopyGeogCSFrom(SpatialReference rhs) {
    int ret = osrPINVOKE.SpatialReference_CopyGeogCSFrom(swigCPtr, SpatialReference.getCPtr(rhs));
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetTOWGS84(double p1, double p2, double p3, double p4, double p5, double p6, double p7) {
    int ret = osrPINVOKE.SpatialReference_SetTOWGS84(swigCPtr, p1, p2, p3, p4, p5, p6, p7);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetTOWGS84(double[] argout) {
    int ret = osrPINVOKE.SpatialReference_GetTOWGS84(swigCPtr, argout);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetGeogCS(string pszGeogName, string pszDatumName, string pszEllipsoidName, double dfSemiMajor, double dfInvFlattening, string pszPMName, double dfPMOffset, string pszUnits, double dfConvertToRadians) {
    int ret = osrPINVOKE.SpatialReference_SetGeogCS(swigCPtr, pszGeogName, pszDatumName, pszEllipsoidName, dfSemiMajor, dfInvFlattening, pszPMName, dfPMOffset, pszUnits, dfConvertToRadians);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetProjCS(string name) {
    int ret = osrPINVOKE.SpatialReference_SetProjCS(swigCPtr, name);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromWkt(SWIGTYPE_p_p_char ppszInput) {
    int ret = osrPINVOKE.SpatialReference_ImportFromWkt(swigCPtr, SWIGTYPE_p_p_char.getCPtr(ppszInput));
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromProj4(string ppszInput) {
    int ret = osrPINVOKE.SpatialReference_ImportFromProj4(swigCPtr, ppszInput);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromESRI(SWIGTYPE_p_p_char ppszInput) {
    int ret = osrPINVOKE.SpatialReference_ImportFromESRI(swigCPtr, SWIGTYPE_p_p_char.getCPtr(ppszInput));
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromEPSG(int arg) {
    int ret = osrPINVOKE.SpatialReference_ImportFromEPSG(swigCPtr, arg);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromPCI(string proj, string units, double[] argin) {
    int ret = osrPINVOKE.SpatialReference_ImportFromPCI(swigCPtr, proj, units, argin);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromUSGS(int proj_code, int zone, double[] argin, int datum_code) {
    int ret = osrPINVOKE.SpatialReference_ImportFromUSGS(swigCPtr, proj_code, zone, argin, datum_code);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ImportFromXML(string xmlString) {
    int ret = osrPINVOKE.SpatialReference_ImportFromXML(swigCPtr, xmlString);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ExportToWkt(out string argout) {
    int ret = osrPINVOKE.SpatialReference_ExportToWkt(swigCPtr, out argout);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ExportToPrettyWkt(out string argout, int simplify) {
    int ret = osrPINVOKE.SpatialReference_ExportToPrettyWkt(swigCPtr, out argout, simplify);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ExportToProj4(out string argout) {
    int ret = osrPINVOKE.SpatialReference_ExportToProj4(swigCPtr, out argout);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ExportToPCI(out string proj, out string units) {
    int ret = osrPINVOKE.SpatialReference_ExportToPCI(swigCPtr, out proj, out units);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ExportToUSGS(out int code, out int zone, out int datum) {
    int ret = osrPINVOKE.SpatialReference_ExportToUSGS(swigCPtr, out code, out zone, out datum);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ExportToXML(out string argout, string dialect) {
    int ret = osrPINVOKE.SpatialReference_ExportToXML(swigCPtr, out argout, dialect);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public SpatialReference CloneGeogCS() {
    IntPtr cPtr = osrPINVOKE.SpatialReference_CloneGeogCS(swigCPtr);
    SpatialReference ret = (cPtr == IntPtr.Zero) ? null : new SpatialReference(cPtr, true? null : this);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int Validate() {
    int ret = osrPINVOKE.SpatialReference_Validate(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int StripCTParms() {
    int ret = osrPINVOKE.SpatialReference_StripCTParms(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int FixupOrdering() {
    int ret = osrPINVOKE.SpatialReference_FixupOrdering(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int Fixup() {
    int ret = osrPINVOKE.SpatialReference_Fixup(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int MorphToESRI() {
    int ret = osrPINVOKE.SpatialReference_MorphToESRI(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int MorphFromESRI() {
    int ret = osrPINVOKE.SpatialReference_MorphFromESRI(swigCPtr);
    if (osrPINVOKE.SWIGPendingException.Pending) throw osrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
