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
00034
00035 namespace geos {
00036 namespace noding {
00037
00050 class NodedSegmentString : public NodableSegmentString
00051 {
00052 public:
00053
00054 static void getNodedSubstrings(SegmentString::ConstVect* segStrings,
00055 SegmentString::NonConstVect* resultEdgelist)
00056 {
00057 for (size_t i=0, n=segStrings->size(); i<n; i++)
00058 {
00059 NodedSegmentString * nss = (NodedSegmentString *)((*segStrings)[i]);
00060 nss->getNodeList().addSplitEdges( resultEdgelist);
00061 }
00062 }
00063
00064 static void getNodedSubstrings(
00065 const SegmentString::NonConstVect& segStrings,
00066 SegmentString::NonConstVect* resultEdgeList);
00067
00069 static SegmentString::NonConstVect* getNodedSubstrings(
00070 const SegmentString::NonConstVect& segStrings);
00071
00072
00082 NodedSegmentString(geom::CoordinateSequence *newPts,
00083 const void* newContext)
00084 :
00085 NodableSegmentString(newContext),
00086 nodeList(this),
00087 pts(newPts)
00088 { }
00089
00090 ~NodedSegmentString()
00091 { }
00092
00102 SegmentNode * addIntersectionNode( geom::Coordinate * intPt, size_t segmentIndex)
00103 {
00104 size_t normalizedSegmentIndex = segmentIndex;
00105
00106
00107 size_t nextSegIndex = normalizedSegmentIndex + 1;
00108 if (nextSegIndex < size())
00109 {
00110 const geom::Coordinate &nextPt = getCoordinate( nextSegIndex);
00111
00112
00113
00114 if ( intPt->equals2D( nextPt ))
00115 {
00116 normalizedSegmentIndex = nextSegIndex;
00117 }
00118 }
00119
00120
00121 SegmentNode * ei = getNodeList().add( *intPt, normalizedSegmentIndex);
00122 return ei;
00123 }
00124
00125 SegmentNodeList& getNodeList();
00126
00127 const SegmentNodeList& getNodeList() const;
00128
00129 virtual unsigned int size() const
00130 {
00131 return pts->size();
00132 }
00133
00134 virtual const geom::Coordinate& getCoordinate(unsigned int i) const;
00135
00136 virtual geom::CoordinateSequence* getCoordinates() const;
00137
00138 virtual bool isClosed() const;
00139
00140 virtual std::ostream& print(std::ostream& os) const;
00141
00142
00150 int getSegmentOctant(unsigned int index) const;
00151
00157 void addIntersections(algorithm::LineIntersector *li,
00158 unsigned int segmentIndex, int geomIndex);
00159
00167 void addIntersection(algorithm::LineIntersector *li,
00168 unsigned int segmentIndex,
00169 int geomIndex, int intIndex);
00170
00178 void addIntersection(const geom::Coordinate& intPt,
00179 unsigned int segmentIndex);
00180
00181
00182 private:
00183
00184 SegmentNodeList nodeList;
00185
00186 geom::CoordinateSequence *pts;
00187
00188 };
00189
00190 }
00191 }
00192
00193 #endif // GEOS_NODING_NODEDSEGMENTSTRING_H
00194
00195
00196
00197