PostGIS 3.0.6dev-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 2866 of file lwgeom_topo.c.

2868{
2869 int i;
2870 POINT2D p1;
2871
2872 /* Get starting ring point */
2873 getPoint2d_p(ring, from, &p1);
2874
2875 LWDEBUGF(1, "Ring's 'from' point (%d) is %g,%g", from, p1.x, p1.y);
2876
2877 /* find the edges defining the next portion of ring starting from
2878 * vertex "from" */
2879 for ( i=0; i<numedges; ++i )
2880 {
2881 const LWT_ISO_EDGE *isoe = &(edges[i]);
2882 LWLINE *edge = isoe->geom;
2883 POINTARRAY *epa = edge->points;
2884 POINT2D p2, pt;
2885 int match = 0;
2886 uint32_t j;
2887
2888 /* Skip if the edge is a dangling one */
2889 if ( isoe->face_left == isoe->face_right )
2890 {
2891 LWDEBUGF(3, "_lwt_FindNextRingEdge: edge %" LWTFMT_ELEMID
2892 " has same face (%" LWTFMT_ELEMID
2893 ") on both sides, skipping",
2894 isoe->edge_id, isoe->face_left);
2895 continue;
2896 }
2897
2898 if (epa->npoints < 2)
2899 {
2900 LWDEBUGF(3, "_lwt_FindNextRingEdge: edge %" LWTFMT_ELEMID
2901 " has only %"PRIu32" points",
2902 isoe->edge_id, epa->npoints);
2903 continue;
2904 }
2905
2906#if 0
2907 size_t sz;
2908 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " is %s",
2909 isoe->edge_id,
2911#endif
2912
2913 /* ptarray_remove_repeated_points ? */
2914
2915 getPoint2d_p(epa, 0, &p2);
2916 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'first' point is %g,%g",
2917 isoe->edge_id, p2.x, p2.y);
2918 LWDEBUGF(1, "Rings's 'from' point is still %g,%g", p1.x, p1.y);
2919 if ( p2d_same(&p1, &p2) )
2920 {
2921 LWDEBUG(1, "p2d_same(p1,p2) returned true");
2922 LWDEBUGF(1, "First point of edge %" LWTFMT_ELEMID
2923 " matches ring vertex %d", isoe->edge_id, from);
2924 /* first point matches, let's check next non-equal one */
2925 for ( j=1; j<epa->npoints; ++j )
2926 {
2927 getPoint2d_p(epa, j, &p2);
2928 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'next' point %d is %g,%g",
2929 isoe->edge_id, j, p2.x, p2.y);
2930 /* we won't check duplicated edge points */
2931 if ( p2d_same(&p1, &p2) ) continue;
2932 /* we assume there are no duplicated points in ring */
2933 getPoint2d_p(ring, from+1, &pt);
2934 LWDEBUGF(1, "Ring's point %d is %g,%g",
2935 from+1, pt.x, pt.y);
2936 match = p2d_same(&pt, &p2);
2937 break; /* we want to check a single non-equal next vertex */
2938 }
2939#if POSTGIS_DEBUG_LEVEL > 0
2940 if ( match ) {
2941 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
2942 " matches ring vertex %d", isoe->edge_id, from+1);
2943 } else {
2944 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
2945 " does not match ring vertex %d", isoe->edge_id, from+1);
2946 }
2947#endif
2948 }
2949
2950 if ( ! match )
2951 {
2952 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " did not match as forward",
2953 isoe->edge_id);
2954 getPoint2d_p(epa, epa->npoints-1, &p2);
2955 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'last' point is %g,%g",
2956 isoe->edge_id, p2.x, p2.y);
2957 if ( p2d_same(&p1, &p2) )
2958 {
2959 LWDEBUGF(1, "Last point of edge %" LWTFMT_ELEMID
2960 " matches ring vertex %d", isoe->edge_id, from);
2961 /* last point matches, let's check next non-equal one */
2962 for ( j=2; j<=epa->npoints; j++ )
2963 {
2964 getPoint2d_p(epa, epa->npoints - j, &p2);
2965 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'prev' point %d is %g,%g",
2966 isoe->edge_id, epa->npoints - j, p2.x, p2.y);
2967 /* we won't check duplicated edge points */
2968 if ( p2d_same(&p1, &p2) ) continue;
2969 /* we assume there are no duplicated points in ring */
2970 getPoint2d_p(ring, from+1, &pt);
2971 LWDEBUGF(1, "Ring's point %d is %g,%g",
2972 from+1, pt.x, pt.y);
2973 match = p2d_same(&pt, &p2);
2974 break; /* we want to check a single non-equal next vertex */
2975 }
2976 }
2977#if POSTGIS_DEBUG_LEVEL > 0
2978 if ( match ) {
2979 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
2980 " matches ring vertex %d", isoe->edge_id, from+1);
2981 } else {
2982 LWDEBUGF(1, "Prev point of edge %" LWTFMT_ELEMID
2983 " does not match ring vertex %d", isoe->edge_id, from+1);
2984 }
2985#endif
2986 }
2987
2988 if ( match ) return i;
2989
2990 }
2991
2992 return -1;
2993}
#define WKT_EXTENDED
Definition liblwgeom.h:2132
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition lwout_wkt.c:676
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:349
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition lwgeom.c:321
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition lwalgorithm.c:50
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:88
#define LWTFMT_ELEMID
Definition lwgeom_topo.c:43
POINTARRAY * points
Definition liblwgeom.h:469
LWT_ELEMID face_right
LWT_ELEMID face_left
LWT_ELEMID edge_id
double y
Definition liblwgeom.h:376
double x
Definition liblwgeom.h:376
uint32_t npoints
Definition liblwgeom.h:413

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(), 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: