1 |
jan |
1611 |
/* Header file for the PyShapelib API for other Python modules */ |
2 |
|
|
/* $Revision$ */ |
3 |
|
|
|
4 |
|
|
#ifndef PYSHAPELIB_API_H |
5 |
|
|
#define PYSHAPELIB_API_H |
6 |
|
|
|
7 |
|
|
typedef struct { |
8 |
|
|
/* Shapefile functions */ |
9 |
|
|
SHPObject * (*SHPReadObject)(SHPHandle hSHP, int iShape); |
10 |
|
|
void (*SHPDestroyObject)(SHPObject * psObject); |
11 |
|
|
|
12 |
|
|
/* SHPTree functions */ |
13 |
|
|
SHPTree * (*SHPCreateTree)(SHPHandle hSHP, int nDimension, int nMaxDepth, |
14 |
|
|
double *padfBoundsMin, double *padfBoundsMax); |
15 |
|
|
void (*SHPDestroyTree)(SHPTree * hTree); |
16 |
|
|
int * (*SHPTreeFindLikelyShapes)(SHPTree * hTree, double * padfBoundsMin, |
17 |
|
|
double * padfBoundsMax, int *); |
18 |
|
|
} PyShapeLibAPI; |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
/* Macro to import the shapelib module, extract the API pointer and |
22 |
|
|
* assign it to the variable given as argument */ |
23 |
|
|
#define PYSHAPELIB_IMPORT_API(apivariable) \ |
24 |
|
|
{ \ |
25 |
bramz |
2735 |
PyObject * shapelib = PyImport_ImportModule("shapelib"); \ |
26 |
jan |
1611 |
if (shapelib) \ |
27 |
|
|
{ \ |
28 |
|
|
PyObject * c_api_func = PyObject_GetAttrString(shapelib, "c_api"); \ |
29 |
|
|
if (c_api_func) \ |
30 |
|
|
{ \ |
31 |
|
|
PyObject * cobj = PyObject_CallObject(c_api_func, NULL); \ |
32 |
|
|
if (cobj) \ |
33 |
|
|
{ \ |
34 |
|
|
(apivariable) = (PyShapeLibAPI*)PyCObject_AsVoidPtr(cobj); \ |
35 |
|
|
} \ |
36 |
|
|
} \ |
37 |
|
|
} \ |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
#endif /* PYSHAPELIB_API_H */ |