00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GEOS_NODING_NODEDSEGMENTSTRING_H
00018 #define GEOS_NODING_NODEDSEGMENTSTRING_H
00019
00020 #include <geos/algorithm/LineIntersector.h>
00021 #include <geos/noding/NodableSegmentString.h>
00022 #include <geos/noding/SegmentNode.h>
00023 #include <geos/noding/SegmentNodeList.h>
00024 #include <geos/noding/SegmentString.h>
00025
00026 #include <geos/geom/Coordinate.h>
00027
00028
00029
00030 namespace geos {
00031 namespace noding {
00032
00046 class NodedSegmentString : public NodableSegmentString
00047 {
00048 private:
00049 protected:
00050 public:
00051 static void getNodedSubstrings( SegmentString::ConstVect * segStrings, SegmentString::NonConstVect * resultEdgelist)
00052 {
00053 for (size_t i=0, n=segStrings->size(); i<n; i++)
00054 {
00055 NodedSegmentString * nss = (NodedSegmentString *)((*segStrings)[i]);
00056 nss->getNodeList().addSplitEdges( resultEdgelist);
00057 }
00058 }
00059
00066 NodedSegmentString( geom::CoordinateSequence *newPts, const void* newContext)
00067 : NodableSegmentString( newPts, newContext )
00068 { }
00069
00070 ~NodedSegmentString()
00071 { }
00072
00082 SegmentNode * addIntersectionNode( geom::Coordinate * intPt, int segmentIndex)
00083 {
00084 int normalizedSegmentIndex = segmentIndex;
00085
00086
00087 int nextSegIndex = normalizedSegmentIndex + 1;
00088 if (nextSegIndex < size())
00089 {
00090 const geom::Coordinate &nextPt = getCoordinate( nextSegIndex);
00091
00092
00093
00094 if ( intPt->equals2D( nextPt ))
00095 {
00096 normalizedSegmentIndex = nextSegIndex;
00097 }
00098 }
00099
00100
00101 SegmentNode * ei = getNodeList().add( *intPt, normalizedSegmentIndex);
00102 return ei;
00103 }
00104
00105 };
00106
00107 }
00108 }
00109
00110 #endif // GEOS_NODING_NODEDSEGMENTSTRING_H
00111
00112
00113
00114