MobilityDB 1.1
Macros | Functions | Variables
type_out.c File Reference
#include <assert.h>
#include <float.h>
#include <postgres.h>
#include <liblwgeom_internal.h>
#include <meos.h>
#include <meos_internal.h>
#include "general/pg_types.h"
#include "general/tinstant.h"
#include "general/tsequence.h"
#include "general/tsequenceset.h"
#include "general/type_util.h"
#include "point/tpoint_spatialfuncs.h"
Include dependency graph for type_out.c:

Macros

#define MOBDB_WKT_BOOL_SIZE   sizeof("false")
 Output of temporal types in WKT, MF-JSON, WKB, EWKB, and HexWKB format. More...
 
#define MOBDB_WKT_INT4_SIZE   sizeof("+2147483647")
 
#define MOBDB_WKT_INT8_SIZE   sizeof("+9223372036854775807")
 
#define MOBDB_WKT_TIMESTAMPTZ_SIZE   sizeof("\"2019-08-06T18:35:48.021455+02:30\",")
 
#define OUT_MAX_DIGS_DOUBLE   (OUT_SHOW_DIGS_DOUBLE + 2) /* +2 mean add dot and sign */
 
#define OUT_MAX_DOUBLE_PRECISION   15
 
#define OUT_SHOW_DIGS_DOUBLE   20
 

Functions

static size_t basetype_to_wkb_size (Datum value, meosType basetype, int16 flags)
 Return the size of the WKB representation of a base value. More...
 
static uint8_t * basevalue_to_wkb_buf (Datum value, meosType basetype, int16 flags, uint8_t *buf, uint8_t variant)
 Write into the buffer a temporal instant represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t bbox_mfjson_buf (meosType temptype, char *output, const bboxunion *bbox, bool hasz, int precision)
 Write into the buffer the bounding box corresponding to the temporal type represented in MF-JSON format. More...
 
static size_t bbox_mfjson_size (meosType temptype, bool hasz, int precision)
 Return the maximum size in bytes of the bounding box corresponding to the temporal type represented in MF-JSON format. More...
 
static size_t bool_mfjson_buf (char *output, bool b)
 Write into the buffer an integer represented in MF-JSON format. More...
 
static uint8_t * bool_to_wkb_buf (bool b, uint8_t *buf, uint8_t variant)
 Write into the buffer a boolean represented in Well-Known Binary (WKB) format. More...
 
static uint8_t * bounds_to_wkb_buf (bool lower_inc, bool upper_inc, uint8_t *buf, uint8_t variant)
 Write into the buffer the flag containing the bounds represented in Well-Known Binary (WKB) format as follows xxxxxxUL x = Unused bits, U = Upper inclusive, L = Lower inclusive. More...
 
uint8_t * bytes_to_wkb_buf (char *valptr, size_t size, uint8_t *buf, uint8_t variant)
 Write into the buffer the bytes of the value represented in Well-Known Binary (WKB) format. More...
 
static size_t coordinates_mfjson_buf (char *output, const TInstant *inst, int precision)
 Write into the buffer the coordinate array represented in MF-JSON format. More...
 
static size_t coordinates_mfjson_size (int npoints, bool hasz, int precision)
 Return the maximum size in bytes of the coordinate array represented in MF-JSON format. More...
 
uint8_t * coords_to_wkb_buf (Datum value, int16 flags, uint8_t *buf, uint8_t variant)
 Write into the buffer the coordinates of the temporal instant point represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t datetimes_mfjson_buf (char *output, TimestampTz t)
 Write into the buffer the datetimes array represented in MF-JSON format. More...
 
static size_t datetimes_mfjson_size (int count)
 Return the maximum size in bytes of the datetimes array represented in MF-JSON format. More...
 
char * datum_as_hexwkb (Datum value, meosType type, uint8_t variant, size_t *size)
 Return the HexWKB representation of a datum value. More...
 
uint8_t * datum_as_wkb (Datum value, meosType type, uint8_t variant, size_t *size_out)
 Return the WKB representation of a datum value. More...
 
static uint8_t * datum_to_wkb_buf (Datum value, meosType type, uint8_t *buf, uint8_t variant)
 Write into the buffer the WKB representation of a value. More...
 
static size_t datum_to_wkb_size (Datum value, meosType type, uint8_t variant)
 Return the size of the WKB representation of a value. More...
 
