Skip to content

Commit e38ac64

Browse files
committed
Changed return type of encode() to list of tuples.
1 parent 2f8c6ef commit e38ac64

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,16 @@ a territory code can be provide to encode for just that territory.
119119

120120
```python
121121
print mapcode.encode(52.376514, 4.908542)
122-
[['49.4V', 'NLD'], ['G9.VWG', 'NLD'], ['DL6.H9L', 'NLD'], ['P25Z.N3Z', 'NLD'], ['VHXGB.1J9J', 'AAA']]
122+
[('49.4V', 'NLD'), ('G9.VWG', 'NLD'), ('DL6.H9L', 'NLD'), ('P25Z.N3Z', 'NLD'), ('VHXGB.1J9J', 'AAA')]
123123
```
124124

125125
A territory code can be provide to encode for just that territory.
126126

127127
```python
128128
print mapcode.encode(52.376514, 4.908542, 'NLD')
129+
[('49.4V', 'NLD'), ('G9.VWG', 'NLD'), ('DL6.H9L', 'NLD'), ('P25Z.N3Z', 'NLD')]
129130
print mapcode.encode(39.609999,45.949999, 'AZE')
130-
[['XLT.HWB', 'AZE'], ['2Z.05XL', 'AZE'], ['6N49.HHV', 'AZE']]
131+
[('XLT.HWB', 'AZE'), ('2Z.05XL', 'AZE'), ('6N49.HHV', 'AZE')]
131132
```
132133

133134
## Decoding

examples/test geocoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def read_boundary_file(filename, debug=False):
4545
# print header_line.strip()
4646

4747
# Do geocode ourself, change format to match fileformat, store in set
48-
mapcodes = mapcode.encode(float(lat), float(lon), None)
49-
mapcodes_geocoded = set(m_country + ' ' + m_code for m_code, m_country in zip(mapcodes[::2], mapcodes[1::2]))
48+
mapcodes = mapcode.encode(float(lat), float(lon))
49+
mapcodes_geocoded = set(m_territory + ' ' + m_code for m_code, m_territory in mapcodes)
5050

5151
if mapcodes_in_file != mapcodes_geocoded:
5252
print "Geocodes did not match!", header_line, mapcodes_in_file, mapcodes_geocoded

mapcodemodule.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static PyObject *version(PyObject *self, PyObject *args)
3232
static char isvalid_doc[] =
3333
"isvalid()\n\
3434
\n\
35-
Verify if the provided string has the right mapcode syntax.\n";
35+
Verify if the provided mapcode has the right syntax.\n";
3636

3737
static PyObject *isvalid(PyObject *self, PyObject *args)
3838
{
@@ -111,12 +111,11 @@ static PyObject *encode(PyObject *self, PyObject *args)
111111

112112
char *mapcode_results[MAX_NR_OF_MAPCODE_RESULTS];
113113
int n = encodeLatLonToMapcodes(mapcode_results, latitude, longitude, territorycode, extra_digits);
114-
// printf("encode: count %d\n", n);
115114
if (n > 0) {
116115
result = PyList_New(n);
117116
while (n--) {
118117
// printf("debug: %d: %s - %s\n", n, mapcode_results[n * 2], mapcode_results[(n * 2) + 1]);
119-
PyList_SetItem(result, n, Py_BuildValue("[ss]", (mapcode_results[n * 2]), mapcode_results[(n * 2) + 1]));
118+
PyList_SetItem(result, n, Py_BuildValue("(ss)", (mapcode_results[n * 2]), mapcode_results[(n * 2) + 1]));
120119
}
121120
return result;
122121
}

0 commit comments

Comments
 (0)