Skip to content

Commit df0aeb3

Browse files
committed
Add encoder for 3D
1 parent b365a0f commit df0aeb3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/mgsession-encoder.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ int mg_session_write_point_2d(mg_session *session, const mg_point_2d *point) {
178178
return 0;
179179
}
180180

181+
int mg_session_write_point_3d(mg_session *session, const mg_point_3d *point) {
182+
MG_RETURN_IF_FAILED(
183+
mg_session_write_uint8(session, (uint8_t)(MG_MARKER_TINY_STRUCT4)));
184+
MG_RETURN_IF_FAILED(mg_session_write_uint8(session, MG_SIGNATURE_POINT_3D));
185+
MG_RETURN_IF_FAILED(mg_session_write_integer(session, point->srid));
186+
MG_RETURN_IF_FAILED(mg_session_write_float(session, point->x));
187+
MG_RETURN_IF_FAILED(mg_session_write_float(session, point->y));
188+
MG_RETURN_IF_FAILED(mg_session_write_float(session, point->z));
189+
return 0;
190+
}
191+
181192
int mg_session_write_value(mg_session *session, const mg_value *value) {
182193
switch (value->type) {
183194
case MG_VALUE_TYPE_NULL:
@@ -230,11 +241,8 @@ int mg_session_write_value(mg_session *session, const mg_value *value) {
230241
return mg_session_write_duration(session, value->duration_v);
231242
case MG_VALUE_TYPE_POINT_2D:
232243
return mg_session_write_point_2d(session, value->point_2d_v);
233-
// mg_session_set_error(session, "tried to send value of type
234-
// 'point_2d'"); // TODO(gitbuda): remove return MG_ERROR_INVALID_VALUE;
235244
case MG_VALUE_TYPE_POINT_3D:
236-
mg_session_set_error(session, "tried to send value of type 'point_3d'");
237-
return MG_ERROR_INVALID_VALUE;
245+
return mg_session_write_point_3d(session, value->point_3d_v);
238246
case MG_VALUE_TYPE_UNKNOWN:
239247
mg_session_set_error(session, "tried to send value of unknown type");
240248
return MG_ERROR_INVALID_VALUE;

0 commit comments

Comments
 (0)