PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ SHPRewindIsInnerRing()

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

Definition at line 2689 of file shpopen.c.

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