- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# LineSequencer.h

    00001 /**********************************************************************
    00002  * $Id: LineSequencer.h 1820 2006-09-06 16:54:23Z mloskot $
    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 #ifndef GEOS_OP_LINEMERGE_LINESEQUENCER_H
    00017 #define GEOS_OP_LINEMERGE_LINESEQUENCER_H
    00018
    00019 #include <geos/operation/linemerge/LineMergeGraph.h> // for composition
    00020 #include <geos/geom/Geometry.h> // for inlines
    00021 #include <geos/geom/LineString.h> // for inlines
    00022
    00023 #include <vector>
    00024 #include <list>
    00025 #include <memory> // for auto_ptr
    00026
    00027 // Forward declarations
    00028 namespace geos {
    00029         namespace geom {
    00030                 class GeometryFactory;
    00031                 class Geometry;
    00032                 class LineString;
    00033         }
    00034         namespace planargraph {
    00035                 class DirectedEdge;
    00036                 class Subgraph;
    00037                 class Node;
    00038         }
    00039 }
    00040
    00041
    00042 namespace geos {
    00043 namespace operation { // geos::operation
    00044 namespace linemerge { // geos::operation::linemerge
    00045
    00082 class LineSequencer {
    00083
    00084 private:
    00085         typedef std::list<planargraph::DirectedEdge*> DirEdgeList;
    00086         typedef std::vector< DirEdgeList* > Sequences;
    00087
    00088         LineMergeGraph graph;
    00089         const geom::GeometryFactory *factory;
    00090         unsigned int lineCount;
    00091         bool isRun;
    00092         std::auto_ptr<geom::Geometry> sequencedGeometry;
    00093         bool isSequenceableVar;
    00094
    00095         void addLine(const geom::LineString *lineString);
    00096         void computeSequence();
    00097         Sequences* findSequences();
    00098         DirEdgeList* findSequence(planargraph::Subgraph& graph);
    00099
    00101         static geom::LineString* reverse(const geom::LineString *line);
    00102
    00112         geom::Geometry* buildSequencedGeometry(const Sequences& sequences);
    00113
    00114         static const planargraph::Node* findLowestDegreeNode(
    00115                         const planargraph::Subgraph& graph);
    00116
    00117         void addReverseSubpath(const planargraph::DirectedEdge *de,
    00118                 DirEdgeList& deList,
    00119                 DirEdgeList::iterator lit,
    00120                 bool expectedClosed);
    00121
    00130         static const planargraph::DirectedEdge* findUnvisitedBestOrientedDE(
    00131                         const planargraph::Node* node);
    00132
    00151         DirEdgeList* orient(DirEdgeList* seq);
    00152
    00161         DirEdgeList* reverse(DirEdgeList& seq);
    00162
    00170         bool hasSequence(planargraph::Subgraph& graph);
    00171
    00172 public:
    00173
    00174         LineSequencer()
    00175                 :
    00176                 factory(0),
    00177                 lineCount(0),
    00178                 isRun(false),
    00179                 sequencedGeometry(0),
    00180                 isSequenceableVar(false)
    00181                 {}
    00182
    00193         static bool isSequenced(const geom::Geometry* geom);
    00194
    00201         bool isSequenceable() {
    00202                 computeSequence();
    00203                 return isSequenceableVar;
    00204         }
    00205
    00214         void add(const geom::Geometry& geometry) {
    00215                 geometry.applyComponentFilter(*this);
    00216         }
    00217
    00222         void filter(const geom::Geometry* g)
    00223         {
    00224                 if (const geom::LineString *ls=dynamic_cast<const geom::LineString *>(g))
    00225                 {
    00226                         addLine(ls);
    00227                 }
    00228         }
    00229
    00239         geom::Geometry*
    00240         getSequencedLineStrings(bool release=1) {
    00241                 computeSequence();
    00242                 if (release) return sequencedGeometry.release();
    00243                 else return sequencedGeometry.get();
    00244         }
    00245
    00246
    00247 };
    00248
    00249 } // namespace geos::operation::linemerge
    00250 } // namespace geos::operation
    00251 } // namespace geos
    00252
    00253 #endif // GEOS_OP_LINEMERGE_LINESEQUENCER_H
    00254
    00255 /**********************************************************************
    00256  * $Log$
    00257  * Revision 1.1  2006/03/22 10:13:53  strk
    00258  * opLinemerge.h split
    00259  *
    00260  **********************************************************************/