PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _lwt_FindNextRingEdge()

static int _lwt_FindNextRingEdge ( const POINTARRAY ring,
int  from,
const LWT_ISO_EDGE edges,
int  numedges 
)
static

Definition at line 3053 of file lwgeom_topo.c.

3055{
3056 int i;
3057 POINT2D p1;
3058
3059 /* Get starting ring point */
3060 getPoint2d_p(ring, from, &p1);
3061
3062 LWDEBUGF(1, "Ring's 'from' point (%d) is %g,%g", from, p1.x, p1.y);
3063
3064 /* find the edges defining the next portion of ring starting from
3065 * vertex "from" */
3066 for ( i=0; i<numedges; ++i )
3067 {
3068 const LWT_ISO_EDGE *isoe = &(edges[i]);
3069 LWLINE *edge = isoe->geom;
3070 POINTARRAY *epa = edge->points;
3071 POINT2D p2, pt;
3072 int match = 0;
3073 uint32_t j;
3074
3075 /* Skip if the edge is a dangling one */
3076 if ( isoe->face_left == isoe->face_right )
3077 {
3078 LWDEBUGF(3, "_lwt_FindNextRingEdge: edge %" LWTFMT_ELEMID
3079 " has same face (%" LWTFMT_ELEMID
3080 ") on both sides, skipping",
3081 isoe->edge_id, isoe->face_left);
3082 continue;
3083 }
3084
3085 if (epa->npoints < 2)
3086 {
3087 LWDEBUGF(3, "_lwt_FindNextRingEdge: edge %" LWTFMT_ELEMID
3088 " has only %"PRIu32" points",
3089 isoe->edge_id, epa->npoints);
3090 continue;
3091 }
3092
3093#if 0
3094 size_t sz;
3095 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " is %s",
3096 isoe->edge_id,
3098#endif
3099
3100 /* ptarray_remove_repeated_points ? */
3101
3102 getPoint2d_p(epa, 0, &p2);
3103 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'first' point is %g,%g",
3104 isoe->edge_id, p2.x, p2.y);
3105 LWDEBUGF(1, "Rings's 'from' point is still %g,%g", p1.x, p1.y);
3106 if ( P2D_SAME_STRICT(&p1, &p2) )
3107 {
3108 LWDEBUG(1, "P2D_SAME_STRICT(p1,p2) returned true");
3109 LWDEBUGF(1, "First point of edge %" LWTFMT_ELEMID
3110 " matches ring vertex %d", isoe->edge_id, from);
3111 /* first point matches, let's check next non-equal one */
3112 for ( j=1; j<epa->npoints; ++j )
3113 {
3114 getPoint2d_p(epa, j, &p2);
3115 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'next' point %d is %g,%g",
3116 isoe->edge_id, j, p2.x, p2.y);
3117 /* we won't check duplicated edge points */
3118 if ( P2D_SAME_STRICT(&p1, &p2) ) continue;
3119 /* we assume there are no duplicated points in ring */
3120 getPoint2d_p(ring, from+1, &pt);
3121 LWDEBUGF(1, "Ring's point %d is %g,%g",
3122 from+1, pt.x, pt.y);
3123 match = P2D_SAME_STRICT(&pt, &p2);
3124 break; /* we want to check a single non-equal next vertex */
3125 }
3126#if POSTGIS_DEBUG_LEVEL > 0
3127 if ( match ) {
3128 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
3129 " matches ring vertex %d", isoe->edge_id, from+1);
3130 } else {
3131 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
3132 " does not match ring vertex %d", isoe->edge_id, from+1);
3133 }
3134#endif
3135 }
3136
3137 if ( ! match )
3138 {
3139 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " did not match as forward",
3140 isoe->edge_id);
3141 getPoint2d_p(epa, epa->npoints-1, &p2);
3142 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'last' point is %g,%g",
3143 isoe->edge_id, p2.x, p2.y);
3144 if ( P2D_SAME_STRICT(&p1, &p2) )
3145 {
3146 LWDEBUGF(1, "Last point of edge %" LWTFMT_ELEMID
3147 " matches ring vertex %d", isoe->edge_id, from);
3148 /* last point matches, let's check next non-equal one */
3149 for ( j=2; j<=epa->npoints; j++ )
3150 {
3151 getPoint2d_p(epa, epa->npoints - j, &p2);
3152 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'prev' point %d is %g,%g",
3153 isoe->edge_id, epa->npoints - j, p2.x, p2.y);
3154 /* we won't check duplicated edge points */
3155 if ( P2D_SAME_STRICT(&p1, &p2) ) continue;
3156 /* we assume there are no duplicated points in ring */
3157 getPoint2d_p(ring, from+1, &pt);
3158 LWDEBUGF(1, "Ring's point %d is %g,%g",
3159 from+1, pt.x, pt.y);
3160 match = P2D_SAME_STRICT(&pt, &p2);
3161 break; /* we want to check a single non-equal next vertex */
3162 }
3163 }
3164#if POSTGIS_DEBUG_LEVEL > 0
3165 if ( match ) {
3166 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
3167 " matches ring vertex %d", isoe->edge_id, from+1);
3168 } else {
3169 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
3170 " does not match ring vertex %d", isoe->edge_id, from+1);
3171 }
3172#endif
3173 }
3174
3175 if ( match ) return i;
3176
3177 }
3178
3179 return -1;
3180}
#define WKT_EXTENDED
Definition liblwgeom.h:2221
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition lwout_wkt.c:708
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:342
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition lwgeom.c:367
#define P2D_SAME_STRICT(a, b)
#define LWTFMT_ELEMID
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
POINTARRAY * points
Definition liblwgeom.h:483
LWT_ELEMID face_right
LWT_ELEMID face_left
LWT_ELEMID edge_id
double y
Definition liblwgeom.h:390
double x
Definition liblwgeom.h:390
uint32_t npoints
Definition liblwgeom.h:427

References LWT_ISO_EDGE::edge_id, LWT_ISO_EDGE::face_left, LWT_ISO_EDGE::face_right, LWT_ISO_EDGE::geom, getPoint2d_p(), LWDEBUG, LWDEBUGF, lwgeom_to_wkt(), lwline_as_lwgeom(), LWTFMT_ELEMID, POINTARRAY::npoints, P2D_SAME_STRICT, LWLINE::points, WKT_EXTENDED, POINT2D::x, and POINT2D::y.

Referenced by lwt_GetFaceEdges().

Here is the call graph for this function:
Here is the caller graph for this function: