/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3u-20020503-1857 (Alpha 5)
 * 
 * This file is not intended to be easily readable and contains a number of 
 * coding conventions designed to improve portability and efficiency. Do not make
 * changes to this file unless you know what you are doing--modify the SWIG 
 * interface file instead. 
 * ----------------------------------------------------------------------------- */

#define SWIGPYTHON
/***********************************************************************
 * common.swg
 *
 *     This file contains generic SWIG runtime support for pointer
 *     type checking as well as a few commonly used macros to control
 *     external linkage.
 *
 * Author : David Beazley (beazley@cs.uchicago.edu)
 *
 * Copyright (c) 1999-2000, The University of Chicago
 * 
 * This file may be freely redistributed without license or fee provided
 * this copyright message remains intact.
 ************************************************************************/

#include <string.h>

#if defined(_WIN32) || defined(__WIN32__)
#       if defined(_MSC_VER)
#               if defined(STATIC_LINKED)
#                       define SWIGEXPORT(a) a
#               else
#                       define SWIGEXPORT(a) __declspec(dllexport) a
#               endif
#       else
#               if defined(__BORLANDC__)
#                       define SWIGEXPORT(a) a _export
#               else
#                       define SWIGEXPORT(a) a
#       endif
#endif
#else
#       define SWIGEXPORT(a) a
#endif

#ifdef SWIG_GLOBAL
#define SWIGRUNTIME(a) SWIGEXPORT(a)
#else
#define SWIGRUNTIME(a) static a
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct swig_type_info {
  char  *name;                 
  void *(*converter)(void *);
  char  *str;
  struct swig_type_info  *next;
  struct swig_type_info  *prev;
} swig_type_info;

#ifdef SWIG_NOINCLUDE
SWIGEXPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
SWIGEXPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
SWIGEXPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
#else

static swig_type_info *swig_type_list = 0;

/* Register a type mapping with the type-checking */
SWIGRUNTIME(swig_type_info *)
SWIG_TypeRegister(swig_type_info *ti)
{
  swig_type_info *tc, *head, *ret, *next;
  /* Check to see if this type has already been registered */
  tc = swig_type_list;
  while (tc) {
    if (strcmp(tc->name, ti->name) == 0) {
      /* Already exists in the table.  Just add additional types to the list */
      head = tc;
      next = tc->next;
      goto l1;
    }
    tc = tc->prev;
  }
  head = ti;
  next = 0;

  /* Place in list */
  ti->prev = swig_type_list;
  swig_type_list = ti;

  /* Build linked lists */
 l1:
  ret = head;
  tc = ti + 1;
  /* Patch up the rest of the links */
  while (tc->name) {
    head->next = tc;
    tc->prev = head;
    head = tc;
    tc++;
  }
  head->next = next;
  return ret;
}

/* Check the typename */
SWIGRUNTIME(swig_type_info *) 
SWIG_TypeCheck(char *c, swig_type_info *ty)
{
  swig_type_info *s;
  if (!ty) return 0;        /* Void pointer */
  s = ty->next;             /* First element always just a name */
  while (s) {
    if (strcmp(s->name,c) == 0) {
      if (s == ty->next) return s;
      /* Move s to the top of the linked list */
      s->prev->next = s->next;
      if (s->next) {
	s->next->prev = s->prev;
      }
      /* Insert s as second element in the list */
      s->next = ty->next;
      if (ty->next) ty->next->prev = s;
      ty->next = s;
      return s;
    }
    s = s->next;
  }
  return 0;
}

/* Cast a pointer (needed for C++ inheritance */
SWIGRUNTIME(void *) 
SWIG_TypeCast(swig_type_info *ty, void *ptr) 
{
  if ((!ty) || (!ty->converter)) return ptr;
  return (*ty->converter)(ptr);
}

/* Search for a swig_type_info structure */
SWIGRUNTIME(void *)
SWIG_TypeQuery(const char *name) {
  swig_type_info *ty = swig_type_list;
  while (ty) {
    if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
    if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
    ty = ty->prev;
  }
  return 0;
}

#endif

#ifdef __cplusplus
}
#endif



/***********************************************************************
 * python.swg
 *
 *     This file contains the runtime support for Python modules
 *     and includes code for managing global variables and pointer
 *     type checking.
 *
 * Author : David Beazley (beazley@cs.uchicago.edu)
 ************************************************************************/

#include <stdlib.h>
#include "Python.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SWIG_PY_INT     1
#define SWIG_PY_FLOAT   2
#define SWIG_PY_STRING  3
#define SWIG_PY_POINTER 4

/* Constant information structure */
typedef struct swig_const_info {
    int type;
    char *name;
    long lvalue;
    double dvalue;
    void   *pvalue;
    swig_type_info **ptype;
} swig_const_info;

#ifdef SWIG_NOINCLUDE

