-
Notifications
You must be signed in to change notification settings - Fork 5
/
libgeoda.i
112 lines (99 loc) · 3.23 KB
/
libgeoda.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
%module libgeoda
%begin %{
#define SWIG_PYTHON_2_UNICODE
%}
%include "stl.i"
%include "std_string.i"
%include "std_vector.i"
%include "std_pair.i"
%template(VecVoid) std::vector<void*>;
%template(VecFloat) std::vector<float>;
%template(VecString) std::vector<std::string>;
%template(VecDouble) std::vector<double>;
%template(VecChar) std::vector<char>;
%template(VecCharPointer) std::vector<char*>;
%template(VecVecDouble) std::vector<std::vector<double> >;
%template(VecInt) std::vector<int>;
%template(VecBool) std::vector<bool>;
%template(VecVecBool) std::vector<std::vector<bool> >;
%template(VecLong) std::vector<long>;
%template(VecInt64) std::vector<long long>;
%template(VecVecInt) std::vector<std::vector<int> >;
%template(VecUINT8) std::vector<unsigned char>;
%template(VecVecUINT8) std::vector<std::vector<unsigned char> >;
%template(VecVecChar) std::vector<std::vector<char> >;
%template(Pair) std::pair<double, std::vector<double> >;
%template(VecPair) std::vector<std::pair<double, std::vector<double> > >;
#if defined(SWIGPYTHON)
%typemap(ignore) TYPEMAP(unsigned char* temp) {
$1 = ($1_ltype) temp;
}
%typemap(in) (unsigned char*) {
// used by GeoDa() constructor for pygeoda
if (!PyByteArray_Check($input)) {
SWIG_exception_fail(SWIG_TypeError, "in method '" "$symname" "', argument "
"$argnum"" of type '" "$type""'");
}
$1 = (unsigned char*) PyByteArray_AsString($input);
}
%typemap(in) (std::vector<char*>) {
// vector of bytes for geopands_to_geoda()
int iLen = PySequence_Length($input);
for(unsigned int i = 0; i < iLen; i++) {
PyObject *o = PySequence_GetItem($input, i);
$1.push_back((char*)(PyBytes_AsString(o)));
}
}
#endif
%{
#include <string>
#include <stdint.h>
#include <weights/GeodaWeight.h>
#include <sa/LISA.h>
#include <sa/BatchLISA.h>
#include <pg/geoms.h>
#include <gda_interface.h>
#include <libgeoda.h>
#include <gda_sa.h>
#include <gda_data.h>
#include <gda_weights.h>
#include <gda_clustering.h>
#include <GenUtils.h>
%}
// release memory for some function to prevent memory leaking
// the SWIG generated wrappers will have a memory leak--the returned
// data will be copied into a string object and the old contents ignored.
%newobject gda_queen_weights;
%newobject gda_rook_weights;
%newobject gda_knn_weights;
%newobject gda_distance_weights;
%newobject gda_localmoran;
%newobject gda_batchlocalmoran;
%newobject gda_localgeary;
%newobject gda_localmultigeary;
%newobject gda_localjoincount;
%newobject gda_localmultijoincount;
%newobject gda_localg;
%newobject gda_localgstar;
%newobject gda_quantilelisa;
%newobject gda_multiquantilelisa;
%newobject gda_fdr;
%newobject gda_bo;
%newobject CreateGeoDaFromGPD;
%newobject CreateGeoDaFromSHP;
%include <std_string.i>
%include <weights/GeodaWeight.h>
%include <sa/LISA.h>
%include <sa/BatchLISA.h>
%include <gda_interface.h>
%include <libgeoda.h>
%include <gda_sa.h>
%include <gda_data.h>
%include <gda_weights.h>
%include <gda_clustering.h>
%include <GenUtils.h>
%template(VecGeoDaColumn) std::vector<GeoDaColumn*>;
%template(VecJoinCountRatio) std::vector<JoinCountRatio>;
%template(VecCompactness) std::vector<Compactness>;
%template(VecDiameter) std::vector<Diameter>;
%template(VecFragmentation) std::vector<Fragmentation>;