7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.38 1998/10/26 01:01:33 tgl Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.39 1998/10/29 18:11:28 thomas Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -2733,18 +2733,6 @@ on_pb(Point *pt, BOX *box)
2733
2733
bool
2734
2734
on_ppath (Point * pt , PATH * path )
2735
2735
{
2736
- #if FALSE
2737
- int above ,
2738
- next , /* is the seg above the ray? */
2739
- inter , /* # of times path crosses ray */
2740
- hi ; /* index inc of higher seg (0,1) */
2741
- double x ,
2742
- yh ,
2743
- yl ,
2744
- xh ,
2745
- xl ;
2746
-
2747
- #endif
2748
2736
int i ,
2749
2737
n ;
2750
2738
double a ,
@@ -2753,8 +2741,9 @@ on_ppath(Point *pt, PATH *path)
2753
2741
if (!PointerIsValid (pt ) || !PointerIsValid (path ))
2754
2742
return FALSE;
2755
2743
2744
+ /*-- OPEN --*/
2756
2745
if (!path -> closed )
2757
- { /*-- OPEN --*/
2746
+ {
2758
2747
n = path -> npts - 1 ;
2759
2748
a = point_dt (pt , & path -> p [0 ]);
2760
2749
for (i = 0 ; i < n ; i ++ )
@@ -2768,58 +2757,8 @@ on_ppath(Point *pt, PATH *path)
2768
2757
return FALSE;
2769
2758
}
2770
2759
2760
+ /*-- CLOSED --*/
2771
2761
return point_inside (pt , path -> npts , path -> p );
2772
- #if FALSE
2773
- inter = 0 ; /*-- CLOSED --*/
2774
- above = FPgt (path -> p [0 ].y , pt -> y ) ? ABOVE :
2775
- FPlt (path -> p [0 ].y , pt -> y ) ? BELOW : UNDEF ;
2776
-
2777
- for (i = 0 ; i < path -> npts ; i ++ )
2778
- {
2779
- hi = path -> p [i ].y < path -> p [NEXT (i )].y ;
2780
-
2781
- /*
2782
- * must take care of wrap around to original vertex for closed
2783
- * paths
2784
- */
2785
- yh = (i + hi < path -> npts ) ? path -> p [i + hi ].y : path -> p [0 ].y ;
2786
- yl = (i + !hi < path -> npts ) ? path -> p [i + !hi ].y : path -> p [0 ].y ;
2787
- hi = path -> p [i ].x < path -> p [NEXT (i )].x ;
2788
- xh = (i + hi < path -> npts ) ? path -> p [i + hi ].x : path -> p [0 ].x ;
2789
- xl = (i + !hi < path -> npts ) ? path -> p [i + !hi ].x : path -> p [0 ].x ;
2790
- /* skip seg if it doesn't touch the ray */
2791
-
2792
- if (FPeq (yh , yl )) /* horizontal seg? */
2793
- if (FPge (pt -> x , xl ) && FPle (pt -> x , xh ) &&
2794
- FPeq (pt -> y , yh ))
2795
- return TRUE; /* pt lies on seg */
2796
- else
2797
- continue ; /* skip other hz segs */
2798
- if (FPlt (yh , pt -> y ) || /* pt is strictly below seg */
2799
- FPgt (yl , pt -> y )) /* strictly above */
2800
- continue ;
2801
-
2802
- /* seg touches the ray, find out where */
2803
-
2804
- x = FPeq (xh , xl ) /* vertical seg? */
2805
- ? path -> p [i ].x
2806
- : (pt -> y - path -> p [i ].y ) /
2807
- point_sl (& path -> p [i ],
2808
- & path -> p [NEXT (i )]) +
2809
- path -> p [i ].x ;
2810
- if (FPeq (x , pt -> x )) /* pt lies on this seg */
2811
- return TRUE;
2812
-
2813
- /* does the seg actually cross the ray? */
2814
-
2815
- next = FPgt (path -> p [NEXT (i )].y , pt -> y ) ? ABOVE :
2816
- FPlt (path -> p [NEXT (i )].y , pt -> y ) ? BELOW : above ;
2817
- inter += FPge (x , pt -> x ) && next != above ;
2818
- above = next ;
2819
- }
2820
- return (above == UNDEF || /* path is horizontal */
2821
- inter % 2 ); /* odd # of intersections */
2822
- #endif
2823
2762
} /* on_ppath() */
2824
2763
2825
2764
@@ -3577,9 +3516,13 @@ path_contain_pt(PATH *path, Point *p)
3577
3516
if (!PointerIsValid (path ) || !PointerIsValid (p ))
3578
3517
return FALSE;
3579
3518
3580
- return (path -> closed ? ( point_inside ( p , path -> npts , & ( path -> p [ 0 ])) != 0 ) : FALSE );
3519
+ return (on_ppath ( p , path ) );
3581
3520
} /* path_contain_pt() */
3582
3521
3522
+ /* pt_contained_path
3523
+ * Point in or on path? This is the same as on_ppath.
3524
+ * - thomas 1998-10-29
3525
+ */
3583
3526
bool
3584
3527
pt_contained_path (Point * p , PATH * path )
3585
3528
{
0 commit comments