GEOS: TaggedLineStringSimplifier.h Source File

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

- File List

# TaggedLineStringSimplifier.h

    00001 /**********************************************************************
    00002  * $Id: TaggedLineStringSimplifier.h 2785 2009-12-03 19:55:11Z 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 Licence as published
    00011  * by the Free Software Foundation.
    00012  * See the COPYING file for more information.
    00013  *
    00014  **********************************************************************
    00015  *
    00016  * Last port: simplify/TaggedLineStringSimplifier.java rev. 1.8 (JTS-1.7.1)
    00017  *
    00018  **********************************************************************
    00019  *
    00020  * NOTES: This class can be optimized to work with vector<Coordinate*>
    00021  *        rather then with CoordinateSequence
    00022  *
    00023  **********************************************************************/
    00024
    00025 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
    00026 #define GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
    00027
    00028 #include <geos/export.h>
    00029 #include <vector>
    00030 #include <memory>
    00031
    00032 // Forward declarations
    00033 namespace geos {
    00034         namespace algorithm {
    00035                 class LineIntersector;
    00036         }
    00037         namespace geom {
    00038                 class CoordinateSequence;
    00039                 class LineSegment;
    00040         }
    00041         namespace simplify {
    00042                 class TaggedLineSegment;
    00043                 class TaggedLineString;
    00044                 class LineSegmentIndex;
    00045         }
    00046 }
    00047
    00048 namespace geos {
    00049 namespace simplify { // geos::simplify
    00050
    00051
    00058 class GEOS_DLL TaggedLineStringSimplifier {
    00059
    00060 public:
    00061
    00062         TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
    00063                 LineSegmentIndex* outputIndex);
    00064
    00073         void setDistanceTolerance(double d);
    00074
    00075         void simplify(TaggedLineString* line);
    00076
    00077
    00078 private:
    00079
    00080         // externally owned
    00081         LineSegmentIndex* inputIndex;
    00082
    00083         // externally owned
    00084         LineSegmentIndex* outputIndex;
    00085
    00086         std::auto_ptr<algorithm::LineIntersector> li;
    00087
    00089         TaggedLineString* line;
    00090
    00091         const geom::CoordinateSequence* linePts;
    00092
    00093         double distanceTolerance;
    00094
    00095         void simplifySection(size_t i, size_t j,
    00096                         size_t depth);
    00097
    00098         static size_t findFurthestPoint(
    00099                         const geom::CoordinateSequence* pts,
    00100                         size_t i, size_t j,
    00101                         double& maxDistance);
    00102
    00103         bool hasBadIntersection(const TaggedLineString* parentLine,
    00104                        const std::vector<size_t>& sectionIndex,
    00105                        const geom::LineSegment& candidateSeg);
    00106
    00107         bool hasBadInputIntersection(const TaggedLineString* parentLine,
    00108                        const std::vector<size_t>& sectionIndex,
    00109                        const geom::LineSegment& candidateSeg);
    00110
    00111         bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
    00112
    00113         bool hasInteriorIntersection(const geom::LineSegment& seg0,
    00114                         const geom::LineSegment& seg1) const;
    00115
    00116         std::auto_ptr<TaggedLineSegment> flatten(
    00117                         size_t start, size_t end);
    00118
    00127         static bool isInLineSection(
    00128                 const TaggedLineString* parentLine,
    00129                 const std::vector<size_t>& sectionIndex,
    00130                 const TaggedLineSegment* seg);
    00131
    00140         void remove(const TaggedLineString* line,
    00141                         size_t start,
    00142                         size_t end);
    00143
    00144 };
    00145
    00146 inline void
    00147 TaggedLineStringSimplifier::setDistanceTolerance(double d)
    00148 {
    00149         distanceTolerance = d;
    00150 }
    00151
    00152 } // namespace geos::simplify
    00153 } // namespace geos
    00154
    00155 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
    00156
    00157 /**********************************************************************
    00158  * $Log$
    00159  * Revision 1.3  2006/04/13 21:52:34  strk
    00160  * Many debugging lines and assertions added. Fixed bug in TaggedLineString class.
    00161  *
    00162  * Revision 1.2  2006/04/13 10:39:12  strk
    00163  * Initial implementation of TaggedLinesSimplifier class
    00164  *
    00165  * Revision 1.1  2006/04/12 17:19:57  strk
    00166  * Ported TaggedLineStringSimplifier class, made LineSegment class
    00167  * polymorphic to fix derivation of TaggedLineSegment
    00168  *
    00169  **********************************************************************/