5
5
# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
6
6
7
7
8
- from ..types import Box, Line, LineSegment, Path, Point, Polygon, Circle
9
-
10
-
11
8
cdef inline _encode_points(WriteBuffer wbuf, object points):
12
9
cdef object point
13
10
@@ -28,7 +25,7 @@ cdef inline _decode_points(FRBuffer *buf):
28
25
for i in range (npts):
29
26
x = hton.unpack_double(frb_read(buf, 8 ))
30
27
y = hton.unpack_double(frb_read(buf, 8 ))
31
- point = Point(x, y)
28
+ point = pgproto_types. Point(x, y)
32
29
cpython.Py_INCREF(point)
33
30
cpython.PyTuple_SET_ITEM(pts, i, point)
34
31
@@ -47,7 +44,9 @@ cdef box_decode(CodecContext settings, FRBuffer *buf):
47
44
double low_x = hton.unpack_double(frb_read(buf, 8 ))
48
45
double low_y = hton.unpack_double(frb_read(buf, 8 ))
49
46
50
- return Box(Point(high_x, high_y), Point(low_x, low_y))
47
+ return pgproto_types.Box(
48
+ pgproto_types.Point(high_x, high_y),
49
+ pgproto_types.Point(low_x, low_y))
51
50
52
51
53
52
cdef line_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -63,7 +62,7 @@ cdef line_decode(CodecContext settings, FRBuffer *buf):
63
62
double B = hton.unpack_double(frb_read(buf, 8 ))
64
63
double C = hton.unpack_double(frb_read(buf, 8 ))
65
64
66
- return Line(A, B, C)
65
+ return pgproto_types. Line(A, B, C)
67
66
68
67
69
68
cdef lseg_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -78,7 +77,7 @@ cdef lseg_decode(CodecContext settings, FRBuffer *buf):
78
77
double p2_x = hton.unpack_double(frb_read(buf, 8 ))
79
78
double p2_y = hton.unpack_double(frb_read(buf, 8 ))
80
79
81
- return LineSegment((p1_x, p1_y), (p2_x, p2_y))
80
+ return pgproto_types. LineSegment((p1_x, p1_y), (p2_x, p2_y))
82
81
83
82
84
83
cdef point_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -92,7 +91,7 @@ cdef point_decode(CodecContext settings, FRBuffer *buf):
92
91
double x = hton.unpack_double(frb_read(buf, 8 ))
93
92
double y = hton.unpack_double(frb_read(buf, 8 ))
94
93
95
- return Point(x, y)
94
+ return pgproto_types. Point(x, y)
96
95
97
96
98
97
cdef path_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -106,7 +105,7 @@ cdef path_encode(CodecContext settings, WriteBuffer wbuf, obj):
106
105
is_closed = 1
107
106
elif cpython.PyList_Check(obj):
108
107
is_closed = 0
109
- elif isinstance (obj, Path):
108
+ elif isinstance (obj, pgproto_types. Path):
110
109
is_closed = obj.is_closed
111
110
112
111
npts = len (obj)
@@ -125,7 +124,7 @@ cdef path_decode(CodecContext settings, FRBuffer *buf):
125
124
cdef:
126
125
int8_t is_closed = < int8_t> (frb_read(buf, 1 )[0 ])
127
126
128
- return Path(* _decode_points(buf), is_closed = is_closed == 1 )
127
+ return pgproto_types. Path(* _decode_points(buf), is_closed = is_closed == 1 )
129
128
130
129
131
130
cdef poly_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -146,7 +145,7 @@ cdef poly_encode(CodecContext settings, WriteBuffer wbuf, obj):
146
145
147
146
148
147
cdef poly_decode(CodecContext settings, FRBuffer * buf):
149
- return Polygon(* _decode_points(buf))
148
+ return pgproto_types. Polygon(* _decode_points(buf))
150
149
151
150
152
151
cdef circle_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -162,4 +161,4 @@ cdef circle_decode(CodecContext settings, FRBuffer *buf):
162
161
double center_y = hton.unpack_double(frb_read(buf, 8 ))
163
162
double radius = hton.unpack_double(frb_read(buf, 8 ))
164
163
165
- return Circle((center_x, center_y), radius)
164
+ return pgproto_types. Circle((center_x, center_y), radius)
0 commit comments