SWIGEXPORT(PyObject *)        SWIG_newvarlink();
SWIGEXPORT(void)              SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
SWIGEXPORT(int)               SWIG_ConvertPtr(PyObject *, void **, swig_type_info *, int);
SWIGEXPORT(void)              SWIG_MakePtr(char *c, void *, swig_type_info *);
SWIGEXPORT(PyObject *)        SWIG_NewPointerObj(void *, swig_type_info *);
SWIGEXPORT(void)              SWIG_InstallConstants(PyObject *d, swig_const_info constants[]);

#else

/* -----------------------------------------------------------------------------
 * global variable support code.
 * ----------------------------------------------------------------------------- */

typedef struct swig_globalvar {   
  char       *name;                  /* Name of global variable */
  PyObject *(*get_attr)(void);       /* Return the current value */
  int       (*set_attr)(PyObject *); /* Set the value */
  struct swig_globalvar *next;
} swig_globalvar;

typedef struct swig_varlinkobject {
  PyObject_HEAD
  swig_globalvar *vars;
} swig_varlinkobject;

static PyObject *
swig_varlink_repr(swig_varlinkobject *v) {
  v = v;
  return PyString_FromString("<Global variables>");
}

static int
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
  swig_globalvar  *var;
  flags = flags;
  fprintf(fp,"Global variables { ");
  for (var = v->vars; var; var=var->next) {
    fprintf(fp,"%s", var->name);
    if (var->next) fprintf(fp,", ");
  }
  fprintf(fp," }\n");
  return 0;
}

static PyObject *
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
  swig_globalvar *var = v->vars;
  while (var) {
    if (strcmp(var->name,n) == 0) {
      return (*var->get_attr)();
    }
    var = var->next;
  }
  PyErr_SetString(PyExc_NameError,"Unknown C global variable");
  return NULL;
}

static int
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
  swig_globalvar *var = v->vars;
  while (var) {
    if (strcmp(var->name,n) == 0) {
      return (*var->set_attr)(p);
    }
    var = var->next;
  }
  PyErr_SetString(PyExc_NameError,"Unknown C global variable");
  return 1;
}

statichere PyTypeObject varlinktype = {
  PyObject_HEAD_INIT(0)              
  0,
  "swigvarlink",                      /* Type name    */
  sizeof(swig_varlinkobject),         /* Basic size   */
  0,                                  /* Itemsize     */
  0,                                  /* Deallocator  */ 
  (printfunc) swig_varlink_print,     /* Print        */
  (getattrfunc) swig_varlink_getattr, /* get attr     */
  (setattrfunc) swig_varlink_setattr, /* Set attr     */
  0,                                  /* tp_compare   */
  (reprfunc) swig_varlink_repr,       /* tp_repr      */    
  0,                                  /* tp_as_number */
  0,                                  /* tp_as_mapping*/
  0,                                  /* tp_hash      */
};

/* Create a variable linking object for use later */
SWIGRUNTIME(PyObject *)
SWIG_newvarlink(void) {
  swig_varlinkobject *result = 0;
  result = PyMem_NEW(swig_varlinkobject,1);
  varlinktype.ob_type = &PyType_Type;    /* Patch varlinktype into a PyType */
  result->ob_type = &varlinktype;
  result->vars = 0;
  result->ob_refcnt = 0;
  Py_XINCREF((PyObject *) result);
  return ((PyObject*) result);
}

SWIGRUNTIME(void)
SWIG_addvarlink(PyObject *p, char *name,
	   PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
  swig_varlinkobject *v;
  swig_globalvar *gv;
  v= (swig_varlinkobject *) p;
  gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
  gv->name = (char *) malloc(strlen(name)+1);
  strcpy(gv->name,name);
  gv->get_attr = get_attr;
  gv->set_attr = set_attr;
  gv->next = v->vars;
  v->vars = gv;
}
/* Convert a pointer value */
SWIGRUNTIME(int)
SWIG_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
  unsigned long p;
  register int d;
  swig_type_info *tc;
  char  *c;
  static PyObject *SWIG_this = 0;
  int    newref = 0;

  if (!obj || (obj == Py_None)) {
    *ptr = 0;
    return 0;
  }
#ifdef SWIG_COBJECT_TYPES
  if (!(PyCObject_Check(obj))) {
    if (!SWIG_this)
      SWIG_this = PyString_InternFromString("this");
    obj = PyObject_GetAttr(obj,SWIG_this);
    newref = 1;
    if (!obj) goto type_error;
    if (!PyCObject_Check(obj)) {
      Py_DECREF(obj);
      goto type_error;
    }
  } 
  *ptr = PyCObject_AsVoidPtr(obj);
  c = (char *) PyCObject_GetDesc(obj);
  if (newref) Py_DECREF(obj);
  goto cobject;
