1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************/
16 #include <geos/noding/SegmentIntersectionDetector.h>
17 #include <geos/noding/SegmentIntersector.h>
18 #include <geos/algorithm/LineIntersector.h>
19 #include <geos/geom/Coordinate.h>
20 #include <geos/geom/CoordinateArraySequence.h>
21 #include <geos/noding/SegmentString.h>
25 namespace noding
{ // geos::noding
30 SegmentIntersectionDetector::
32 noding::SegmentString
* e0
, int segIndex0
,
33 noding::SegmentString
* e1
, int segIndex1
)
35 // don't bother intersecting a segment with itself
36 if (e0
== e1
&& segIndex0
== segIndex1
) return;
38 const geom::Coordinate
& p00
= (*e0
->getCoordinates())[ segIndex0
];
39 const geom::Coordinate
& p01
= (*e0
->getCoordinates())[ segIndex0
+ 1 ];
40 const geom::Coordinate
& p10
= (*e1
->getCoordinates())[ segIndex1
];
41 const geom::Coordinate
& p11
= (*e1
->getCoordinates())[ segIndex1
+ 1 ];
43 li
->computeIntersection( p00
, p01
, p10
, p11
);
45 if (li
->hasIntersection())
47 // record intersection info
48 _hasIntersection
= true;
50 bool isProper
= li
->isProper();
53 _hasProperIntersection
= true;
55 _hasNonProperIntersection
= true;
57 // If this is the kind of intersection we are searching for
58 // OR no location has yet been recorded
59 // save the location data
60 bool saveLocation
= true;
62 if (findProper
&& !isProper
)
65 if (!intPt
|| saveLocation
)
67 // record intersection location (approximate)
68 intPt
= &li
->getIntersection(0);
72 // record intersecting segments
73 intSegments
= new geom::CoordinateArraySequence();
74 intSegments
->add( p00
, true);
75 intSegments
->add( p01
, true);
76 intSegments
->add( p10
, true);
77 intSegments
->add( p11
, true);
86 /**********************************************************************
89 **********************************************************************/