Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

opLinemerge.h

00001 /**********************************************************************
00002  * $Id: opLinemerge.h,v 1.3 2004/07/19 13:19:31 strk Exp $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2001-2002 Vivid Solutions 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  * $Log: opLinemerge.h,v $
00016  * Revision 1.3  2004/07/19 13:19:31  strk
00017  * Documentation fixes
00018  *
00019  * Revision 1.2  2004/07/08 19:34:49  strk
00020  * Mirrored JTS interface of CoordinateSequence, factory and
00021  * default implementations.
00022  * Added DefaultCoordinateSequenceFactory::instance() function.
00023  *
00024  * Revision 1.1  2004/07/02 13:20:42  strk
00025  * Header files moved under geos/ dir.
00026  *
00027  * Revision 1.1  2004/04/07 06:55:50  ybychkov
00028  * "operation/linemerge" ported from JTS 1.4
00029  *
00030  *
00031  **********************************************************************/
00032 
00033 
00034 #ifndef GEOS_OPLINEMERGE_H
00035 #define GEOS_OPLINEMERGE_H
00036 
00037 #include <geos/platform.h>
00038 #include <geos/planargraph.h>
00039 #include <geos/geom.h>
00040 #include <vector>
00041 
00042 namespace geos {
00043 
00044 /*
00045  * An edge of a LineMergeGraph. The <code>marked</code> field indicates
00046  * whether this Edge has been logically deleted from the graph.
00047  *
00048  */
00049 class LineMergeEdge: public planarEdge {
00050 private:
00051         LineString *line;
00052 public:
00056         LineMergeEdge(LineString *newLine);
00060         LineString* getLine();
00061 };
00062 
00063 
00064 /*
00065  * A {@link com.vividsolutions.jts.planargraph.DirectedEdge} of a 
00066  * {@link LineMergeGraph}. 
00067  *
00068  */
00069 class LineMergeDirectedEdge: public planarDirectedEdge {
00070 public:
00082         LineMergeDirectedEdge(planarNode *newFrom,planarNode *newTo,Coordinate& newDirectionPt,bool nEdgeDirection);
00088         LineMergeDirectedEdge* getNext();
00089 };
00090 
00091 /*
00092  * \brief
00093  * A sequence of LineMergeDirectedEdge forming one of the lines that will
00094  * be output by the line-merging process.
00095  */
00096 class EdgeString {
00097 private:
00098         GeometryFactory *factory;
00099         vector<LineMergeDirectedEdge*> *directedEdges;
00100         CoordinateSequence *coordinates;
00101         const CoordinateSequence* getCoordinates();
00102 public:
00107         EdgeString(GeometryFactory *newFactory);
00108 
00109         ~EdgeString();
00110 
00114         void add(LineMergeDirectedEdge *directedEdge);
00115 
00119         LineString* toLineString();
00120 };
00121 
00122 /*
00123  * A planar graph of edges that is analyzed to sew the edges together. The 
00124  * <code>marked</code> flag on @{link com.vividsolutions.planargraph.Edge}s 
00125  * and @{link com.vividsolutions.planargraph.Node}s indicates whether they have been
00126  * logically deleted from the graph.
00127  *
00128  */
00129 class LineMergeGraph: public planarPlanarGraph {
00130 public:
00135         void addEdge(LineString *lineString);
00136 private:
00137         planarNode* getNode(Coordinate &coordinate);
00138 };
00139 
00140 /*
00141  * Sews together a set of fully noded LineStrings. Sewing stops at nodes of degree 1
00142  * or 3 or more -- the exception is an isolated loop, which only has degree-2 nodes,
00143  * in which case a node is simply chosen as a starting point. The direction of each
00144  * merged LineString will be that of the majority of the LineStrings from which it
00145  * was derived.
00146  * <p>
00147  * Any dimension of Geometry is handled -- the constituent linework is extracted to 
00148  * form the edges. The edges must be correctly noded; that is, they must only meet
00149  * at their endpoints.  The LineMerger will still run on incorrectly noded input
00150  * but will not form polygons from incorrected noded edges.
00151  *
00152  */
00153 class LineMerger {
00154 public:
00155         LineMerger();
00156         ~LineMerger();
00162         void add(vector<Geometry*> *geometries);
00168         void add(Geometry *geometry);
00172         vector<LineString*>* getMergedLineStrings();
00173         void add(LineString *lineString);
00174 private:
00175         LineMergeGraph *graph;
00176         vector<LineString*> *mergedLineStrings;
00177         vector<EdgeString*> *edgeStrings;
00178         GeometryFactory *factory;
00179         void merge();
00180         void buildEdgeStringsForObviousStartNodes();
00181         void buildEdgeStringsForIsolatedLoops();
00182         void buildEdgeStringsForUnprocessedNodes();
00183         void buildEdgeStringsForNonDegree2Nodes();
00184         void buildEdgeStringsStartingAt(planarNode *node);
00185         EdgeString* buildEdgeStringStartingWith(LineMergeDirectedEdge *start);
00186 };
00187 
00188 class LMGeometryComponentFilter: public GeometryComponentFilter {
00189 public:
00190         LineMerger *lm;
00191         LMGeometryComponentFilter(LineMerger *newLm);
00192         virtual void filter_rw(Geometry *geom);
00193         virtual void filter_ro(const Geometry *geom){}; // Unsupported
00194 };
00195 
00196 }
00197 #endif
00198 

Generated on Fri Nov 26 21:30:45 2004 for GEOS by  doxygen 1.3.9.1