static size_t double_mfjson_buf (char *output, double d, int precision)
 Write into the buffer the double value represented in MF-JSON format. More...
 
uint8_t * double_to_wkb_buf (const double d, uint8_t *buf, uint8_t variant)
 Write into the buffer the float64 represented in Well-Known Binary (WKB) format. More...
 
uint8_t * endian_to_wkb_buf (uint8_t *buf, uint8_t variant)
 Write into the buffer the Endian represented in Well-Known Binary (WKB) format. More...
 
bool geoset_wkb_needs_srid (const Set *set, uint8_t variant)
 Return true if the temporal point needs to output the SRID. More...
 
static uint8_t * int16_to_wkb_buf (const int16 i, uint8_t *buf, uint8_t variant)
 Write into the buffer the int2 represented in Well-Known Binary (WKB) format. More...
 
static size_t int32_mfjson_buf (char *output, int i)
 Write into the buffer an integer represented in MF-JSON format. More...
 
uint8_t * int32_to_wkb_buf (const int i, uint8_t *buf, uint8_t variant)
 Write into the buffer the int4 represented in Well-Known Binary (WKB) format. More...
 
uint8_t * int64_to_wkb_buf (const int64 i, uint8_t *buf, uint8_t variant)
 Write into the buffer the int8 represented in Well-Known Binary (WKB) format. More...
 
static uint8_t * lower_upper_to_wkb_buf (const Span *s, uint8_t *buf, uint8_t variant)
 Write into the buffer the lower and upper bounds of a span represented in Well-Known Binary (WKB) format. More...
 
static size_t period_mfjson_buf (char *output, const Span *p)
 Write into the buffer the period bounding box represented in MF-JSON format. More...
 
static size_t period_mfjson_size (void)
 Return the maximum size in bytes of the period bounding box represented in MF-JSON format. More...
 
char * set_as_hexwkb (const Set *s, uint8_t variant, size_t *size_out)
 Return the WKB representation of a set in hex-encoded ASCII. More...
 
uint8_t * set_as_wkb (const Set *s, uint8_t variant, size_t *size_out)
 Return the WKB representation of a set. More...
 
static size_t set_basetype_to_wkb_size (Datum value, meosType basetype, int16 flags)
 Return the size of the WKB representation of the base value of an ordered set type. More...
 
static uint8_t * set_flags_to_wkb_buf (const Set *set, uint8_t *buf, uint8_t variant)
 Write into the buffer the flag containing the temporal type and other characteristics represented in Well-Known Binary (WKB) format. More...
 
static uint8_t * set_to_wkb_buf (const Set *set, uint8_t *buf, uint8_t variant)
 Write into the buffer a set represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t set_to_wkb_size (const Set *set, uint8_t variant)
 Return the size in bytes of a set represented in Well-Known Binary (WKB) format. More...
 
char * span_as_hexwkb (const Span *s, uint8_t variant, size_t *size_out)
 Return the WKB representation of a span in hex-encoded ASCII. More...
 
uint8_t * span_as_wkb (const Span *s, uint8_t variant, size_t *size_out)
 Return the WKB representation of a span. More...
 
static size_t span_basetype_to_wkb_size (const Span *s)
 Return the size of the WKB representation of the base value of a span type. More...
 
uint8_t * span_to_wkb_buf (const Span *s, uint8_t *buf, uint8_t variant)
 Write into the buffer a span represented in Well-Known Binary (WKB) format as follows. More...
 
uint8_t * span_to_wkb_buf_int (const Span *s, uint8_t *buf, uint8_t variant)
 Write into the buffer a span that is a component of another type represented in Well-Known Binary (WKB) format as follows. More...
 
static uint8_t * span_to_wkb_buf_int1 (const Span *s, uint8_t *buf, uint8_t variant)
 Write into the buffer a span that is a component of a span set represented in Well-Known Binary (WKB) format as follows. More...
 
size_t span_to_wkb_size (const Span *s)
 Return the size in bytes of a span represented in Well-Known Binary (WKB) format. More...
 
size_t span_to_wkb_size_int (const Span *s)
 Return the size in bytes of a component span represented in Well-Known Binary (WKB) format. More...
 
char * spanset_as_hexwkb (const SpanSet *ss, uint8_t variant, size_t *size_out)
 Return the WKB representation of a span set in hex-encoded ASCII. More...
 
uint8_t * spanset_as_wkb (const SpanSet *ss, uint8_t variant, size_t *size_out)
 Return the WKB representation of a period set. More...
 
static uint8_t * spanset_to_wkb_buf (const SpanSet *ss, uint8_t *buf, uint8_t variant)
 Write into the buffer a span set represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t spanset_to_wkb_size (const SpanSet *ss)
 Return the size in bytes of a span set represented in Well-Known Binary (WKB) format. More...
 
static size_t srs_mfjson_buf (char *output, char *srs)
 Write into the buffer the SRS represented in MF-JSON format. More...
 
static size_t srs_mfjson_size (char *srs)
 Return the maximum size in bytes of the SRS represented in MF-JSON format. More...
 
char * stbox_as_hexwkb (const STBox *box, uint8_t variant, size_t *size_out)
 Return the WKB representation of a spatiotemporal box in hex-encoded ASCII. More...
 
uint8_t * stbox_as_wkb (const STBox *box, uint8_t variant, size_t *size_out)
 Return the WKB representation of a spatiotemporal box. More...
 
static uint8_t * stbox_flags_to_wkb_buf (const STBox *box, uint8_t *buf, uint8_t variant)
 Write into the buffer the flag of a spatiotemporal box represented in Well-Known Binary (WKB) format. More...
 
static size_t stbox_mfjson_buf (char *output, const STBox *bbox, bool hasz, int precision)
 Write into the buffer the spatiotemporal bounding box represented in MF-JSON format. More...
 
static size_t stbox_mfjson_size (bool hasz, int precision)
 Return the maximum size in bytes of the spatiotemporal bounding box represented in MF-JSON format. More...
 
static uint8_t * stbox_to_wkb_buf (const STBox *box, uint8_t *buf, uint8_t variant)
 Write into the buffer a spatiotemporal box represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t stbox_to_wkb_size (const STBox *box, uint8_t variant)
 Return the size in bytes of a spatiotemporal box represented in Well-Known Binary (WKB) format. More...
 
static bool stbox_wkb_needs_srid (const STBox *box, uint8_t variant)
 Return true if the spatiotemporal box needs to output the SRID. More...
 
char * tboolinst_as_mfjson (const TInstant *inst, bool with_bbox)
 Return the MF-JSON representation of a temporal instant boolean. More...
 
char * tboolseq_as_mfjson (const TSequence *seq, bool with_bbox)
 Return the MF-JSON representation of a temporal sequence boolean. More...
 
char * tboolseqset_as_mfjson (const TSequenceSet *ss, bool with_bbox)
 Return the MF-JSON representation of a temporal sequence set boolean. More...
 
char * tbox_as_hexwkb (const TBox *box, uint8_t variant, size_t *size_out)
 Return the WKB representation of a temporal box in hex-encoded ASCII. More...
 
uint8_t * tbox_as_wkb (const TBox *box, uint8_t variant, size_t *size_out)
 Return the WKB representation of a temporal box. More...
 
static size_t tbox_mfjson_buf (char *output, const TBox *bbox, int precision)
 Write into the buffer the temporal bounding box represented in MF-JSON format. More...
 
static size_t tbox_mfjson_size (int precision)
 Return the maximum size in bytes of the temporal bounding box represented in MF-JSON format. More...
 
static uint8_t * tbox_to_wkb_buf (const TBox *box, uint8_t *buf, uint8_t variant)
 Write into the buffer a temporal box represented in Well-Known Binary (WKB) format as follows. More...
 
static uint8_t * tbox_to_wkb_flags_buf (const TBox *box, uint8_t *buf, uint8_t variant)
 Write into the buffer the flag of a temporal box represented in Well-Known Binary (WKB) format. More...
 
static size_t tbox_to_wkb_size (const TBox *box)
 Return the size in bytes of a temporal box represented in Well-Known Binary (WKB) format. More...
 
char * temporal_as_hexwkb (const Temporal *temp, uint8_t variant, size_t *size_out)
 Return the WKB representation of a temporal value in hex-encoded ASCII. More...
 
char * temporal_as_mfjson (const Temporal *temp, bool with_bbox, int flags, int precision, char *srs)
 Return the MF-JSON representation of a temporal value. More...
 
uint8_t * temporal_as_wkb (const Temporal *temp, uint8_t variant, size_t *size_out)
 Return the WKB representation of a temporal value. More...
 
static size_t temporal_basetype_to_wkb_size (Datum value, meosType basetype, int16 flags)
 Return the size of the WKB representation of a base value. More...
 
static size_t temporal_basevalue_mfjson_buf (char *output, Datum value, meosType temptype, int precision)
 Write into the buffer a base value represented in MF-JSON format. More...
 
static size_t temporal_basevalue_mfjson_size (Datum value, meosType temptype, int precision)
 Write into the buffer a base value represented in MF-JSON format. More...
 
static uint8_t * temporal_flags_to_wkb_buf (const Temporal *temp, uint8_t *buf, uint8_t variant)
 Write into the buffer the flag containing the temporal type and other characteristics represented in Well-Known Binary (WKB) format. More...
 
static uint8_t * temporal_to_wkb_buf (const Temporal *temp, uint8_t *buf, uint8_t variant)
 Write into the buffer the temporal value represented in Well-Known Binary (WKB) format depending on the subtype. More...
 
static size_t temporal_to_wkb_size (const Temporal *temp, uint8_t variant)
 Return the maximum size in bytes of the temporal value represented in Well-Known Binary (WKB) format. More...
 
char ** temporalarr_out (const Temporal **temparr, int count, int maxdd)
 Return the Well-Known Text (WKT) representation of an array of temporal values. More...
 
static size_t temptype_mfjson_buf (char *output, meosType temptype)
 Write into the buffer the temporal type represented in MF-JSON format. More...
 
static size_t temptype_mfjson_size (meosType temptype)
 Return the maximum size in bytes of the temporal type represented in MF-JSON format. More...
 
static size_t text_mfjson_buf (char *output, text *txt)
 Write into the buffer a text value represented in MF-JSON format. More...
 
static uint8_t * text_to_wkb_buf (const text *txt, uint8_t *buf, uint8_t variant)
 Write into the buffer a text value represented in Well-Known Binary (WKB) format. More...
 
char * tfloatinst_as_mfjson (const TInstant *inst, bool with_bbox, int precision)
 Return the MF-JSON representation of a temporal instant float. More...
 
char * tfloatseq_as_mfjson (const TSequence *seq, bool with_bbox, int precision)
 Return the MF-JSON representation of a temporal sequence float. More...
 
char * tfloatseqset_as_mfjson (const TSequenceSet *ss, bool with_bbox, int precision)
 Return the MF-JSON representation of a temporal sequence set float. More...
 
char * tgeogpointinst_as_mfjson (const TInstant *inst, bool with_bbox, int precision, char *srs)
 Return the MF-JSON representation of a temporal instant geographic point. More...
 
char * tgeogpointseq_as_mfjson (const TSequence *seq, bool with_bbox, int precision, char *srs)
 Return the MF-JSON representation of a temporal sequence geographic point. More...
 
char * tgeogpointseqset_as_mfjson (const TSequenceSet *ss, bool with_bbox, int precision, char *srs)
 Return the MF-JSON representation of a temporal sequence set geographic point. More...
 
char * tgeompointinst_as_mfjson (const TInstant *inst, bool with_bbox, int precision, char *srs)
 Return the MF-JSON representation of a temporal instant geometric point. More...
 
char * tgeompointseq_as_mfjson (const TSequence *seq, bool with_bbox, int precision, char *srs)
 Return the MF-JSON representation of a temporal sequence geometric point. More...
 
char * tgeompointseqset_as_mfjson (const TSequenceSet *ss, bool with_bbox, int precision, char *srs)
 Return the MF-JSON representation of a temporal sequence set geometric point. More...
 
uint8_t * timestamp_to_wkb_buf (const TimestampTz t, uint8_t *buf, uint8_t variant)
 Write into the buffer the TimestampTz (aka int64) represented in Well-Known Binary (WKB) format. More...
 
char * tinstant_as_mfjson (const TInstant *inst, int precision, bool with_bbox, char *srs)
 Return the MF-JSON representation of a temporal instant. More...
 
static uint8_t * tinstant_basevalue_time_to_wkb_buf (const TInstant *inst, uint8_t *buf, uint8_t variant)
 Write into the buffer a temporal instant represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t tinstant_mfjson_buf (const TInstant *inst, bool isgeo, bool hasz, int precision, const bboxunion *bbox, char *srs, char *output)
 Write into the buffer the temporal instant represented in MF-JSON format. More...
 