#else
  if (!(PyString_Check(obj))) {
    if (!SWIG_this)
      SWIG_this = PyString_InternFromString("this");
    obj = PyObject_GetAttr(obj,SWIG_this);
    newref = 1;
    if (!obj) goto type_error;
    if (!PyString_Check(obj)) {
      Py_DECREF(obj);
      goto type_error;
    }
  } 
  c = PyString_AsString(obj);
  p = 0;
  /* Pointer values must start with leading underscore */
  if (*c != '_') {
    *ptr = (void *) 0;
    if (strcmp(c,"NULL") == 0) {
      if (newref) Py_DECREF(obj);
      return 0;
    } else {
      if (newref) Py_DECREF(obj);
      goto type_error;
    }
  }
  c++;
  /* Extract hex value from pointer */
  while ((d = *c)) {
    if ((d >= '0') && (d <= '9'))
      p = (p << 4) + (d - '0');
    else if ((d >= 'a') && (d <= 'f'))
      p = (p << 4) + (d - ('a'-10));
    else
      break; 
    c++;
  }
  *ptr = (void *) p;
  if (newref) Py_DECREF(obj);
#endif

#ifdef SWIG_COBJECT_TYPES
cobject:
#endif

  if (ty) {
    tc = SWIG_TypeCheck(c,ty);
    if (!tc) goto type_error;
    *ptr = SWIG_TypeCast(tc,(void*)p);
  }
  return 0;

type_error:

  if (flags) {
    if (ty) {
      char *temp = (char *) malloc(64+strlen(ty->name));
      sprintf(temp,"Type error. Expected %s", ty->name);
      PyErr_SetString(PyExc_TypeError, temp);
      free((char *) temp);
    } else {
      PyErr_SetString(PyExc_TypeError,"Expected a pointer");
    }
  }
  return -1;
}

/* Take a pointer and convert it to a string */
SWIGRUNTIME(void) 
SWIG_MakePtr(char *c, void *ptr, swig_type_info *ty) {
  static char hex[17] = "0123456789abcdef";
  unsigned long p, s;
  char result[32], *r; 
  r = result;
  p = (unsigned long) ptr;
  if (p > 0) {
    while (p > 0) {
      s = p & 0xf;
      *(r++) = hex[s];
      p = p >> 4;
    }
    *r = '_';
    while (r >= result)
      *(c++) = *(r--);
    strcpy (c, ty->name);
  } else {
    strcpy (c, "NULL");
  }
}

/* Create a new pointer object */
SWIGRUNTIME(PyObject *)
SWIG_NewPointerObj(void *ptr, swig_type_info *type) {
  char result[512];
  PyObject *robj;
  if (!ptr) {
    Py_INCREF(Py_None);
    return Py_None;
  }
#ifdef SWIG_COBJECT_TYPES
  robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, type->name, NULL);
#else
  SWIG_MakePtr(result,ptr,type);
  robj = PyString_FromString(result);
#endif
  return robj;
}

/* Install Constants */
SWIGRUNTIME(void)
SWIG_InstallConstants(PyObject *d, swig_const_info constants[]) {
  int i;
  PyObject *obj;
  for (i = 0; constants[i].type; i++) {
    switch(constants[i].type) {
    case SWIG_PY_INT:
      obj = PyInt_FromLong(constants[i].lvalue);
      break;
    case SWIG_PY_FLOAT:
      obj = PyFloat_FromDouble(constants[i].dvalue);
      break;
    case SWIG_PY_STRING:
      obj = PyString_FromString((char *) constants[i].pvalue);
      break;
    case SWIG_PY_POINTER:
      obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype);
      break;
    default:
      obj = 0;
      break;
    }
    if (obj) {
      PyDict_SetItemString(d,constants[i].name,obj);
      Py_DECREF(obj);
    }
  }
}

#endif

#ifdef __cplusplus
}
#endif



/* -------- TYPES TABLE (BEGIN) -------- */

#define  SWIGTYPE_p_float swig_types[0] 
#define  SWIGTYPE_p_double swig_types[1] 
#define  SWIGTYPE_p_p_char swig_types[2] 
#define  SWIGTYPE_p_PJ swig_types[3] 
#define  SWIGTYPE_p_int swig_types[4] 
#define  SWIGTYPE_p_Projection swig_types[5] 
static swig_type_info *swig_types[7];

/* -------- TYPES TABLE (END) -------- */


/*-----------------------------------------------
              @(target):= Projectionc.so
  ------------------------------------------------*/
#define SWIG_init    initProjectionc

#define SWIG_name    "Projectionc"

#include <projects.h>

    // We wrap the PJ structure in our own so we can keep the
    // type of units the user wants to operate in along.
    typedef enum {DEGREES, RADIANS} Units;
    typedef struct {
	Units units;
	PJ *proj;
    } Projection;

