本文整理汇总了C++中FLAGS_GET_M函数的典型用法代码示例。如果您正苦于以下问题:C++ FLAGS_GET_M函数的具体用法?C++ FLAGS_GET_M怎么用?C++ FLAGS_GET_M使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FLAGS_GET_M函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lwline_from_gserialized_buffer
static LWLINE* lwline_from_gserialized_buffer(uint8_t *data_ptr, uint8_t g_flags, size_t *g_size)
{
uint8_t *start_ptr = data_ptr;
LWLINE *line;
uint32_t npoints = 0;
assert(data_ptr);
line = (LWLINE*)lwalloc(sizeof(LWLINE));
line->srid = SRID_UNKNOWN; /* Default */
line->bbox = NULL;
line->type = LINETYPE;
line->flags = g_flags;
data_ptr += 4; /* Skip past the type. */
npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
data_ptr += 4; /* Skip past the npoints. */
if ( npoints > 0 )
line->points = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, data_ptr);
else
line->points = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty linestring */
data_ptr += FLAGS_NDIMS(g_flags) * npoints * sizeof(double);
if ( g_size )
*g_size = data_ptr - start_ptr;
return line;
}
示例2: lwcircstring_from_gserialized_buffer
static LWCIRCSTRING* lwcircstring_from_gserialized_buffer(uint8_t *data_ptr, uint8_t g_flags, size_t *g_size)
{
uint8_t *start_ptr = data_ptr;
LWCIRCSTRING *circstring;
uint32_t npoints = 0;
assert(data_ptr);
circstring = (LWCIRCSTRING*)lwalloc(sizeof(LWCIRCSTRING));
circstring->srid = SRID_UNKNOWN; /* Default */
circstring->bbox = NULL;
circstring->type = CIRCSTRINGTYPE;
circstring->flags = g_flags;
data_ptr += 4; /* Skip past the circstringtype. */
npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
data_ptr += 4; /* Skip past the npoints. */
if ( npoints > 0 )
circstring->points = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, data_ptr);
else
circstring->points = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty circularstring */
data_ptr += FLAGS_NDIMS(g_flags) * npoints * sizeof(double);
if ( g_size )
*g_size = data_ptr - start_ptr;
return circstring;
}
示例3: gbox_to_string
char* gbox_to_string(const GBOX *gbox)
{
static int sz = 128;
char *str = NULL;
if ( ! gbox )
return strdup("NULL POINTER");
str = (char*)lwalloc(sz);
if ( FLAGS_GET_GEODETIC(gbox->flags) )
{
snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->xmax, gbox->ymax, gbox->zmax);
return str;
}
if ( FLAGS_GET_Z(gbox->flags) && FLAGS_GET_M(gbox->flags) )
{
snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->mmin, gbox->xmax, gbox->ymax, gbox->zmax, gbox->mmax);
return str;
}
if ( FLAGS_GET_Z(gbox->flags) )
{
snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->xmax, gbox->ymax, gbox->zmax);
return str;
}
if ( FLAGS_GET_M(gbox->flags) )
{
snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->mmin, gbox->xmax, gbox->ymax, gbox->mmax);
return str;
}
snprintf(str, sz, "GBOX((%.8g,%.8g),(%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->xmax, gbox->ymax);
return str;
}
示例4: gbox_overlaps
int gbox_overlaps(const GBOX *g1, const GBOX *g2)
{
/* Make sure our boxes are consistent */
if ( FLAGS_GET_GEODETIC(g1->flags) != FLAGS_GET_GEODETIC(g2->flags) )
lwerror("gbox_overlaps: cannot compare geodetic and non-geodetic boxes");
/* Check X/Y first */
if ( g1->xmax < g2->xmin || g1->ymax < g2->ymin ||
g1->xmin > g2->xmax || g1->ymin > g2->ymax )
return LW_FALSE;
/* If both geodetic or both have Z, check Z */
if ( (FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags)) ||
(FLAGS_GET_GEODETIC(g1->flags) && FLAGS_GET_GEODETIC(g2->flags)) )
{
if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
return LW_FALSE;
}
/* If both have M, check M */
if ( FLAGS_GET_M(g1->flags) && FLAGS_GET_M(g2->flags) )
{
if ( g1->mmax < g2->mmin || g1->mmin > g2->mmax )
return LW_FALSE;
}
return LW_TRUE;
}
示例5: lwpoint_from_gserialized_buffer
static LWPOINT* lwpoint_from_gserialized_buffer(uint8_t *data_ptr, uint8_t g_flags, size_t *g_size)
{
uint8_t *start_ptr = data_ptr;
LWPOINT *point;
uint32_t npoints = 0;
assert(data_ptr);
point = (LWPOINT*)lwalloc(sizeof(LWPOINT));
point->srid = SRID_UNKNOWN; /* Default */
point->bbox = NULL;
point->type = POINTTYPE;
point->flags = g_flags;
data_ptr += 4; /* Skip past the type. */
npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
data_ptr += 4; /* Skip past the npoints. */
if ( npoints > 0 )
point->point = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 1, data_ptr);
else
point->point = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty point */
data_ptr += npoints * FLAGS_NDIMS(g_flags) * sizeof(double);
if ( g_size )
*g_size = data_ptr - start_ptr;
return point;
}
示例6: LWGEOM_m_point
Datum LWGEOM_m_point(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom;
LWPOINT *point = NULL;
LWGEOM *lwgeom;
POINT3DM p;
geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
if ( gserialized_get_type(geom) != POINTTYPE )
lwerror("Argument to M() must be a point");
lwgeom = lwgeom_from_gserialized(geom);
point = lwgeom_as_lwpoint(lwgeom);
if ( lwgeom_is_empty(lwgeom) )
PG_RETURN_NULL();
/* no M in input */
if ( ! FLAGS_GET_M(point->flags) ) PG_RETURN_NULL();
getPoint3dm_p(point->point, 0, &p);
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_FLOAT8(p.m);
}
示例7: ptarray_merge
/**
* @brief Merge two given POINTARRAY and returns a pointer
* on the new aggregate one.
* Warning: this function free the two inputs POINTARRAY
* @return #POINTARRAY is newly allocated
*/
POINTARRAY *
ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
{
POINTARRAY *pa;
size_t ptsize = ptarray_point_size(pa1);
if (FLAGS_GET_ZM(pa1->flags) != FLAGS_GET_ZM(pa2->flags))
lwerror("ptarray_cat: Mixed dimension");
pa = ptarray_construct( FLAGS_GET_Z(pa1->flags),
FLAGS_GET_M(pa1->flags),
pa1->npoints + pa2->npoints);
memcpy( getPoint_internal(pa, 0),
getPoint_internal(pa1, 0),
ptsize*(pa1->npoints));
memcpy( getPoint_internal(pa, pa1->npoints),
getPoint_internal(pa2, 0),
ptsize*(pa2->npoints));
lwfree(pa1);
lwfree(pa2);
return pa;
}
示例8: lwcircstring_calculate_gbox_cartesian
static int lwcircstring_calculate_gbox_cartesian(LWCIRCSTRING *curve, GBOX *gbox)
{
uint8_t flags = gflags(FLAGS_GET_Z(curve->flags), FLAGS_GET_M(curve->flags), 0);
GBOX tmp;
POINT4D p1, p2, p3;
int i;
if ( ! curve ) return LW_FAILURE;
if ( curve->points->npoints < 3 ) return LW_FAILURE;
tmp.flags = flags;
/* Initialize */
gbox->xmin = gbox->ymin = gbox->zmin = gbox->mmin = MAXFLOAT;
gbox->xmax = gbox->ymax = gbox->zmax = gbox->mmax = -1 * MAXFLOAT;
for ( i = 2; i < curve->points->npoints; i += 2 )
{
getPoint4d_p(curve->points, i-2, &p1);
getPoint4d_p(curve->points, i-1, &p2);
getPoint4d_p(curve->points, i, &p3);
if (lw_arc_calculate_gbox_cartesian(&p1, &p2, &p3, &tmp) == LW_FAILURE)
continue;
gbox_merge(&tmp, gbox);
}
return LW_SUCCESS;
}
示例9: wkt_parser_point_new
/**
* Create a new point. Null point array implies empty. Null dimensionality
* implies no specified dimensionality in the WKT.
*/
LWGEOM* wkt_parser_point_new(POINTARRAY *pa, char *dimensionality)
{
uint8_t flags = wkt_dimensionality(dimensionality);
LWDEBUG(4,"entered");
/* No pointarray means it is empty */
if( ! pa )
return lwpoint_as_lwgeom(lwpoint_construct_empty(SRID_UNKNOWN, FLAGS_GET_Z(flags), FLAGS_GET_M(flags)));
/* If the number of dimensions is not consistent, we have a problem. */
if( wkt_pointarray_dimensionality(pa, flags) == LW_FALSE )
{
ptarray_free(pa);
SET_PARSER_ERROR(PARSER_ERROR_MIXDIMS);
return NULL;
}
/* Only one point allowed in our point array! */
if( pa->npoints != 1 )
{
ptarray_free(pa);
SET_PARSER_ERROR(PARSER_ERROR_LESSPOINTS);
return NULL;
}
return lwpoint_as_lwgeom(lwpoint_construct(SRID_UNKNOWN, NULL, pa));
}
示例10: wkt_parser_polygon_finalize
LWGEOM* wkt_parser_polygon_finalize(LWGEOM *poly, char *dimensionality)
{
uint8_t flags = wkt_dimensionality(dimensionality);
int flagdims = FLAGS_NDIMS(flags);
LWDEBUG(4,"entered");
/* Null input implies empty return */
if( ! poly )
return lwpoly_as_lwgeom(lwpoly_construct_empty(SRID_UNKNOWN, FLAGS_GET_Z(flags), FLAGS_GET_M(flags)));
/* If the number of dimensions are not consistent, we have a problem. */
if( flagdims > 2 )
{
if ( flagdims != FLAGS_NDIMS(poly->flags) )
{
lwgeom_free(poly);
SET_PARSER_ERROR(PARSER_ERROR_MIXDIMS);
return NULL;
}
/* Harmonize the flags in the sub-components with the wkt flags */
if( LW_FAILURE == wkt_parser_set_dims(poly, flags) )
{
lwgeom_free(poly);
SET_PARSER_ERROR(PARSER_ERROR_OTHER);
return NULL;
}
}
return poly;
}
示例11: wkt_pointarray_dimensionality
/**
* Read the dimensionality from a flag, if provided. Then check that the
* dimensionality matches that of the pointarray. If the dimension counts
* match, ensure the pointarray is using the right "Z" or "M".
*/
static int wkt_pointarray_dimensionality(POINTARRAY *pa, uint8_t flags)
{
int hasz = FLAGS_GET_Z(flags);
int hasm = FLAGS_GET_M(flags);
int ndims = 2 + hasz + hasm;
/* No dimensionality or array means we go with what we have */
if( ! (flags && pa) )
return LW_TRUE;
LWDEBUGF(5,"dimensionality ndims == %d", ndims);
LWDEBUGF(5,"FLAGS_NDIMS(pa->flags) == %d", FLAGS_NDIMS(pa->flags));
/*
* ndims > 2 implies that the flags have something useful to add,
* that there is a 'Z' or an 'M' or both.
*/
if( ndims > 2 )
{
/* Mismatch implies a problem */
if ( FLAGS_NDIMS(pa->flags) != ndims )
return LW_FALSE;
/* Match means use the explicit dimensionality */
else
{
FLAGS_SET_Z(pa->flags, hasz);
FLAGS_SET_M(pa->flags, hasm);
}
}
return LW_TRUE;
}
示例12: ptarray_append_point
int
ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int repeated_points)
{
/* Check for pathology */
if( ! pa || ! pt )
{
lwerror("ptarray_append_point: null input");
return LW_FAILURE;
}
/* Check for duplicate end point */
if ( repeated_points == LW_FALSE && pa->npoints > 0 )
{
POINT4D tmp;
getPoint4d_p(pa, pa->npoints-1, &tmp);
LWDEBUGF(4,"checking for duplicate end point (pt = POINT(%g %g) pa->npoints-q = POINT(%g %g))",pt->x,pt->y,tmp.x,tmp.y);
/* Return LW_SUCCESS and do nothing else if previous point in list is equal to this one */
if ( (pt->x == tmp.x) && (pt->y == tmp.y) &&
(FLAGS_GET_Z(pa->flags) ? pt->z == tmp.z : 1) &&
(FLAGS_GET_M(pa->flags) ? pt->m == tmp.m : 1) )
{
return LW_SUCCESS;
}
}
/* Append is just a special case of insert */
return ptarray_insert_point(pa, pt, pa->npoints);
}
示例13: gbox_is_valid
int gbox_is_valid(const GBOX *gbox)
{
/* X */
if ( ! isfinite(gbox->xmin) || isnan(gbox->xmin) ||
! isfinite(gbox->xmax) || isnan(gbox->xmax) )
return LW_FALSE;
/* Y */
if ( ! isfinite(gbox->ymin) || isnan(gbox->ymin) ||
! isfinite(gbox->ymax) || isnan(gbox->ymax) )
return LW_FALSE;
/* Z */
if ( FLAGS_GET_GEODETIC(gbox->flags) || FLAGS_GET_Z(gbox->flags) )
{
if ( ! isfinite(gbox->zmin) || isnan(gbox->zmin) ||
! isfinite(gbox->zmax) || isnan(gbox->zmax) )
return LW_FALSE;
}
/* M */
if ( FLAGS_GET_M(gbox->flags) )
{
if ( ! isfinite(gbox->mmin) || isnan(gbox->mmin) ||
! isfinite(gbox->mmax) || isnan(gbox->mmax) )
return LW_FALSE;
}
return LW_TRUE;
}
示例14: gbox_merge
int gbox_merge(const GBOX *new_box, GBOX *merge_box)
{
assert(merge_box);
if ( FLAGS_GET_ZM(merge_box->flags) != FLAGS_GET_ZM(new_box->flags) )
return LW_FAILURE;
if ( new_box->xmin < merge_box->xmin) merge_box->xmin = new_box->xmin;
if ( new_box->ymin < merge_box->ymin) merge_box->ymin = new_box->ymin;
if ( new_box->xmax > merge_box->xmax) merge_box->xmax = new_box->xmax;
if ( new_box->ymax > merge_box->ymax) merge_box->ymax = new_box->ymax;
if ( FLAGS_GET_Z(merge_box->flags) || FLAGS_GET_GEODETIC(merge_box->flags) )
{
if ( new_box->zmin < merge_box->zmin) merge_box->zmin = new_box->zmin;
if ( new_box->zmax > merge_box->zmax) merge_box->zmax = new_box->zmax;
}
if ( FLAGS_GET_M(merge_box->flags) )
{
if ( new_box->mmin < merge_box->mmin) merge_box->mmin = new_box->mmin;
if ( new_box->mmax > merge_box->mmax) merge_box->mmax = new_box->mmax;
}
return LW_SUCCESS;
}
示例15: wkt_parser_linestring_new
/**
* Create a new linestring. Null point array implies empty. Null dimensionality
* implies no specified dimensionality in the WKT. Check for numpoints >= 2 if
* requested.
*/
LWGEOM* wkt_parser_linestring_new(POINTARRAY *pa, char *dimensionality)
{
uint8_t flags = wkt_dimensionality(dimensionality);
LWDEBUG(4,"entered");
/* No pointarray means it is empty */
if( ! pa )
return lwline_as_lwgeom(lwline_construct_empty(SRID_UNKNOWN, FLAGS_GET_Z(flags), FLAGS_GET_M(flags)));
/* If the number of dimensions is not consistent, we have a problem. */
if( wkt_pointarray_dimensionality(pa, flags) == LW_FALSE )
{
ptarray_free(pa);
SET_PARSER_ERROR(PARSER_ERROR_MIXDIMS);
return NULL;
}
/* Apply check for not enough points, if requested. */
if( (global_parser_result.parser_check_flags & LW_PARSER_CHECK_MINPOINTS) && (pa->npoints < 2) )
{
ptarray_free(pa);
SET_PARSER_ERROR(PARSER_ERROR_MOREPOINTS);
return NULL;
}
return lwline_as_lwgeom(lwline_construct(SRID_UNKNOWN, NULL, pa));
}