22
22
23
23
@shareable_encoder
24
24
def default_encoder (encoder , obj ):
25
- if isinstance (obj , GeometryPoint ):
26
- tagged = CBORTag (constants .TAG_GEOMETRY_POINT , obj .get_coordinates ())
27
-
28
25
if obj is None :
29
26
tagged = CBORTag (constants .TAG_NONE , None )
30
27
28
+ elif isinstance (obj , GeometryPoint ):
29
+ tagged = CBORTag (constants .TAG_GEOMETRY_POINT , obj .get_coordinates ())
30
+
31
31
elif isinstance (obj , GeometryLine ):
32
- tagged = CBORTag (constants .TAG_GEOMETRY_LINE , obj .get_coordinates () )
32
+ tagged = CBORTag (constants .TAG_GEOMETRY_LINE , obj .geometry_points )
33
33
34
34
elif isinstance (obj , GeometryPolygon ):
35
- tagged = CBORTag (constants .TAG_GEOMETRY_POLYGON , obj .get_coordinates () )
35
+ tagged = CBORTag (constants .TAG_GEOMETRY_POLYGON , obj .geometry_lines )
36
36
37
37
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 )
39
39
40
40
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 )
42
42
43
43
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 )
45
45
46
46
elif isinstance (obj , GeometryCollection ):
47
47
tagged = CBORTag (constants .TAG_GEOMETRY_COLLECTION , obj .geometries )
@@ -69,6 +69,7 @@ def default_encoder(encoder, obj):
69
69
70
70
elif isinstance (obj , IsoDateTimeWrapper ):
71
71
tagged = CBORTag (constants .TAG_DATETIME , obj .dt )
72
+
72
73
else :
73
74
raise BufferError ("no encoder for type " , type (obj ))
74
75
@@ -80,19 +81,19 @@ def tag_decoder(decoder, tag, shareable_index=None):
80
81
return GeometryPoint .parse_coordinates (tag .value )
81
82
82
83
elif tag .tag == constants .TAG_GEOMETRY_LINE :
83
- return GeometryLine . parse_coordinates ( tag .value )
84
+ return GeometryLine ( * tag .value )
84
85
85
86
elif tag .tag == constants .TAG_GEOMETRY_POLYGON :
86
- return GeometryPolygon . parse_coordinates ( tag .value )
87
+ return GeometryPolygon ( * tag .value )
87
88
88
89
elif tag .tag == constants .TAG_GEOMETRY_MULTI_POINT :
89
- return GeometryMultiPoint . parse_coordinates ( tag .value )
90
+ return GeometryMultiPoint ( * tag .value )
90
91
91
92
elif tag .tag == constants .TAG_GEOMETRY_MULTI_LINE :
92
- return GeometryMultiLine . parse_coordinates ( tag .value )
93
+ return GeometryMultiLine ( * tag .value )
93
94
94
95
elif tag .tag == constants .TAG_GEOMETRY_MULTI_POLYGON :
95
- return GeometryMultiPolygon . parse_coordinates ( tag .value )
96
+ return GeometryMultiPolygon ( * tag .value )
96
97
97
98
elif tag .tag == constants .TAG_GEOMETRY_COLLECTION :
98
99
return GeometryCollection (* tag .value )
0 commit comments