static PyObject* l_output_helper(PyObject* target, PyObject* o) {
    PyObject*   o2;
    if (!target) {                   
        target = o;
    } else if (target == Py_None) {  
        Py_DECREF(Py_None);
        target = o;
    } else {                         
        if (!PyList_Check(target)) {
            o2 = target;
            target = PyList_New(0);
            PyList_Append(target, o2);
	    Py_XDECREF(o2);
        }
        PyList_Append(target,o);
	Py_XDECREF(o);
    }
    return target;
}

static PyObject* t_output_helper(PyObject* target, PyObject* o) {
    PyObject*   o2;
    PyObject*   o3;

    if (!target) {                   
        target = o;
    } else if (target == Py_None) {  
        Py_DECREF(Py_None);
        target = o;
    } else {                         
        if (!PyTuple_Check(target)) {
            o2 = target;
            target = PyTuple_New(1);
            PyTuple_SetItem(target, 0, o2);
        }
        o3 = PyTuple_New(1);            
        PyTuple_SetItem(o3, 0, o);      

        o2 = target;
        target = PySequence_Concat(o2, o3); 
        Py_DECREF(o2);                      
        Py_DECREF(o3);
    }
    return target;
}

#define  SWIG_MemoryError    1
#define  SWIG_IOError        2
#define  SWIG_RuntimeError   3
#define  SWIG_IndexError     4
#define  SWIG_TypeError      5
#define  SWIG_DivisionByZero 6
#define  SWIG_OverflowError  7
#define  SWIG_SyntaxError    8
#define  SWIG_ValueError     9
#define  SWIG_SystemError   10
#define  SWIG_UnknownError  99

static void _SWIG_exception(int code, char *msg) {
  switch(code) {
  case SWIG_MemoryError:
    PyErr_SetString(PyExc_MemoryError,msg);
    break;
  case SWIG_IOError:
    PyErr_SetString(PyExc_IOError,msg);
    break;
  case SWIG_RuntimeError:
    PyErr_SetString(PyExc_RuntimeError,msg);
    break;
  case SWIG_IndexError:
    PyErr_SetString(PyExc_IndexError,msg);
    break;
  case SWIG_TypeError:
    PyErr_SetString(PyExc_TypeError,msg);
    break;
  case SWIG_DivisionByZero:
    PyErr_SetString(PyExc_ZeroDivisionError,msg);
    break;
  case SWIG_OverflowError:
    PyErr_SetString(PyExc_OverflowError,msg);
    break;
  case SWIG_SyntaxError:
    PyErr_SetString(PyExc_SyntaxError,msg);
    break;
  case SWIG_ValueError:
    PyErr_SetString(PyExc_ValueError,msg);
    break;
  case SWIG_SystemError:
    PyErr_SetString(PyExc_SystemError,msg);
    break;
  default:
    PyErr_SetString(PyExc_RuntimeError,msg);
    break;
  }
}

#define SWIG_exception(a,b) { _SWIG_exception(a,b); return NULL; }

#include <limits.h>

/* Create a new integer array */

  static int *int_array(int size) {
#ifdef __cplusplus
    return new int[size];
#else
    return (int *) malloc(size*sizeof(int));
#endif
  }

  /* Destroy an integer array */

  static void int_destroy(int *array) {
    if (array) {
#ifdef __cplusplus
      delete [] array;
#else
      free(array);
#endif
    }
  }

  /* Return an element */

  static int int_get(int *array, int index) {
    if (array) {
      return array[index];
    } else {
      return INT_MIN;
    }
  }
   
  /* Set an element */
  
  static int int_set(int *array, int index, int value) {
    if (array) {
      return (array[index] = value);
    } else {
      return INT_MIN;
    }
  }


  #include <float.h>

  /* Create a new float array */

  static float *float_array(int size) {
#ifdef __cplusplus
    return new float[size];
#else
    return (float *) malloc(size*sizeof(float));
#endif
  }

  /* Destroy an array */

  static void float_destroy(float *array) {
    if (array) {
#ifdef __cplusplus
      delete [] array;
#else
      free(array);
#endif
    }
  }

  /* Return an element */

  static float float_get(float *array, int index) {
    if (array) {
      return array[index];
    } else {
      return FLT_MIN;
    }
  }
   
  /* Set an element */
  
  static float float_set(float *array, int index, float value) {
    if (array) {
      return (array[index] = value);
    } else {
      return FLT_MIN;
    }
  }

  /* Create a new double array */

  static double *double_array(int size) {
#ifdef __cplusplus
    return new double[size];
#else
    return (double *) malloc(size*sizeof(double));
#endif
  }

  /* Destroy an array */

  static void double_destroy(double *array) {
    if (array) {
#ifdef __cplusplus
      delete [] array;
#else
      free(array);
#endif
    }
  }

  /* Return an element */

  static double double_get(double *array, int index) {
    if (array) {
      return array[index];
    } else {
      return FLT_MIN;
    }
  }
   
  /* Set an element */
  
  static double double_set(double *array, int index, double value) {
    if (array) {
      return (array[index] = value);
    } else {
      return FLT_MIN;
    }
  }


