PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ SHPRewindIsInnerRing()

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

Definition at line 2687 of file shpopen.c.

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