• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

LineSequencer.h

00001 /**********************************************************************
00002  * $Id: LineSequencer.h 2562 2009-06-08 15:28:27Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************
00015  *
00016  * Last port: operation/linemerge/LineSequencer.java rev. 1.6 (JTS-1.10)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_OP_LINEMERGE_LINESEQUENCER_H
00021 #define GEOS_OP_LINEMERGE_LINESEQUENCER_H
00022 
00023 #include <geos/export.h>
00024 
00025 #include <geos/operation/linemerge/LineMergeGraph.h> // for composition
00026 #include <geos/geom/Geometry.h> // for inlines
00027 #include <geos/geom/LineString.h> // for inlines
00028 
00029 #include <vector>
00030 #include <list>
00031 #include <memory> // for auto_ptr
00032 
00033 // Forward declarations 
00034 namespace geos {
00035         namespace geom { 
00036                 class GeometryFactory;
00037                 class Geometry;
00038                 class LineString;
00039         }
00040         namespace planargraph { 
00041                 class DirectedEdge;
00042                 class Subgraph;
00043                 class Node;
00044         }
00045 }
00046 
00047 
00048 namespace geos {
00049 namespace operation { // geos::operation
00050 namespace linemerge { // geos::operation::linemerge
00051 
00087 class GEOS_DLL LineSequencer {
00088 
00089 private:
00090         typedef std::list<planargraph::DirectedEdge*> DirEdgeList;
00091         typedef std::vector< DirEdgeList* > Sequences;
00092 
00093         LineMergeGraph graph;
00094         const geom::GeometryFactory *factory;
00095         unsigned int lineCount;
00096         bool isRun;
00097         std::auto_ptr<geom::Geometry> sequencedGeometry;
00098         bool isSequenceableVar;
00099 
00100         void addLine(const geom::LineString *lineString);
00101         void computeSequence();
00102         Sequences* findSequences();
00103         DirEdgeList* findSequence(planargraph::Subgraph& graph);
00104 
00106         static geom::LineString* reverse(const geom::LineString *line);
00107 
00117         geom::Geometry* buildSequencedGeometry(const Sequences& sequences);
00118 
00119         static const planargraph::Node* findLowestDegreeNode(
00120                         const planargraph::Subgraph& graph);
00121 
00122         void addReverseSubpath(const planargraph::DirectedEdge *de,
00123                 DirEdgeList& deList,
00124                 DirEdgeList::iterator lit,
00125                 bool expectedClosed);
00126         
00135         static const planargraph::DirectedEdge* findUnvisitedBestOrientedDE(
00136                         const planargraph::Node* node);
00137 
00156         DirEdgeList* orient(DirEdgeList* seq);
00157 
00166         DirEdgeList* reverse(DirEdgeList& seq);
00167 
00175         bool hasSequence(planargraph::Subgraph& graph);
00176 
00177 public:
00178 
00179         LineSequencer()
00180                 :
00181                 factory(0),
00182                 lineCount(0),
00183                 isRun(false),
00184                 sequencedGeometry(0),
00185                 isSequenceableVar(false)
00186                 {}
00187 
00198         static bool isSequenced(const geom::Geometry* geom);
00199 
00206         bool isSequenceable() {
00207                 computeSequence();
00208                 return isSequenceableVar;
00209         }
00210 
00219         void add(const geom::Geometry& geometry) {
00220                 geometry.applyComponentFilter(*this);
00221         }
00222 
00227         void filter(const geom::Geometry* g)
00228         {
00229                 if (const geom::LineString *ls=dynamic_cast<const geom::LineString *>(g))
00230                 {
00231                         addLine(ls);
00232                 }
00233         }
00234 
00244         geom::Geometry*
00245         getSequencedLineStrings(bool release=1) {
00246                 computeSequence();
00247                 if (release) return sequencedGeometry.release();
00248                 else return sequencedGeometry.get();
00249         }
00250 
00251 
00252 };
00253 
00254 } // namespace geos::operation::linemerge
00255 } // namespace geos::operation
00256 } // namespace geos
00257 
00258 #endif // GEOS_OP_LINEMERGE_LINESEQUENCER_H
00259 
00260 /**********************************************************************
00261  * $Log$
00262  * Revision 1.1  2006/03/22 10:13:53  strk
00263  * opLinemerge.h split
00264  *
00265  **********************************************************************/

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1