/[zanavi_public1]/navit/navit/binding/python/pcoord.c
ZANavi

Contents of /navit/navit/binding/python/pcoord.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 1981 byte(s)
import files
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "common.h"
21 #include "coord.h"
22
23 typedef struct {
24 PyObject_HEAD
25 struct pcoord pc;
26 } pcoordObject;
27
28 static PyObject *
29 pcoord_func(pcoordObject *self, PyObject *args)
30 {
31 const char *file;
32 int ret=0;
33 if (!PyArg_ParseTuple(args, "s", &file))
34 return NULL;
35 return Py_BuildValue("i",ret);
36 }
37
38
39
40 static PyMethodDef pcoord_methods[] = {
41 {"func", (PyCFunction) pcoord_func, METH_VARARGS },
42 {NULL, NULL },
43 };
44
45
46 static PyObject *
47 pcoord_getattr_py(PyObject *self, char *name)
48 {
49 return Py_FindMethod(pcoord_methods, self, name);
50 }
51
52 static void
53 pcoord_destroy_py(pcoordObject *self)
54 {
55 }
56
57 PyTypeObject pcoord_Type = {
58 Obj_HEAD
59 .tp_name="pcoord",
60 .tp_basicsize=sizeof(pcoordObject),
61 .tp_dealloc=(destructor)pcoord_destroy_py,
62 .tp_getattr=pcoord_getattr_py,
63 };
64
65 PyObject *
66 pcoord_py(PyObject *self, PyObject *args)
67 {
68 pcoordObject *ret;
69 const char *str;
70 enum projection pro;
71 struct coord c;
72 if (!PyArg_ParseTuple(args, "si", &str, &pro))
73 return NULL;
74 ret=PyObject_NEW(pcoordObject, &pcoord_Type);
75 coord_parse(str, pro, &c);
76 ret->pc.pro=pro;
77 ret->pc.x=c.x;
78 ret->pc.y=c.y;
79 dbg(0,"0x%x,0x%x\n", c.x, c.y);
80 return (PyObject *)ret;
81 }
82
83 struct pcoord *
84 pcoord_py_get(PyObject *self)
85 {
86 return &((pcoordObject *)self)->pc;
87 }
88

   
Visit the ZANavi Wiki