Return the list of directed edges bounding a face.
3093{
3097 uint64_t numfaceedges;
3098 int fields;
3099 uint32_t i;
3100 int nseid = 0;
3101 int prevseid;
3103
3104
3105 numfaceedges = 1;
3110 ;
3112 if (numfaceedges == UINT64_MAX)
3113 {
3115 return -1;
3116 }
3117 if ( ! numfaceedges ) return 0;
3118 LWDEBUGF(1,
"lwt_GetFaceEdges: lwt_be_getEdgeByFace returned %llu edges", numfaceedges);
3119
3120
3121
3123 if ( ! face )
3124 {
3125
3127 lwerror(
"Corrupted topology: unable to build geometry of face %"
3128 LWTFMT_ELEMID " from its %"PRIu64
" edges", face_id, numfaceedges);
3129 return -1;
3130 }
3131
3133 {
3134
3137 return 0;
3138 }
3139
3140
3141
3142
3144
3145#if 0
3146 {
3147 size_t sz;
3150 face_id, wkt);
3152 }
3153#endif
3154
3156 if ( ! facepoly )
3157 {
3161 return -1;
3162 }
3163
3164 nseid = prevseid = 0;
3166
3167
3168 for ( i=0; i<facepoly->
nrings; ++i )
3169 {
3171 int32_t j = 0;
3174
3176
3177 while ( j < (int32_t) ring->
npoints-1 )
3178 {
3179 LWDEBUGF(1,
"Looking for edge covering ring %d from vertex %d",
3180 i, j);
3181
3183 if ( edgeno == -1 )
3184 {
3185
3189 lwerror(
"No edge (among %" PRIu64
") found to be defining geometry of face %"
3191 return -1;
3192 }
3193
3194 nextedge = &(edges[edgeno]);
3195 nextline = nextedge->
geom;
3196
3198 " covers ring %d from vertex %d to %d",
3200
3201#if 0
3202 {
3203 size_t sz;
3208 }
3209#endif
3210
3212
3213
3214 seid[nseid++] = nextedge->
face_left == face_id ?
3217
3218
3220 }
3221
3222
3223
3224
3225 if ( (nseid - prevseid) > 1 )
3226 {{
3228 int minidx = 0;
3229 LWDEBUGF(1,
"Looking for smallest id among the %d edges "
3230 "composing ring %d", (nseid-prevseid), i);
3231 for ( j=prevseid; j<nseid; ++j )
3232 {
3235 if ( ! minid || id < minid )
3236 {
3237 minid = id;
3238 minidx = j;
3239 }
3240 }
3242 " at position %d", minid, minidx);
3243 if ( minidx != prevseid )
3244 {
3246 }
3247 }}
3248
3249 prevseid = nseid;
3250 }
3251
3254
3255 *out = seid;
3256 return nseid;
3257}
void lwgeom_free(LWGEOM *geom)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
void * lwalloc(size_t size)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
void lwgeom_reverse_in_place(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
#define LWT_COL_EDGE_FACE_RIGHT
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_FACE_LEFT
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_EDGE_GEOM
#define PGTOPO_BE_ERROR()
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int _lwt_FindNextRingEdge(const POINTARRAY *ring, int from, const LWT_ISO_EDGE *edges, int numedges)
static void _lwt_RotateElemidArray(LWT_ELEMID *ary, int from, int to, int rotidx)
static LWT_ISO_EDGE * lwt_be_getEdgeByFace(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields, const GBOX *box)
void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
static LWGEOM * _lwt_FaceByEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edges, int numfaceedges)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)