[geos-devel] gprof (missing attachment)

Norman Vine nhv at cape.com
Sun Feb 6 07:02:05 EST 2005


If this is actually a hotspot probably best to take advantage
of all the apriori knowledge we can :-)

< I think this is correct some one should check my logic though >

bool Envelope::intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2)
{
/* please leave this commented code as documentation 
    if( min(p1.x,p2.x) > max(q1.x,q2.x) ||
          max(p1.x,p2.x) < min(q1.x,q2.x) ||
          min(p1.y,p2.y) > max(q1.y,q2.y) ||
          max(p1.y,p2.y) < min(q1.y,q2.y) )
        return false;
    return true;
*/

    if( p1.x < p2.x )  {
        if( q1.x > q2.x )  {
            if( p1.x > q1.x )  return false;
            if( p2.x < q2.x )  return false;
        } else {
            if( p1.x > q2.x )  return false;
            if( p2.x < q1.x )  return false;
        }
    } else {
        if( q1.x > q2.x )  {
            if( p2.x > q1.x )  return false;
            if( p1.x < q2.x )  return false;
        } else {
            if( p2.x > q2.x )  return false;
            if( p1.x < q1.x )  return false;
        }
    }

    if( p1.y < p2.y ) {
        if( q1.y > q2.y )  {
            if( p1.y > q1.y )  return false;
            if( p2.y < q2.y )  return false;
        } else {
            if( p1.y > q2.y )  return false;
            if( p2.y < q1.y )  return false;
        }
    } else {
        if( q1.y > q2.y ) {
            if( p2.y > q1.y )  return false;
            if( p1.y < q2.y )  return false;
        } else {
            if( p2.y > q2.y )  return false;
            if( p1.y < q1.y )  return false;
        }
    }
    return true;
}




More information about the geos-devel mailing list