00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_NODING_NODEDSEGMENTSTRING_H
00022 #define GEOS_NODING_NODEDSEGMENTSTRING_H
00023
00024 #include <geos/noding/NodableSegmentString.h>
00025 #include <geos/geom/CoordinateSequence.h>
00026 #include <geos/algorithm/LineIntersector.h>
00027 #include <geos/noding/SegmentNode.h>
00028 #include <geos/noding/SegmentNodeList.h>
00029 #include <geos/noding/SegmentString.h>
00030
00031 #include <geos/geom/Coordinate.h>
00032
00033 #ifdef _MSC_VER
00034 #pragma warning(push)
00035 #pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list
00036 #endif
00037
00038 namespace geos {
00039 namespace noding {
00040
00053 class NodedSegmentString : public NodableSegmentString
00054 {
00055 public:
00056
00057 static void getNodedSubstrings(SegmentString::ConstVect* segStrings,
00058 SegmentString::NonConstVect* resultEdgelist)
00059 {
00060 for (size_t i=0, n=segStrings->size(); i<n; i++)
00061 {
00062 NodedSegmentString * nss = (NodedSegmentString *)((*segStrings)[i]);
00063 nss->getNodeList().addSplitEdges( resultEdgelist);
00064 }
00065 }
00066
00067 static void getNodedSubstrings(
00068 const SegmentString::NonConstVect& segStrings,
00069 SegmentString::NonConstVect* resultEdgeList);
00070
00072 static SegmentString::NonConstVect* getNodedSubstrings(
00073 const SegmentString::NonConstVect& segStrings);
00074
00075
00085 NodedSegmentString(geom::CoordinateSequence *newPts,
00086 const void* newContext)
00087 :
00088 NodableSegmentString(newContext),
00089 nodeList(this),
00090 pts(newPts)
00091 { }
00092
00093 ~NodedSegmentString()
00094 { }
00095
00105 SegmentNode * addIntersectionNode( geom::Coordinate * intPt, size_t segmentIndex)
00106 {
00107 size_t normalizedSegmentIndex = segmentIndex;
00108
00109
00110 size_t nextSegIndex = normalizedSegmentIndex + 1;
00111 if (nextSegIndex < size())
00112 {
00113 const geom::Coordinate &nextPt = getCoordinate( nextSegIndex);
00114
00115
00116
00117 if ( intPt->equals2D( nextPt ))
00118 {
00119 normalizedSegmentIndex = nextSegIndex;
00120 }
00121 }
00122
00123
00124 SegmentNode * ei = getNodeList().add( *intPt, normalizedSegmentIndex);
00125 return ei;
00126 }
00127
00128 SegmentNodeList& getNodeList();
00129
00130 const SegmentNodeList& getNodeList() const;
00131
00132 virtual unsigned int size() const
00133 {
00134 return pts->size();
00135 }
00136
00137 virtual const geom::Coordinate& getCoordinate(unsigned int i) const;
00138
00139 virtual geom::CoordinateSequence* getCoordinates() const;
00140
00141 virtual bool isClosed() const;
00142
00143 virtual std::ostream& print(std::ostream& os) const;
00144
00145
00153 int getSegmentOctant(unsigned int index) const;
00154
00160 void addIntersections(algorithm::LineIntersector *li,
00161 unsigned int segmentIndex, int geomIndex);
00162
00170 void addIntersection(algorithm::LineIntersector *li,
00171 unsigned int segmentIndex,
00172 int geomIndex, int intIndex);
00173
00181 void addIntersection(const geom::Coordinate& intPt,
00182 unsigned int segmentIndex);
00183
00184
00185 private:
00186
00187 SegmentNodeList nodeList;
00188
00189 geom::CoordinateSequence *pts;
00190
00191 };
00192
00193 }
00194 }
00195
00196 #ifdef _MSC_VER
00197 #pragma warning(pop)
00198 #endif
00199
00200 #endif // GEOS_NODING_NODEDSEGMENTSTRING_H
00201
00202
00203
00204