GEOS 3.6.2
EdgeIntersection.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2009-2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geomgraph/EdgeIntersection.java rev. 1.5 (JTS-1.10)
18 *
19 **********************************************************************/
20
21
22#ifndef GEOS_GEOMGRAPH_EDGEINTERSECTION_H
23#define GEOS_GEOMGRAPH_EDGEINTERSECTION_H
24
25#include <geos/export.h>
26
27#include <geos/geom/Coordinate.h> // for composition and inlines
28
29#include <geos/inline.h>
30
31#include <ostream>
32
33
34namespace geos {
35namespace geomgraph { // geos.geomgraph
36
45class GEOS_DLL EdgeIntersection {
46public:
47
48 // the point of intersection
49 geom::Coordinate coord;
50
51 // the edge distance of this point along the containing line segment
52 double dist;
53
54 // the index of the containing line segment in the parent edge
55 int segmentIndex;
56
57 EdgeIntersection(const geom::Coordinate& newCoord,
58 int newSegmentIndex, double newDist)
59 :
60 coord(newCoord),
61 dist(newDist),
62 segmentIndex(newSegmentIndex)
63 {}
64
65 bool isEndPoint(int maxSegmentIndex) const {
66 if (segmentIndex==0 && dist==0.0) return true;
67 if (segmentIndex==maxSegmentIndex) return true;
68 return false;
69 }
70
71 const geom::Coordinate& getCoordinate() const {
72 return coord;
73 }
74
75 int getSegmentIndex() const { return segmentIndex; }
76
77 double getDistance() const { return dist; }
78
79};
80
82//
84inline bool operator< (const EdgeIntersection& ei1, const EdgeIntersection& ei2)
85{
86 if ( ei1.segmentIndex < ei2.segmentIndex ) return true;
87 if ( ei1.segmentIndex == ei2.segmentIndex )
88 {
89 if ( ei1.dist < ei2.dist ) return true;
90
91 // TODO: check if the Coordinate matches, or this will
92 // be a robustness issue in computin distance
93 // See http://trac.osgeo.org/geos/ticket/350
94 }
95 return false;
96}
97
98// @deprecated, use strict weak ordering operator
99struct GEOS_DLL EdgeIntersectionLessThen {
100 bool operator()(const EdgeIntersection *ei1,
101 const EdgeIntersection *ei2) const
102 {
103 return *ei1 < *ei2;
104 }
105};
106
108inline std::ostream& operator<< (std::ostream& os, const EdgeIntersection& e)
109{
110 os << e.coord << " seg # = " << e.segmentIndex << " dist = " << e.dist;
111 return os;
112}
113
114} // namespace geos.geomgraph
115} // namespace geos
116
117#endif // ifndef GEOS_GEOMGRAPH_EDGEINTERSECTION_H
118
119
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Definition EdgeIntersection.h:45
Contains classes that implement topology graphs.
Definition IndexedNestedRingTester.h:34
bool operator<(const EdgeIntersection &ei1, const EdgeIntersection &ei2)
Strict weak ordering operator for EdgeIntersection.
Definition EdgeIntersection.h:84
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25