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 **********************************************************************
15 * Last port: geomgraph/EdgeList.java rev. 1.4 (JTS-1.10)
17 **********************************************************************/
23 #include <geos/geomgraph/Edge.h>
24 #include <geos/geomgraph/EdgeList.h>
25 #include <geos/noding/OrientedCoordinateArray.h>
26 #include <geos/profiler.h>
33 using namespace geos::noding
;
36 namespace geomgraph
{ // geos.geomgraph
39 static Profiler
*profiler
= Profiler::instance();
44 EdgeList::add(Edge
*e
)
47 OrientedCoordinateArray
* oca
= new OrientedCoordinateArray(*(e
->getCoordinates()));
52 EdgeList::addAll(const vector
<Edge
*> &edgeColl
)
54 for (std::size_t i
=0, s
=edgeColl
.size(); i
<s
; ++i
)
61 * If there is an edge equal to e already in the list, return it.
62 * Otherwise return null.
63 * @return equal edge, if there is one already in the list
67 EdgeList::findEqualEdge(Edge
*e
)
70 static Profile
*prof
= profiler
->get("EdgeList::findEqualEdge(Edge *e)");
74 OrientedCoordinateArray
oca(*(e
->getCoordinates()));
76 EdgeMap::iterator it
= ocaMap
.find(&oca
);
82 if ( it
!= ocaMap
.end() ) return it
->second
;
93 * If the edge e is already in the list, return its index.
94 * @return index, if e is already in the list
98 EdgeList::findEdgeIndex(Edge
*e
)
100 for (int i
=0, s
=(int)edges
.size(); i
<s
; ++i
)
102 if ( edges
[i
]->equals(e
) ) return i
;
114 string out
="EdgeList( ";
115 for(unsigned int j
=0, s
=edges
.size(); j
<s
; ++j
)
127 EdgeList::clearList()
129 for (unsigned int pos
=0; pos
< edges
.size(); pos
++)
130 delete *(&edges
[pos
]);
136 operator<< (std::ostream
&os
, const EdgeList
& el
)
138 os
<< "EdgeList: " << std::endl
;
139 for(std::size_t j
=0, s
=el
.edges
.size(); j
<s
; ++j
)
142 os
<< " " << *e
<< std::endl
;
147 EdgeList::~EdgeList()
149 for (EdgeMap::iterator i
=ocaMap
.begin(), e
=ocaMap
.end(); i
!=e
; ++i
)
151 delete i
->first
; // OrientedCoordinateArray
155 } // namespace geos.geomgraph