Skip to content

Commit 045a72d

Browse files
fixing polygon issue (#178)
1 parent 221d87c commit 045a72d

File tree

3 files changed

+489
-14
lines changed

3 files changed

+489
-14
lines changed

src/surrealdb/connections/utils_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class UtilsMixin:
33
@staticmethod
44
def check_response_for_error(response: dict, process: str) -> None:
55
if response.get("error") is not None:
6-
raise Exception(response.get('error'))
6+
raise Exception(response.get("error"))
77

88
@staticmethod
99
def check_response_for_result(response: dict, process: str) -> None:

src/surrealdb/data/cbor.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@
2222

2323
@shareable_encoder
2424
def default_encoder(encoder, obj):
25-
if isinstance(obj, GeometryPoint):
26-
tagged = CBORTag(constants.TAG_GEOMETRY_POINT, obj.get_coordinates())
27-
2825
if obj is None:
2926
tagged = CBORTag(constants.TAG_NONE, None)
3027

28+
elif isinstance(obj, GeometryPoint):
29+
tagged = CBORTag(constants.TAG_GEOMETRY_POINT, obj.get_coordinates())
30+
3131
elif isinstance(obj, GeometryLine):
32-
tagged = CBORTag(constants.TAG_GEOMETRY_LINE, obj.get_coordinates())
32+
tagged = CBORTag(constants.TAG_GEOMETRY_LINE, obj.geometry_points)
3333

3434
elif isinstance(obj, GeometryPolygon):
35-
tagged = CBORTag(constants.TAG_GEOMETRY_POLYGON, obj.get_coordinates())
35+
tagged = CBORTag(constants.TAG_GEOMETRY_POLYGON, obj.geometry_lines)
3636

3737
elif isinstance(obj, GeometryMultiLine):
38-
tagged = CBORTag(constants.TAG_GEOMETRY_MULTI_LINE, obj.get_coordinates())
38+
tagged = CBORTag(constants.TAG_GEOMETRY_MULTI_LINE, obj.geometry_lines)
3939

4040
elif isinstance(obj, GeometryMultiPoint):
41-
tagged = CBORTag(constants.TAG_GEOMETRY_MULTI_POINT, obj.get_coordinates())
41+
tagged = CBORTag(constants.TAG_GEOMETRY_MULTI_POINT, obj.geometry_points)
4242

4343
elif isinstance(obj, GeometryMultiPolygon):
44-
tagged = CBORTag(constants.TAG_GEOMETRY_MULTI_POLYGON, obj.get_coordinates())
44+
tagged = CBORTag(constants.TAG_GEOMETRY_MULTI_POLYGON, obj.geometry_polygons)
4545

4646
elif isinstance(obj, GeometryCollection):
4747
tagged = CBORTag(constants.TAG_GEOMETRY_COLLECTION, obj.geometries)
@@ -69,6 +69,7 @@ def default_encoder(encoder, obj):
6969

7070
elif isinstance(obj, IsoDateTimeWrapper):
7171
tagged = CBORTag(constants.TAG_DATETIME, obj.dt)
72+
7273
else:
7374
raise BufferError("no encoder for type ", type(obj))
7475

@@ -80,19 +81,19 @@ def tag_decoder(decoder, tag, shareable_index=None):
8081
return GeometryPoint.parse_coordinates(tag.value)
8182

8283
elif tag.tag == constants.TAG_GEOMETRY_LINE:
83-
return GeometryLine.parse_coordinates(tag.value)
84+
return GeometryLine(*tag.value)
8485

8586
elif tag.tag == constants.TAG_GEOMETRY_POLYGON:
86-
return GeometryPolygon.parse_coordinates(tag.value)
87+
return GeometryPolygon(*tag.value)
8788

8889
elif tag.tag == constants.TAG_GEOMETRY_MULTI_POINT:
89-
return GeometryMultiPoint.parse_coordinates(tag.value)
90+
return GeometryMultiPoint(*tag.value)
9091

9192
elif tag.tag == constants.TAG_GEOMETRY_MULTI_LINE:
92-
return GeometryMultiLine.parse_coordinates(tag.value)
93+
return GeometryMultiLine(*tag.value)
9394

9495
elif tag.tag == constants.TAG_GEOMETRY_MULTI_POLYGON:
95-
return GeometryMultiPolygon.parse_coordinates(tag.value)
96+
return GeometryMultiPolygon(*tag.value)
9697

9798
elif tag.tag == constants.TAG_GEOMETRY_COLLECTION:
9899
return GeometryCollection(*tag.value)

0 commit comments

Comments
 (0)