1 /**********************************************************************
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
14 **********************************************************************/
17 #include <geos/geom/Geometry.h>
18 #include <geos/geom/Polygon.h>
19 #include <geos/geom/MultiPolygon.h>
20 #include <geos/geom/prep/PreparedPolygon.h>
21 #include <geos/geom/prep/PreparedPolygonContainsProperly.h>
22 #include <geos/geom/prep/PreparedPolygonPredicate.h>
23 #include <geos/noding/SegmentString.h>
24 #include <geos/noding/SegmentStringUtil.h>
25 #include <geos/noding/FastSegmentSetIntersectionFinder.h>
28 namespace geom
{ // geos.geom
29 namespace prep
{ // geos.geom.prep
42 PreparedPolygonContainsProperly::containsProperly( const geom::Geometry
* geom
)
44 // Do point-in-poly tests first, since they are cheaper and may result
45 // in a quick negative result.
46 // If a point of any test components does not lie in target, result is false
47 bool isAllInPrepGeomArea
= isAllTestComponentsInTargetInterior( geom
);
48 if ( !isAllInPrepGeomArea
)
51 // If any segments intersect, result is false
52 noding::SegmentString::ConstVect lineSegStr
;
53 noding::SegmentStringUtil::extractSegmentStrings( geom
, lineSegStr
);
54 bool segsIntersect
= prepPoly
->getIntersectionFinder()->intersects( &lineSegStr
);
56 for ( size_t i
= 0, ni
= lineSegStr
.size(); i
< ni
; i
++ ) {
57 delete lineSegStr
[ i
];
58 delete lineSegStr
[ i
]->getCoordinates();
64 if ( geom
->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
65 || geom
->getGeometryTypeId() == geos::geom::GEOS_POLYGON
)
67 // TODO: generalize this to handle GeometryCollections
68 bool isTargetGeomInTestArea
= isAnyTargetComponentInTestArea( geom
, prepPoly
->getRepresentativePoints());
69 if (isTargetGeomInTestArea
)
76 } // namespace geos.geom.prep
77 } // namespace geos.geom
80 /**********************************************************************
83 **********************************************************************/