-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyDataset_1.c
80 lines (67 loc) · 1.97 KB
/
pyDataset_1.c
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
#include "Python.h"
#include "Dataset.h"
#include "GeoJSON.h"
using namespace Mapzen::Pelopia;
using namespace std;
/*Create a new Dataset object*/
static PyObject *py_Dataset(Py_Object *self, PyObject *args)
{
const char *filename;
Dataset ds;
if (!PyArg_ParseTuple(args, "s", &filename);
{
return NULL;
}
Dataset ds (filename);
return Py_BuildValue("O", ds);
}
/* Python code: ds = Dataset(NYC.Pelopia) */
/* Responce Search(const char* text, const LatLon& scope, const Distance& radius, Format format)*/
static PyObject *py_Search(Py_Object *self, PyObject *args)
{
Py_Object *self;
const char *text;
double lat;
double lon;
double radius;
int format;
Responce resp;
if (!PyArg_ParseTuple(args, "Ocdddi", &self, & text, &lat, &lon, &radius, &format))
{
return NULL;
}
resp = self.Serch(text, LatLon(lat,lon), Distance(Miles, radius), Format(format));
return Py_BuildValue("O", resp);
}
/* resp = ds.Search(text, Latlon(lat,lon),radius, format) */
/*bool Get ( unsigned int index, Id & id, MarchQuality & score )*/
static PyObject *py_Get(Py_Object *self, Py_Object *args)
{
Py_Object *self;
unsigned int index;
Id id;
MarchQuality score;
bool result;
if (!PyArg_ParseTuple(args, 'OiOO', @self, &index, &id, &score))
{
return NULL;
}
result = self.Get(i, id, score);
return Py_BuildValue("O", result);
}
/* for i in resp:
resp.Get(i, id, score */
/* place Place(id)*/
static PyObject *py_Place(Py_Object *self, PyObject *args)
{
Py_Object *self;
Id id;
Feature place;
if (!PyArg_ParseTuple(args, "OO", &self, &id))
{
return NULL;
}
place = self.Place(id);
return Py_BuildValue("O", place);
}
/* place = ds.Place(id) */