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

◆ SHPRewindIsInnerRing()

static int SHPRewindIsInnerRing ( const SHPObject psObject,
int  iOpRing,
double  dfTestX,
double  dfTestY 
)
static

Definition at line 2698 of file shpopen.c.

2701{
2702/* -------------------------------------------------------------------- */
2703/* Determine if this ring is an inner ring or an outer ring */
2704/* relative to all the other rings. For now we assume the */
2705/* first ring is outer and all others are inner, but eventually */
2706/* we need to fix this to handle multiple island polygons and */
2707/* unordered sets of rings. */
2708/* */
2709/* -------------------------------------------------------------------- */
2710
2711 int bInner = FALSE;
2712 int iCheckRing;
2713 for( iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++ )
2714 {
2715 int nVertStartCheck, nVertCountCheck;
2716 int iEdge;
2717
2718 if( iCheckRing == iOpRing )
2719 continue;
2720
2721 nVertStartCheck = psObject->panPartStart[iCheckRing];
2722 nVertCountCheck = SHPGetPartVertexCount(psObject, iCheckRing);
2723
2724 for( iEdge = 0; iEdge < nVertCountCheck; iEdge++ )
2725 {
2726 int iNext;
2727
2728 if( iEdge < nVertCountCheck-1 )
2729 iNext = iEdge+1;
2730 else
2731 iNext = 0;
2732
2733 /* Rule #1:
2734 * Test whether the edge 'straddles' the horizontal ray from
2735 * the test point (dfTestY,dfTestY)
2736 * The rule #1 also excludes edges colinear with the ray.
2737 */
2738 if ( ( psObject->padfY[iEdge+nVertStartCheck] < dfTestY
2739 && dfTestY <= psObject->padfY[iNext+nVertStartCheck] )
2740 || ( psObject->padfY[iNext+nVertStartCheck] < dfTestY
2741 && dfTestY <= psObject->padfY[iEdge+nVertStartCheck] ) )
2742 {
2743 /* Rule #2:
2744 * Test if edge-ray intersection is on the right from the
2745 * test point (dfTestY,dfTestY)
2746 */
2747 double const intersect =
2748 ( psObject->padfX[iEdge+nVertStartCheck]
2749 + ( dfTestY - psObject->padfY[iEdge+nVertStartCheck] )
2750 / ( psObject->padfY[iNext+nVertStartCheck] -
2751 psObject->padfY[iEdge+nVertStartCheck] )
2752 * ( psObject->padfX[iNext+nVertStartCheck] -
2753 psObject->padfX[iEdge+nVertStartCheck] ) );
2754
2755 if (intersect < dfTestX)
2756 {
2757 bInner = !bInner;
2758 }
2759 else if( intersect == dfTestX )
2760 {
2761 /* Potential shared edge */
2762 return -1;
2763 }
2764 }
2765 }
2766 } /* for iCheckRing */
2767 return bInner;
2768}
static int SHPGetPartVertexCount(const SHPObject *psObject, int iPart)
Definition shpopen.c:2685
#define FALSE
Definition shpopen.c:58
double * padfX
Definition shapefil.h:390
double * padfY
Definition shapefil.h:391
int * panPartStart
Definition shapefil.h:386

References FALSE, tagSHPObject::nParts, tagSHPObject::padfX, tagSHPObject::padfY, tagSHPObject::panPartStart, and SHPGetPartVertexCount().

Referenced by SHPRewindObject().

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