Return -1 if g1 is "less than" g2, 1 if g1 is "greater than" g2 and 0 if g1 and g2 are the "same".
Equality is evaluated with a memcmp and size check. So it is possible that two identical objects where one lacks a bounding box could be evaluated as non-equal initially. Greater and less than are evaluated by calculating a sortable key from the center point of the object bounds.
Definition at line 294 of file g_serialized.c.
296 int g1_is_empty, g2_is_empty, cmp;
298 uint64_t hash1, hash2;
315 double *dptr = (
double*)(g1->
data +
sizeof(
double));
320 dptr = (
double*)(g2->
data +
sizeof(
double));
344 size_t bsz1 = sz1 - hsz1;
345 size_t bsz2 = sz2 - hsz2;
346 size_t bsz = bsz1 < bsz2 ? bsz1 : bsz2;
354 if (g1_is_empty && !g2_is_empty)
358 if (!g1_is_empty && g2_is_empty)
362 cmp = memcmp(b1, b2, bsz);
363 if ( bsz1 == bsz2 && cmp_srid == 0 && cmp == 0 )
366 if (!g1_is_empty && !g2_is_empty)
376 else if ( hash1 < hash2 )
404 if (bsz1 != bsz2 && cmp == 0)
408 else if (bsz1 > bsz2)
411 return cmp > 0 ? 1 : -1;
static int gserialized_cmp_srid(const GSERIALIZED *s1, const GSERIALIZED *s2)
static uint64_t uint32_interleave_2(uint32_t u1, uint32_t u2)
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Read the bounding box off a serialization and calculate one if it is not already there.
uint32_t gserialized_header_size(const GSERIALIZED *gser)
Returns the size in bytes of the header, from the start of the object up to the type number.
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
uint64_t gbox_get_sortable_hash(const GBOX *g)
Return a sortable key based on the center point of the GBOX.
#define FLAGS_GET_BBOX(flags)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define SIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
References GSERIALIZED::data, GSERIALIZED::flags, FLAGS_GET_BBOX, gbox_get_sortable_hash(), gserialized_cmp_srid(), gserialized_get_gbox_p(), gserialized_get_type(), gserialized_header_size(), LW_FAILURE, POINTTYPE, GSERIALIZED::size, SIZE_GET, uint32_interleave_2(), pixval::x, GBOX::xmax, GBOX::xmin, pixval::y, GBOX::ymax, and GBOX::ymin.
Referenced by geography_cmp(), geography_eq(), geography_ge(), geography_gt(), geography_le(), geography_lt(), lwgeom_cmp(), lwgeom_eq(), lwgeom_ge(), lwgeom_gt(), lwgeom_le(), and lwgeom_lt().