Skip to content

Commit ad4a87e

Browse files
committed
encode() and encode_single()'s territory paramter can now be None as well.
1 parent e5ba2ad commit ad4a87e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

mapcodemodule.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "mapcoder.c"
1919

2020

21-
static char version_doc[] =
21+
static char version_doc[] =
2222
"version()\n\
2323
\n\
2424
Returns the version of the Mapcode C library used by this Python module.\n";
@@ -29,7 +29,7 @@ static PyObject *version(PyObject *self, PyObject *args)
2929
}
3030

3131

32-
static char isvalid_doc[] =
32+
static char isvalid_doc[] =
3333
"isvalid()\n\
3434
\n\
3535
Verify if the provided mapcode has the right syntax.\n";
@@ -50,7 +50,7 @@ static PyObject *isvalid(PyObject *self, PyObject *args)
5050
}
5151

5252

53-
static char decode_doc[] =
53+
static char decode_doc[] =
5454
"decode(mapcode, (territoryname))\n\
5555
\n\
5656
Decodes the provided string to latitude and longitude. Optionally\n\
@@ -82,7 +82,7 @@ static PyObject *decode(PyObject *self, PyObject *args)
8282
}
8383

8484

85-
static char encode_doc[] =
85+
static char encode_doc[] =
8686
"encode(latitude, longitude, (territoryname, extra_digits))\n\
8787
\n\
8888
Encodes the given latitude, longitude to one or more mapcodes.\n\
@@ -97,7 +97,7 @@ static PyObject *encode(PyObject *self, PyObject *args)
9797
int extra_digits = 0, territorycode = 0;
9898
PyObject *result;
9999

100-
if (!PyArg_ParseTuple(args, "dd|si", &latitude, &longitude, &territoryname, &extra_digits))
100+
if (!PyArg_ParseTuple(args, "dd|zi", &latitude, &longitude, &territoryname, &extra_digits))
101101
return NULL;
102102

103103
// printf("encode: args: %f, %f, %x, %i\n", latitude, longitude, territoryname, extra_digits);
@@ -117,15 +117,15 @@ static PyObject *encode(PyObject *self, PyObject *args)
117117
result = PyList_New(n);
118118
while (n--) {
119119
// printf("debug: %d: %s - %s\n", n, mapcode_results[n * 2], mapcode_results[(n * 2) + 1]);
120-
PyList_SetItem(result, n, Py_BuildValue("(ss)", (mapcode_results[n * 2]), mapcode_results[(n * 2) + 1]));
120+
PyList_SetItem(result, n, Py_BuildValue("(ss)", (mapcode_results[n * 2]), mapcode_results[(n * 2) + 1]));
121121
}
122122
return result;
123123
}
124124
return PyList_New(0);
125125
}
126126

127127

128-
static char encode_single_doc[] =
128+
static char encode_single_doc[] =
129129
"encode_single(latitude, longitude, (territoryname, extra_digits))\n\
130130
\n\
131131
Encodes the given latitude, longitude to a mapcode. Optionally a territoryname\n\
@@ -138,7 +138,7 @@ static PyObject *encode_single(PyObject *self, PyObject *args)
138138
int extra_digits = 0, territorycode = 0;
139139
PyObject *result;
140140

141-
if (!PyArg_ParseTuple(args, "dd|si", &latitude, &longitude, &territoryname, &extra_digits))
141+
if (!PyArg_ParseTuple(args, "dd|zi", &latitude, &longitude, &territoryname, &extra_digits))
142142
return NULL;
143143

144144
// printf("encode_single: args: %f, %f, %x, %i\n", latitude, longitude, territoryname, extra_digits);

0 commit comments

Comments
 (0)