<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GEOS: LineSequencer.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>LineSequencer.h</h1> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**********************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> * $Id: LineSequencer.h 2562 2009-06-08 15:28:27Z strk $</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * GEOS - Geometry Engine Open Source</span> <a name="l00005"></a>00005 <span class="comment"> * http://geos.refractions.net</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2006 Refractions Research Inc.</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * This is free software; you can redistribute and/or modify it under</span> <a name="l00010"></a>00010 <span class="comment"> * the terms of the GNU Lesser General Public Licence as published</span> <a name="l00011"></a>00011 <span class="comment"> * by the Free Software Foundation. </span> <a name="l00012"></a>00012 <span class="comment"> * See the COPYING file for more information.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> **********************************************************************</span> <a name="l00015"></a>00015 <span class="comment"> *</span> <a name="l00016"></a>00016 <span class="comment"> * Last port: operation/linemerge/LineSequencer.java rev. 1.6 (JTS-1.10)</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> **********************************************************************/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef GEOS_OP_LINEMERGE_LINESEQUENCER_H</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define GEOS_OP_LINEMERGE_LINESEQUENCER_H</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <geos/export.h></span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#include <geos/operation/linemerge/LineMergeGraph.h></span> <span class="comment">// for composition</span> <a name="l00026"></a>00026 <span class="preprocessor">#include <geos/geom/Geometry.h></span> <span class="comment">// for inlines</span> <a name="l00027"></a>00027 <span class="preprocessor">#include <geos/geom/LineString.h></span> <span class="comment">// for inlines</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include <vector></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <list></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <memory></span> <span class="comment">// for auto_ptr</span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="comment">// Forward declarations </span> <a name="l00034"></a>00034 <span class="keyword">namespace </span>geos { <a name="l00035"></a>00035 <span class="keyword">namespace </span>geom { <a name="l00036"></a>00036 <span class="keyword">class </span>GeometryFactory; <a name="l00037"></a>00037 <span class="keyword">class </span>Geometry; <a name="l00038"></a>00038 <span class="keyword">class </span>LineString; <a name="l00039"></a>00039 } <a name="l00040"></a>00040 <span class="keyword">namespace </span>planargraph { <a name="l00041"></a>00041 <span class="keyword">class </span>DirectedEdge; <a name="l00042"></a>00042 <span class="keyword">class </span>Subgraph; <a name="l00043"></a>00043 <span class="keyword">class </span>Node; <a name="l00044"></a>00044 } <a name="l00045"></a>00045 } <a name="l00046"></a>00046 <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="keyword">namespace </span>geos { <a name="l00049"></a>00049 <span class="keyword">namespace </span>operation { <span class="comment">// geos::operation</span> <a name="l00050"></a>00050 <span class="keyword">namespace </span>linemerge { <span class="comment">// geos::operation::linemerge</span> <a name="l00051"></a>00051 <a name="l00087"></a><a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html">00087</a> <span class="keyword">class </span>GEOS_DLL <a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html" title="Builds a sequence from a set of LineStrings so that they are ordered end to end.">LineSequencer</a> { <a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="keyword">private</span>: <a name="l00090"></a>00090 <span class="keyword">typedef</span> std::list<planargraph::DirectedEdge*> DirEdgeList; <a name="l00091"></a>00091 <span class="keyword">typedef</span> std::vector< DirEdgeList* > Sequences; <a name="l00092"></a>00092 <a name="l00093"></a>00093 <a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineMergeGraph.html" title="A planar graph of edges that is analyzed to sew the edges together.">LineMergeGraph</a> graph; <a name="l00094"></a>00094 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1GeometryFactory.html" title="Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...">geom::GeometryFactory</a> *factory; <a name="l00095"></a>00095 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> lineCount; <a name="l00096"></a>00096 <span class="keywordtype">bool</span> isRun; <a name="l00097"></a>00097 std::auto_ptr<geom::Geometry> sequencedGeometry; <a name="l00098"></a>00098 <span class="keywordtype">bool</span> isSequenceableVar; <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="keywordtype">void</span> addLine(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a> *lineString); <a name="l00101"></a>00101 <span class="keywordtype">void</span> computeSequence(); <a name="l00102"></a>00102 Sequences* findSequences(); <a name="l00103"></a>00103 DirEdgeList* findSequence(<a class="code" href="classgeos_1_1planargraph_1_1Subgraph.html" title="A subgraph of a PlanarGraph.">planargraph::Subgraph</a>& graph); <a name="l00104"></a>00104 <a name="l00106"></a>00106 <span class="keyword">static</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a>* reverse(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a> *line); <a name="l00107"></a>00107 <a name="l00117"></a>00117 <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>* buildSequencedGeometry(<span class="keyword">const</span> Sequences& sequences); <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classgeos_1_1planargraph_1_1Node.html" title="A node in a PlanarGraph is a location where 0 or more Edge meet.">planargraph::Node</a>* findLowestDegreeNode( <a name="l00120"></a>00120 <span class="keyword">const</span> <a class="code" href="classgeos_1_1planargraph_1_1Subgraph.html" title="A subgraph of a PlanarGraph.">planargraph::Subgraph</a>& graph); <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="keywordtype">void</span> addReverseSubpath(<span class="keyword">const</span> <a class="code" href="classgeos_1_1planargraph_1_1DirectedEdge.html" title="Represents a directed edge in a PlanarGraph.">planargraph::DirectedEdge</a> *de, <a name="l00123"></a>00123 DirEdgeList& deList, <a name="l00124"></a>00124 DirEdgeList::iterator lit, <a name="l00125"></a>00125 <span class="keywordtype">bool</span> expectedClosed); <a name="l00126"></a>00126 <a name="l00135"></a>00135 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classgeos_1_1planargraph_1_1DirectedEdge.html" title="Represents a directed edge in a PlanarGraph.">planargraph::DirectedEdge</a>* findUnvisitedBestOrientedDE( <a name="l00136"></a>00136 <span class="keyword">const</span> <a class="code" href="classgeos_1_1planargraph_1_1Node.html" title="A node in a PlanarGraph is a location where 0 or more Edge meet.">planargraph::Node</a>* node); <a name="l00137"></a>00137 <a name="l00156"></a>00156 DirEdgeList* orient(DirEdgeList* seq); <a name="l00157"></a>00157 <a name="l00166"></a>00166 DirEdgeList* reverse(DirEdgeList& seq); <a name="l00167"></a>00167 <a name="l00175"></a>00175 <span class="keywordtype">bool</span> hasSequence(<a class="code" href="classgeos_1_1planargraph_1_1Subgraph.html" title="A subgraph of a PlanarGraph.">planargraph::Subgraph</a>& graph); <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="keyword">public</span>: <a name="l00178"></a>00178 <a name="l00179"></a>00179 <a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html" title="Builds a sequence from a set of LineStrings so that they are ordered end to end.">LineSequencer</a>() <a name="l00180"></a>00180 : <a name="l00181"></a>00181 factory(0), <a name="l00182"></a>00182 lineCount(0), <a name="l00183"></a>00183 isRun(<span class="keyword">false</span>), <a name="l00184"></a>00184 sequencedGeometry(0), <a name="l00185"></a>00185 isSequenceableVar(<span class="keyword">false</span>) <a name="l00186"></a>00186 {} <a name="l00187"></a>00187 <a name="l00198"></a>00198 <span class="keyword">static</span> <span class="keywordtype">bool</span> isSequenced(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>* geom); <a name="l00199"></a>00199 <a name="l00206"></a><a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#a6f67bdb9cae41e922f385097864854a2">00206</a> <span class="keywordtype">bool</span> <a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#a6f67bdb9cae41e922f385097864854a2">isSequenceable</a>() { <a name="l00207"></a>00207 computeSequence(); <a name="l00208"></a>00208 <span class="keywordflow">return</span> isSequenceableVar; <a name="l00209"></a>00209 } <a name="l00210"></a>00210 <a name="l00219"></a><a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#aa0b6aa09f7f894d46510d94b76eb07ba">00219</a> <span class="keywordtype">void</span> <a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#aa0b6aa09f7f894d46510d94b76eb07ba">add</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& geometry) { <a name="l00220"></a>00220 geometry.<a class="code" href="classgeos_1_1geom_1_1Geometry.html#a558ac8159fcba50c602ce9a385005a6a" title="Apply a fiter to each component of this geometry. The filter is expected to provide a ...">applyComponentFilter</a>(*<span class="keyword">this</span>); <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <a name="l00227"></a><a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#aa869e231e53cda4dfbacd04eabbff7c0">00227</a> <span class="keywordtype">void</span> filter(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>* g) <a name="l00228"></a>00228 { <a name="l00229"></a>00229 <span class="keywordflow">if</span> (<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a> *ls=dynamic_cast<const geom::LineString *>(g)) <a name="l00230"></a>00230 { <a name="l00231"></a>00231 addLine(ls); <a name="l00232"></a>00232 } <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00244"></a>00244 <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>* <a name="l00245"></a><a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#a40cd323835090fd35250b3aff87f95b6">00245</a> <a class="code" href="classgeos_1_1operation_1_1linemerge_1_1LineSequencer.html#a40cd323835090fd35250b3aff87f95b6">getSequencedLineStrings</a>(<span class="keywordtype">bool</span> release=1) { <a name="l00246"></a>00246 computeSequence(); <a name="l00247"></a>00247 <span class="keywordflow">if</span> (release) <span class="keywordflow">return</span> sequencedGeometry.release(); <a name="l00248"></a>00248 <span class="keywordflow">else</span> <span class="keywordflow">return</span> sequencedGeometry.get(); <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <a name="l00251"></a>00251 <a name="l00252"></a>00252 }; <a name="l00253"></a>00253 <a name="l00254"></a>00254 } <span class="comment">// namespace geos::operation::linemerge</span> <a name="l00255"></a>00255 } <span class="comment">// namespace geos::operation</span> <a name="l00256"></a>00256 } <span class="comment">// namespace geos</span> <a name="l00257"></a>00257 <a name="l00258"></a>00258 <span class="preprocessor">#endif // GEOS_OP_LINEMERGE_LINESEQUENCER_H</span> <a name="l00259"></a>00259 <span class="preprocessor"></span> <a name="l00260"></a>00260 <span class="comment">/**********************************************************************</span> <a name="l00261"></a>00261 <span class="comment"> * $Log$</span> <a name="l00262"></a>00262 <span class="comment"> * Revision 1.1 2006/03/22 10:13:53 strk</span> <a name="l00263"></a>00263 <span class="comment"> * opLinemerge.h split</span> <a name="l00264"></a>00264 <span class="comment"> *</span> <a name="l00265"></a>00265 <span class="comment"> **********************************************************************/</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Thu Jul 22 2010 for GEOS by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address> </body> </html>