/src/geos/src/operation/linemerge/LineMergeDirectedEdge.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2005-2006 Refractions Research Inc. |
7 | | * Copyright (C) 2001-2002 Vivid Solutions Inc. |
8 | | * |
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. |
13 | | * |
14 | | ********************************************************************** |
15 | | * |
16 | | * Last port: operation/linemerge/LineMergeDirectedEdge.java r378 (JTS-1.12) |
17 | | * |
18 | | **********************************************************************/ |
19 | | |
20 | | #include <geos/operation/linemerge/LineMergeDirectedEdge.h> |
21 | | #include <geos/planargraph/DirectedEdge.h> |
22 | | #include <geos/planargraph/Node.h> |
23 | | |
24 | | #include <cassert> |
25 | | |
26 | | //using namespace geos::planargraph; |
27 | | using namespace geos::geom; |
28 | | |
29 | | namespace geos { |
30 | | namespace operation { // geos.operation |
31 | | namespace linemerge { // geos.operation.linemerge |
32 | | |
33 | | LineMergeDirectedEdge::LineMergeDirectedEdge( |
34 | | planargraph::Node* newFrom, |
35 | | planargraph::Node* newTo, |
36 | | const Coordinate& newDirectionPt, |
37 | | bool nEdgeDirection) |
38 | | : |
39 | | planargraph::DirectedEdge(newFrom, newTo, |
40 | | newDirectionPt, nEdgeDirection) |
41 | 0 | {} |
42 | | |
43 | | /** |
44 | | * Returns the directed edge that starts at this directed edge's end point, |
45 | | * or null if there are zero or multiple directed edges starting there. |
46 | | * @param checkDirection |
47 | | * @return |
48 | | */ |
49 | | LineMergeDirectedEdge* |
50 | | LineMergeDirectedEdge::getNext(bool checkDirection) |
51 | 0 | { |
52 | 0 | if(getToNode()->getDegree() != 2) { |
53 | 0 | return nullptr; |
54 | 0 | } |
55 | 0 | if(getToNode()->getOutEdges()->getEdges()[0] == getSym()) { |
56 | 0 | auto nextedge = dynamic_cast<LineMergeDirectedEdge*>(getToNode()->getOutEdges()->getEdges()[1]); |
57 | 0 | return (!checkDirection || nextedge->getEdgeDirection()) ? nextedge : nullptr; |
58 | 0 | } |
59 | 0 | assert(getToNode()->getOutEdges()->getEdges()[1] == getSym()); |
60 | |
|
61 | 0 | auto nextedge = dynamic_cast<LineMergeDirectedEdge*>(getToNode()->getOutEdges()->getEdges()[0]); |
62 | 0 | assert(nextedge); |
63 | |
|
64 | 0 | return (!checkDirection || nextedge->getEdgeDirection()) ? nextedge : nullptr; |
65 | 0 | } |
66 | | |
67 | | } // namespace geos.operation.linemerge |
68 | | } // namespace geos.operation |
69 | | } //namespace geos |