/*private*/ void LineIntersector::intersectionWithNormalization(const Coordinate& p1, const Coordinate& p2, const Coordinate& q1, const Coordinate& q2, Coordinate &intPt) const { Coordinate n1=p1; Coordinate n2=p2; Coordinate n3=q1; Coordinate n4=q2; Coordinate normPt; normalizeToEnvCentre(n1, n2, n3, n4, normPt); safeHCoordinateIntersection(n1, n2, n3, n4, intPt); intPt.x += normPt.x; intPt.y += normPt.y; }
Coordinate* RobustLineIntersector::intersection(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2) const { Coordinate n1=p1; Coordinate n2=p2; Coordinate n3=q1; Coordinate n4=q2; Coordinate normPt; //normalize(&n1, &n2, &n3, &n4, &normPt); normalizeToEnvCentre(n1, n2, n3, n4, normPt); Coordinate *intPt=NULL; #if DEBUG cerr<<"RobustIntersector::intersection(p1,p2,q1,q2) called:"<<endl; cerr<<" p1"<<p1.toString()<<endl; cerr<<" p2"<<p2.toString()<<endl; cerr<<" q1"<<q1.toString()<<endl; cerr<<" q2"<<q2.toString()<<endl; cerr<<" n1"<<n1.toString()<<endl; cerr<<" n2"<<n2.toString()<<endl; cerr<<" n3"<<n3.toString()<<endl; cerr<<" n4"<<n4.toString()<<endl; #endif try { intPt=HCoordinate::intersection(n1,n2,n3,n4); #if DEBUG cerr<<" HCoordinate found intersection h:"<<h->toString()<<endl; #endif } catch (const NotRepresentableException& e) { delete intPt; Assert::shouldNeverReachHere("Coordinate for intersection is not calculable"+e.toString()); } intPt->x+=normPt.x; intPt->y+=normPt.y; /** * * MD - May 4 2005 - This is still a problem. Here is a failure case: * * LINESTRING (2089426.5233462777 1180182.3877339689, * 2085646.6891757075 1195618.7333999649) * LINESTRING (1889281.8148903656 1997547.0560044837, * 2259977.3672235999 483675.17050843034) * int point = (2097408.2633752143,1144595.8008114607) */ #if DEBUG if (! isInSegmentEnvelopes(intPt)) { cerr<<"Intersection outside segment envelopes: "<< intPt->toString(); } #endif if (precisionModel!=NULL) precisionModel->makePrecise(intPt); #if COMPUTE_Z double ztot = 0; double zvals = 0; double zp = interpolateZ(*intPt, p1, p2); double zq = interpolateZ(*intPt, q1, q2); if ( !ISNAN(zp)) { ztot += zp; zvals++; } if ( !ISNAN(zq)) { ztot += zq; zvals++; } if ( zvals ) intPt->z = ztot/zvals; #endif // COMPUTE_Z return intPt; }