static size_t tinstant_mfjson_size (const TInstant *inst, bool isgeo, bool hasz, int precision, const bboxunion *bbox, char *srs)
 Return the maximum size in bytes of a temporal instant represented in MF-JSON format. More...
 
static uint8_t * tinstant_to_wkb_buf (const TInstant *inst, uint8_t *buf, uint8_t variant)
 Write into the buffer the temporal instant represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t tinstant_to_wkb_size (const TInstant *inst, uint8_t variant)
 Return the maximum size in bytes of the temporal instant represented in Well-Known Binary (WKB) format. More...
 
static size_t tinstarr_to_wkb_size (const TInstant **instants, int count)
 Return the maximum size in bytes of an array of temporal instants represented in Well-Known Binary (WKB) format. More...
 
char * tintinst_as_mfjson (const TInstant *inst, bool with_bbox)
 Return the MF-JSON representation of a temporal instant integer. More...
 
char * tintseq_as_mfjson (const TSequence *seq, bool with_bbox)
 Return the MF-JSON representation of a temporal sequence integer. More...
 
char * tintseqset_as_mfjson (const TSequenceSet *ss, bool with_bbox)
 Return the MF-JSON representation of a temporal sequence set integer. More...
 
bool tpoint_wkb_needs_srid (const Temporal *temp, uint8_t variant)
 Return true if the temporal point needs to output the SRID. More...
 
char * tsequence_as_mfjson (const TSequence *seq, int precision, bool with_bbox, char *srs)
 Return the MF-JSON representation of a temporal sequence. More...
 
static size_t tsequence_mfjson_buf (const TSequence *seq, bool isgeo, bool hasz, int precision, const bboxunion *bbox, char *srs, char *output)
 Write into the buffer the temporal sequence represented in MF-JSON format. More...
 
static size_t tsequence_mfjson_size (const TSequence *seq, bool isgeo, bool hasz, int precision, const bboxunion *bbox, char *srs)
 Return the maximum size in bytes of a temporal sequence represented in MF-JSON format. More...
 
static uint8_t * tsequence_to_wkb_buf (const TSequence *seq, uint8_t *buf, uint8_t variant)
 Write into the buffer the temporal sequence represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t tsequence_to_wkb_size (const TSequence *seq, uint8_t variant)
 Return the maximum size in bytes of the temporal sequence represented in Well-Known Binary (WKB) format. More...
 
char * tsequenceset_as_mfjson (const TSequenceSet *ss, int precision, bool with_bbox, char *srs)
 Return the MF-JSON representation of a temporal sequence set. More...
 
static size_t tsequenceset_mfjson_buf (const TSequenceSet *ss, bool isgeo, bool hasz, int precision, const bboxunion *bbox, char *srs, char *output)
 Write into the buffer the temporal sequence set represented in MF-JSON format. More...
 
static size_t tsequenceset_mfjson_size (const TSequenceSet *ss, bool isgeo, bool hasz, int precision, const bboxunion *bbox, char *srs)
 Return the maximum size in bytes of a temporal sequence set represented in MF-JSON format. More...
 
static uint8_t * tsequenceset_to_wkb_buf (const TSequenceSet *ss, uint8_t *buf, uint8_t variant)
 Write into the buffer a temporal sequence set represented in Well-Known Binary (WKB) format as follows. More...
 
static size_t tsequenceset_to_wkb_size (const TSequenceSet *ss, uint8_t variant)
 Return the maximum size in bytes of the temporal sequence set represented in Well-Known Binary (WKB) format. More...
 
char * ttextinst_as_mfjson (const TInstant *inst, bool with_bbox)
 Return the MF-JSON representation of a temporal instant text. More...
 
char * ttextseq_as_mfjson (const TSequence *seq, bool with_bbox)
 Return the MF-JSON representation of a temporal sequence text. More...
 
char * ttextseqset_as_mfjson (const TSequenceSet *ss, bool with_bbox)
 Return the MF-JSON representation of a temporal sequence set text. More...
 
static uint8_t * uint8_to_wkb_buf (const uint8_t i, uint8_t *buf, uint8_t variant)
 Write into the buffer the int4 represented in Well-Known Binary (WKB) format. More...
 
static bool wkb_swap_bytes (uint8_t variant)
 Return true if the bytes must be swaped dependng of the variant. More...
 

Variables

static char * hexchr = "0123456789ABCDEF"
 Look-up table for hex writer. More...