Skip to content

Commit d6d2dd5

Browse files
committed
First commit
1 parent 9763781 commit d6d2dd5

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

mapcode/mapcode.i

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* File: mapcode.i */
2+
3+
%define DOCSTRING
4+
"Routines to encode latitude/longitudes to mapcodes and back.
5+
6+
See mapcode.org for more information on Mapcode."
7+
%enddef
8+
9+
%module(docstring=DOCSTRING) mapcode
10+
11+
%include "typemaps.i"
12+
13+
%{
14+
#define SWIG_FILE_WITH_INIT
15+
#include "mapcode_swig.h"
16+
%}
17+
18+
/*
19+
%typemap(python, out) int decode {
20+
printf("result: %d\n", result);
21+
if (result) {
22+
$result = PyList_New(0);
23+
}
24+
}
25+
*/
26+
27+
/* this converts the char ** returned by encode() into a Python list */
28+
%typemap(python, out) char **encode {
29+
int len = 0;
30+
while ($1[len])
31+
len++;
32+
33+
$result = PyList_New(len);
34+
int i = 0;
35+
while ($1[i]) {
36+
PyList_SetItem($result, i, PyString_FromString($1[i++]));
37+
}
38+
}
39+
40+
char *version(void);
41+
char **encode(double latitude, double longitude, char *territory=NULL, int extra_digits=0);
42+
char *encode_single(double latitude, double longitude, char *territory=NULL, int extra_digits=0);
43+
int decode(double *OUTPUT, double *OUTPUT, const char *mapcode, char *territory = NULL);
44+
int isvalid(char *mapcode, int includesTerritory);
45+
wchar_t *alphabet(const char *mapcode, int alphabet);

0 commit comments

Comments
 (0)