]> granicus.if.org Git - postgis/commitdiff
Applyed "Mark Cave-Ayland" <mark.cave-ayland@webbased.co.uk>'s patch
authorDavid Blasby <dblasby@gmail.com>
Fri, 16 Aug 2002 17:58:44 +0000 (17:58 +0000)
committerDavid Blasby <dblasby@gmail.com>
Fri, 16 Aug 2002 17:58:44 +0000 (17:58 +0000)
 to the truly_inside() function.  Thanks mark!

git-svn-id: http://svn.osgeo.org/postgis/trunk@179 b70326c6-7e19-0410-871a-916f4a2858ee

postgis_fn.c

index 6d45f0a6bd388756618860529a6854cd39fedb69..7621f2c5971d7e0547b35c57fa68f077e84a173e 100644 (file)
@@ -517,7 +517,7 @@ bool lineseg_inside_box( POINT3D *P1, POINT3D *P2, BOX3D *box)
        // know that its a diagonal line
 
        //this is the tough case - it may or maynot intersect the box
-       //see if it intersects the horizonal box lines
+       //see if it intersects the horizonal and vertical box lines
 
        // from comp.graphics.algo's faq:
        /*
@@ -560,6 +560,32 @@ bool lineseg_inside_box( POINT3D *P1, POINT3D *P2, BOX3D *box)
        if  ( (r>=0) && (r<=1) && (s>=0) && (s<=1)    )
                return TRUE;
 
+       //left ver part of box
+       Cx = box->LLB.x; Cy= box->LLB.y;
+       Dx = box->LLB.x; Dy= box->URT.y;
+
+               r= ((Ay-Cy)*(Dx-Cx)-(Ax-Cx)*(Dy-Cy) )/
+                       ((Bx-Ax)*(Dy-Cy)-(By-Ay)*(Dx-Cx) ) ;
+
+               s=  ((Ay-Cy)*(Bx-Ax)-(Ax-Cx)*(By-Ay))/
+                       ((Bx-Ax)*(Dy-Cy)-(By-Ay)*(Dx-Cx) ) ;
+
+       if  ( (r>=0) && (r<=1) && (s>=0) && (s<=1)    )
+               return TRUE;
+
+       //right ver part of box
+       Cx = box->URT.x; Cy= box->LLB.y;
+       Dx = box->URT.x; Dy= box->URT.y;
+
+               r= ((Ay-Cy)*(Dx-Cx)-(Ax-Cx)*(Dy-Cy) )/
+                       ((Bx-Ax)*(Dy-Cy)-(By-Ay)*(Dx-Cx) ) ;
+
+               s=  ((Ay-Cy)*(Bx-Ax)-(Ax-Cx)*(By-Ay))/
+                       ((Bx-Ax)*(Dy-Cy)-(By-Ay)*(Dx-Cx) ) ;
+       if  ( (r>=0) && (r<=1) && (s>=0) && (s<=1)    )
+               return TRUE;
+
+       //otherwise we did not intersect the box
        return FALSE;
        
 }