41
43
PointBuilder::build(int opCode)
43
vector<Node*>* nodeList=collectNodes(opCode);
44
vector<Point*>* resultPointList=simplifyPoints(nodeList);
45
extractNonCoveredResultNodes(opCode);
46
46
return resultPointList;
50
PointBuilder::collectNodes(int opCode)
52
vector<Node*>* resultNodeList=new vector<Node*>();
53
// add nodes from edge intersections which have not already been
54
// included in the result
55
map<Coordinate,Node*,CoordLT> *nodeMap=op->getGraph()->getNodeMap()->nodeMap;
56
map<Coordinate,Node*,CoordLT>::iterator it=nodeMap->begin();
57
for (;it!=nodeMap->end();it++) {
58
Node *node=it->second;
59
if (!node->isInResult()) {
60
Label *label=node->getLabel();
61
if (OverlayOp::isResultOfOp(label,opCode)) {
62
resultNodeList->push_back(node);
66
return resultNodeList;
70
* This method simplifies the resultant Geometry by finding and eliminating
72
* A point is covered if it is contained in another element Geometry
73
* with higher dimension (e.g. a point might be contained in a polygon,
74
* in which case the point can be eliminated from the resultant).
50
* Determines nodes which are in the result, and creates Point for them.
52
* This method determines nodes which are candidates for the result via their
53
* labelling and their graph topology.
55
* @param opCode the overlay operation
77
PointBuilder::simplifyPoints(vector<Node*> *resultNodeList)
58
PointBuilder::extractNonCoveredResultNodes(int opCode)
79
vector<Point*>* nonCoveredPointList=new vector<Point*>();
80
for(int i=0;i<(int)resultNodeList->size();i++)
60
map<Coordinate,Node*,CoordLT> *nodeMap =
61
op->getGraph()->getNodeMap()->nodeMap;
62
map<Coordinate,Node*,CoordLT>::iterator it=nodeMap->begin();
63
for (; it!=nodeMap->end(); ++it)
82
Node *n=(*resultNodeList)[i];
83
const Coordinate& coord=n->getCoordinate();
84
if(!op->isCoveredByLA(coord)) {
85
Point *pt=geometryFactory->createPoint(coord);
86
nonCoveredPointList->push_back(pt);
67
// filter out nodes which are known to be in the result
68
if (n->isInResult()) continue;
70
// if an incident edge is in the result, then
71
// the node coordinate is included already
72
if (n->isIncidentEdgeInResult()) continue;
74
if ( n->getEdges()->getDegree() == 0 ||
75
opCode == OverlayOp::INTERSECTION )
79
* For nodes on edges, only INTERSECTION can result
80
* in edge nodes being included even
81
* if none of their incident edges are included
83
Label *label=n->getLabel();
84
if (OverlayOp::isResultOfOp(label,opCode))
85
filterCoveredNodeToPoint(n);
89
return nonCoveredPointList;
91
PointBuilder::filterCoveredNodeToPoint(const Node *n)
93
const Coordinate& coord=n->getCoordinate();
94
if(!op->isCoveredByLA(coord)) {
95
Point *pt=geometryFactory->createPoint(coord);
96
resultPointList->push_back(pt);
92
100
} // namespace geos
94
102
/**********************************************************************
95
103
* $Log: PointBuilder.cpp,v $
104
* Revision 1.13.2.2 2005/06/28 01:07:11 strk
105
* improved extraction of result points in overlay op
107
* Revision 1.13.2.1 2005/06/26 09:40:19 strk
108
* Backport of OverlayOp performance improvements
96
110
* Revision 1.13 2004/11/17 15:09:08 strk
97
111
* Changed COMPUTE_Z defaults to be more conservative