File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 1616
1717#include "Python.h"
1818#include "mapcoder.c"
19-
19+ #include <math.h>
2020
2121static char version_doc [] =
2222"version() -> string\n\
@@ -56,7 +56,7 @@ static char decode_doc[] =
5656Decodes the provided string to latitude and longitude. Optionally\n\
5757a territoryname can be provided to disambiguate the mapcode.\n\
5858\n\
59- Returns (999,999 ) when decoding failed.\n" ;
59+ Returns (nan,nan ) when decoding failed.\n" ;
6060
6161static PyObject * decode (PyObject * self , PyObject * args )
6262{
@@ -70,15 +70,17 @@ static PyObject *decode(PyObject *self, PyObject *args)
7070 if (territoryname ) {
7171 territorycode = convertTerritoryIsoNameToCode (territoryname , 0 );
7272 if (territorycode < 0 ) {
73- return Py_False ;
73+ latitude = NAN ;
74+ longitude = NAN ;
75+ return Py_BuildValue ("ff" , latitude , longitude );
7476 }
7577 } else
7678 territorycode = 0 ;
7779
7880 if (decodeMapcodeToLatLon (& latitude , & longitude , mapcode , territorycode )) {
79- /* return 999/999 as error values */
80- latitude = 999 ;
81- longitude = 999 ;
81+ /* return nan,nan as error values */
82+ latitude = NAN ;
83+ longitude = NAN ;
8284 }
8385 return Py_BuildValue ("ff" , latitude , longitude );
8486}
You can’t perform that action at this time.
0 commit comments