/* Create character string arrays */

static char **string_array(int size) {
  char **a;
  int i;
#ifdef __cplusplus
  a = new char *[size];
#else
  a = (char **) malloc(size*sizeof(char *));
#endif
  for (i = 0; i < size; i++)
    a[i] = 0;
  return a;
}

/* Destroy a string array */

static void string_destroy(char **array) {
  int i = 0;
  if (array) {
      while (array[i]) {
#ifdef __cplusplus
            delete array[i];
#else
            free(array[i]);
#endif
            i++;
      }          	
#ifdef __cplusplus
     delete [] array;
#else
     free(array);
#endif
   }      
}

/* Get an element */

static char *string_get(char **array_string, int index) {
  if (array_string) 
    if (array_string[index]) return (array_string[index]);
    else return "";
  else 
    return "";
}

/* Set an element */

static char *string_set(char **array_string, int index, char * val) {
  if (array_string) {
    if (array_string[index]) {
#ifdef __cplusplus
	delete array_string[index];
#else
        free(array_string[index]);
#endif
    }	
    if (strlen(val) > 0) {
#ifdef __cplusplus
      array_string[index] = new char[strlen(val)+1];
#else
      array_string[index] = (char *) malloc(strlen(val)+1);
#endif
      strcpy(array_string[index],val);
      return array_string[index];
    } else {
      array_string[index] = 0;
      return val;
    }
  } else return val;
}


    // Make a brand new projection
    Projection *new_Projection(char **argv, Units units) {
	int argc = 0;
	char **p;
	PJ *proj;
	Projection *pj = NULL;
	
	for(p = argv; p != NULL && *p != NULL; p++) argc++;
	proj = pj_init(argc, argv);
	if(proj != NULL) {
	    pj = (Projection *) malloc(sizeof(Projection));
	    pj->units = units;
	    pj->proj = proj;
	}
	return pj;
    }

    // Get rid of a projection
    void delete_Projection(Projection *self) {
	if(self != NULL) {
	    if(self->proj != NULL)
		pj_free(self->proj);
	    free(self);  
	} 
    }

    // Do a forward (lat/lon --> world) translation
    void Projection_Forward(Projection *self, double lat, double lon, double *u, double *v) {
	projUV latlon, result;
	latlon.u = lat;
	latlon.v = lon;
	if(self->units == DEGREES) {
	    latlon.u *= DEG_TO_RAD;
	    latlon.v *= DEG_TO_RAD;
	}
	result = pj_fwd(latlon, self->proj);
	*u = result.u;
	*v = result.v;
    }

    // Do a reverse (world --> lat/lon) translation
    void Projection_Inverse(Projection *self, double u, double v, double *lat, double *lon) {
	projUV world, result;
	world.u = u;
	world.v = v;
	result = pj_inv(world, self->proj);
	if(self->units == DEGREES) {
	    result.u *= RAD_TO_DEG;
	    result.v *= RAD_TO_DEG;
	}
	*lat = result.u;
	*lon = result.v;
    }
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_int_array(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int arg0 ;
    int *result ;
    
    if(!PyArg_ParseTuple(args,"i:int_array",&arg0)) return NULL;
    result = (int *)int_array(arg0);
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_int);
    {
        if (!result) {
            SWIG_exception(SWIG_MemoryError,"Out of memory.");
        }
    }
    return resultobj;
}


static PyObject *_wrap_int_destroy(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int *arg0 ;
    PyObject * argo0 =0 ;
    
    if(!PyArg_ParseTuple(args,"O:int_destroy",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_int,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    int_destroy(arg0);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_int_get(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int *arg0 ;
    int arg1 ;
    PyObject * argo0 =0 ;
    int result ;
    
    if(!PyArg_ParseTuple(args,"Oi:int_get",&argo0,&arg1)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_int,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (int )int_get(arg0,arg1);
    resultobj = PyInt_FromLong((long)result);
    return resultobj;
}


static PyObject *_wrap_int_set(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int *arg0 ;
    int arg1 ;
    int arg2 ;
    PyObject * argo0 =0 ;
    int result ;
    
    if(!PyArg_ParseTuple(args,"Oii:int_set",&argo0,&arg1,&arg2)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_int,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (int )int_set(arg0,arg1,arg2);
    resultobj = PyInt_FromLong((long)result);
    return resultobj;
}


static PyObject *_wrap_double_array(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int arg0 ;
    double *result ;
    
    if(!PyArg_ParseTuple(args,"i:double_array",&arg0)) return NULL;
    result = (double *)double_array(arg0);
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_double);
    {
        if (!result) {
            SWIG_exception(SWIG_MemoryError,"Out of memory.");
        }
    }
    return resultobj;
}


static PyObject *_wrap_double_destroy(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    double *arg0 ;
    PyObject * argo0 =0 ;
    
    if(!PyArg_ParseTuple(args,"O:double_destroy",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_double,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    double_destroy(arg0);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_double_get(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    double *arg0 ;
    int arg1 ;
    PyObject * argo0 =0 ;
    double result ;
    
    if(!PyArg_ParseTuple(args,"Oi:double_get",&argo0,&arg1)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_double,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (double )double_get(arg0,arg1);
    resultobj = PyFloat_FromDouble(result);
    return resultobj;
}


static PyObject *_wrap_double_set(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    double *arg0 ;
    int arg1 ;
    double arg2 ;
    PyObject * argo0 =0 ;
    double result ;
    
    if(!PyArg_ParseTuple(args,"Oid:double_set",&argo0,&arg1,&arg2)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_double,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (double )double_set(arg0,arg1,arg2);
    resultobj = PyFloat_FromDouble(result);
    return resultobj;
}


static PyObject *_wrap_float_array(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int arg0 ;
    float *result ;
    
    if(!PyArg_ParseTuple(args,"i:float_array",&arg0)) return NULL;
    result = (float *)float_array(arg0);
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_float);
    {
        if (!result) {
            SWIG_exception(SWIG_MemoryError,"Out of memory.");
        }
    }
    return resultobj;
}


static PyObject *_wrap_float_destroy(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    float *arg0 ;
    PyObject * argo0 =0 ;
    
    if(!PyArg_ParseTuple(args,"O:float_destroy",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_float,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    float_destroy(arg0);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_float_get(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    float *arg0 ;
    int arg1 ;
    PyObject * argo0 =0 ;
    float result ;
    
    if(!PyArg_ParseTuple(args,"Oi:float_get",&argo0,&arg1)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_float,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (float )float_get(arg0,arg1);
    resultobj = PyFloat_FromDouble(result);
    return resultobj;
}


static PyObject *_wrap_float_set(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    float *arg0 ;
    int arg1 ;
    float arg2 ;
    PyObject * argo0 =0 ;
    float result ;
    
    if(!PyArg_ParseTuple(args,"Oif:float_set",&argo0,&arg1,&arg2)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_float,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (float )float_set(arg0,arg1,arg2);
    resultobj = PyFloat_FromDouble(result);
    return resultobj;
}


static PyObject *_wrap_string_array(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int arg0 ;
    char **result ;
    
    if(!PyArg_ParseTuple(args,"i:string_array",&arg0)) return NULL;
    result = (char **)string_array(arg0);
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_p_char);
    {
        if (!result) {
            SWIG_exception(SWIG_MemoryError,"Out of memory.");
        }
    }
    return resultobj;
}


static PyObject *_wrap_string_destroy(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    char **arg0 ;
    PyObject * argo0 =0 ;
    
    if(!PyArg_ParseTuple(args,"O:string_destroy",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_p_char,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    string_destroy(arg0);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_string_get(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    char **arg0 ;
    int arg1 ;
    PyObject * argo0 =0 ;
    char *result ;
    
    if(!PyArg_ParseTuple(args,"Oi:string_get",&argo0,&arg1)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_p_char,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (char *)string_get(arg0,arg1);
    resultobj = PyString_FromString(result);
    return resultobj;
}


static PyObject *_wrap_string_set(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    char **arg0 ;
    int arg1 ;
    char *arg2 ;
    PyObject * argo0 =0 ;
    char *result ;
    
    if(!PyArg_ParseTuple(args,"Ois:string_set",&argo0,&arg1,&arg2)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_p_char,1)) == -1) return NULL;
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    result = (char *)string_set(arg0,arg1,arg2);
    resultobj = PyString_FromString(result);
    return resultobj;
}


static PyObject *_wrap_Projection_units_set(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    int arg1 ;
    PyObject * argo0 =0 ;
    
    if(!PyArg_ParseTuple(args,"Oi:Projection_units_set",&argo0,&arg1)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    arg0->units = (Units )arg1;
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_Projection_units_get(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    PyObject * argo0 =0 ;
    int result ;
    
    if(!PyArg_ParseTuple(args,"O:Projection_units_get",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    result = (int ) (arg0->units);
    resultobj = PyInt_FromLong((long)result);
    return resultobj;
}


static PyObject *_wrap_Projection_proj_set(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    PJ *arg1 ;
    PyObject * argo0 =0 ;
    PyObject * argo1 =0 ;
    
    if(!PyArg_ParseTuple(args,"OO:Projection_proj_set",&argo0,&argo1)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    if ((SWIG_ConvertPtr(argo1,(void **) &arg1,SWIGTYPE_p_PJ,1)) == -1) return NULL;
    arg0->proj = arg1;
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_Projection_proj_get(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    PyObject * argo0 =0 ;
    PJ *result ;
    
    if(!PyArg_ParseTuple(args,"O:Projection_proj_get",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    result = (PJ *) (arg0->proj);
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_PJ);
    return resultobj;
}


static PyObject *_wrap_new_Projection(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    char **arg0 ;
    int arg1 = DEGREES ;
    PyObject * obj0  = 0 ;
    Projection *result ;
    
    if(!PyArg_ParseTuple(args,"O|i:new_Projection",&obj0,&arg1)) return NULL;
    {
        /* Check if is a list */ 
        if (PyList_Check(obj0)) {
            int size = PyList_Size(obj0); 
            int i = 0; 
            arg0 = (char **) malloc((size+1)*sizeof(char *)); 
            for (i = 0; i < size; i++) {
                PyObject *o = PyList_GetItem(obj0,i); 
                if (PyString_Check(o)) 
                arg0[i] = PyString_AsString(PyList_GetItem(obj0,i)); 
                else {
                    PyErr_SetString(PyExc_TypeError,"list must contain strings"); 
                    free(arg0); 
                    return NULL; 
                }
            }
            arg0[i] = 0; 
        }else {
            PyErr_SetString(PyExc_TypeError,"not a list"); return NULL; 
        }
    }
    {
        if (!arg0) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    {
        /* Use pj_get_errno_ref to access the pj_errno because directly
        * accessing pj_errno doesn't work on windows if the proj library is
     * in a DLL */
    *pj_get_errno_ref() = 0;
    result = (Projection *)new_Projection(arg0,(Units )arg1);
;
    if (!result)
    {
	/* FIXME: There's a case where result is NULL and pj_errno is
        * not set, namely when memory allocation of the Projection
        * struct fails. */
        SWIG_exception(SWIG_IOError, pj_strerrno(*pj_get_errno_ref()));
    }
}resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Projection);
{
    free((char *) arg0);
}
return resultobj;
}


static PyObject *_wrap_delete_Projection(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    PyObject * argo0 =0 ;
    
    if(!PyArg_ParseTuple(args,"O:delete_Projection",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    delete_Projection(arg0);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    return resultobj;
}


static PyObject *_wrap_Projection_Forward(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    double arg1 ;
    double arg2 ;
    double *arg3 ;
    double *arg4 ;
    double temp ;
    double temp0 ;
    PyObject * argo0 =0 ;
    
    {
        arg3 = &temp;
    }
    {
        arg4 = &temp0;
    }
    if(!PyArg_ParseTuple(args,"Odd:Projection_Forward",&argo0,&arg1,&arg2)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    {
        if (!arg3) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    {
        if (!arg4) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    Projection_Forward(arg0,arg1,arg2,arg3,arg4);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    {
        PyObject *o; 
        o = PyFloat_FromDouble(*arg3); 
        if ((!resultobj) || (resultobj == Py_None)) {
            resultobj = o; 
        }else {
            if (!PyList_Check(resultobj)) {
                PyObject *o2 = resultobj; 
                resultobj = PyList_New(0); 
                PyList_Append(resultobj,o2); 
                Py_XDECREF(o2); 
            }
            PyList_Append(resultobj,o); 
            Py_XDECREF(o); 
        }
    }
    {
        PyObject *o; 
        o = PyFloat_FromDouble(*arg4); 
        if ((!resultobj) || (resultobj == Py_None)) {
            resultobj = o; 
        }else {
            if (!PyList_Check(resultobj)) {
                PyObject *o2 = resultobj; 
                resultobj = PyList_New(0); 
                PyList_Append(resultobj,o2); 
                Py_XDECREF(o2); 
            }
            PyList_Append(resultobj,o); 
            Py_XDECREF(o); 
        }
    }
    return resultobj;
}


static PyObject *_wrap_Projection_Inverse(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    double arg1 ;
    double arg2 ;
    double *arg3 ;
    double *arg4 ;
    double temp ;
    double temp0 ;
    PyObject * argo0 =0 ;
    
    {
        arg3 = &temp;
    }
    {
        arg4 = &temp0;
    }
    if(!PyArg_ParseTuple(args,"Odd:Projection_Inverse",&argo0,&arg1,&arg2)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    {
        if (!arg3) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    {
        if (!arg4) {
            SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
        }
    }
    Projection_Inverse(arg0,arg1,arg2,arg3,arg4);
    Py_INCREF(Py_None);
    resultobj = Py_None;
    {
        PyObject *o; 
        o = PyFloat_FromDouble(*arg3); 
        if ((!resultobj) || (resultobj == Py_None)) {
            resultobj = o; 
        }else {
            if (!PyList_Check(resultobj)) {
                PyObject *o2 = resultobj; 
                resultobj = PyList_New(0); 
                PyList_Append(resultobj,o2); 
                Py_XDECREF(o2); 
            }
            PyList_Append(resultobj,o); 
            Py_XDECREF(o); 
        }
    }
    {
        PyObject *o; 
        o = PyFloat_FromDouble(*arg4); 
        if ((!resultobj) || (resultobj == Py_None)) {
            resultobj = o; 
        }else {
            if (!PyList_Check(resultobj)) {
                PyObject *o2 = resultobj; 
                resultobj = PyList_New(0); 
                PyList_Append(resultobj,o2); 
                Py_XDECREF(o2); 
            }
            PyList_Append(resultobj,o); 
            Py_XDECREF(o); 
        }
    }
    return resultobj;
}


PyObject * Projection_cobject(Projection *self) {
    {
        return PyCObject_FromVoidPtr(self->proj, NULL);
    }
}


static PyObject *_wrap_Projection_cobject(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    Projection *arg0 ;
    PyObject * argo0 =0 ;
    PyObject *result ;
    
    if(!PyArg_ParseTuple(args,"O:Projection_cobject",&argo0)) return NULL;
    if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_Projection,1)) == -1) return NULL;
    result = (PyObject *)Projection_cobject(arg0);
    {
        resultobj = result;
    }
    return resultobj;
}


static PyMethodDef ProjectioncMethods[] = {
	 { "int_array", _wrap_int_array, METH_VARARGS },
	 { "int_destroy", _wrap_int_destroy, METH_VARARGS },
	 { "int_get", _wrap_int_get, METH_VARARGS },
	 { "int_set", _wrap_int_set, METH_VARARGS },
	 { "double_array", _wrap_double_array, METH_VARARGS },
	 { "double_destroy", _wrap_double_destroy, METH_VARARGS },
	 { "double_get", _wrap_double_get, METH_VARARGS },
	 { "double_set", _wrap_double_set, METH_VARARGS },
	 { "float_array", _wrap_float_array, METH_VARARGS },
	 { "float_destroy", _wrap_float_destroy, METH_VARARGS },
	 { "float_get", _wrap_float_get, METH_VARARGS },
	 { "float_set", _wrap_float_set, METH_VARARGS },
	 { "string_array", _wrap_string_array, METH_VARARGS },
	 { "string_destroy", _wrap_string_destroy, METH_VARARGS },
	 { "string_get", _wrap_string_get, METH_VARARGS },
	 { "string_set", _wrap_string_set, METH_VARARGS },
	 { "Projection_units_set", _wrap_Projection_units_set, METH_VARARGS },
	 { "Projection_units_get", _wrap_Projection_units_get, METH_VARARGS },
	 { "Projection_proj_set", _wrap_Projection_proj_set, METH_VARARGS },
	 { "Projection_proj_get", _wrap_Projection_proj_get, METH_VARARGS },
	 { "new_Projection", _wrap_new_Projection, METH_VARARGS },
	 { "delete_Projection", _wrap_delete_Projection, METH_VARARGS },
	 { "Projection_Forward", _wrap_Projection_Forward, METH_VARARGS },
	 { "Projection_Inverse", _wrap_Projection_Inverse, METH_VARARGS },
	 { "Projection_cobject", _wrap_Projection_cobject, METH_VARARGS },
	 { NULL, NULL }
};

#ifdef __cplusplus
}
#endif

/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */

static swig_type_info _swigt__p_float[] = {{"_p_float", 0, "float *"},{"_p_float"},{0}};
static swig_type_info _swigt__p_double[] = {{"_p_double", 0, "double *"},{"_p_double"},{0}};
static swig_type_info _swigt__p_p_char[] = {{"_p_p_char", 0, "char **"},{"_p_p_char"},{0}};
static swig_type_info _swigt__p_PJ[] = {{"_p_PJ", 0, "PJ *"},{"_p_PJ"},{0}};
static swig_type_info _swigt__p_int[] = {{"_p_int", 0, "int *"},{"_p_int"},{0}};
static swig_type_info _swigt__p_Projection[] = {{"_p_Projection", 0, "Projection *"},{"_p_Projection"},{0}};

static swig_type_info *swig_types_initial[] = {
_swigt__p_float, 
_swigt__p_double, 
_swigt__p_p_char, 
_swigt__p_PJ, 
_swigt__p_int, 
_swigt__p_Projection, 
0
};


/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */

static swig_const_info swig_const_table[] = {
    { SWIG_PY_INT,     "DEGREES", (long) DEGREES, 0, 0, 0},
    { SWIG_PY_INT,     "RADIANS", (long) RADIANS, 0, 0, 0},
{0}};

static PyObject *SWIG_globals;
#ifdef __cplusplus
extern "C" 
#endif
SWIGEXPORT(void) initProjectionc(void) {
    PyObject *m, *d;
    int i;
    SWIG_globals = SWIG_newvarlink();
    m = Py_InitModule("Projectionc", ProjectioncMethods);
    d = PyModule_GetDict(m);
    for (i = 0; swig_types_initial[i]; i++) {
        swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
    }
    SWIG_InstallConstants(d,swig_const_table);
}

