GEOS: TaggedLineStringSimplifier.h Source File

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

# TaggedLineStringSimplifier.h

    00001 /**********************************************************************
    00002  * $Id: TaggedLineStringSimplifier.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 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 <vector>
    00029 #include <memory>
    00030
    00031 // Forward declarations
    00032 namespace geos {
    00033         namespace algorithm {
    00034                 class LineIntersector;
    00035         }
    00036         namespace geom {
    00037                 class CoordinateSequence;
    00038                 class LineSegment;
    00039         }
    00040         namespace simplify {
    00041                 class TaggedLineSegment;
    00042                 class TaggedLineString;
    00043                 class LineSegmentIndex;
    00044         }
    00045 }
    00046
    00047 namespace geos {
    00048 namespace simplify { // geos::simplify
    00049
    00050
    00057 class TaggedLineStringSimplifier {
    00058
    00059 public:
    00060
    00061         TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
    00062                 LineSegmentIndex* outputIndex);
    00063
    00072         void setDistanceTolerance(double d);
    00073
    00074         void simplify(TaggedLineString* line);
    00075
    00076
    00077 private:
    00078
    00079         // externally owned
    00080         LineSegmentIndex* inputIndex;
    00081
    00082         // externally owned
    00083         LineSegmentIndex* outputIndex;
    00084
    00085         std::auto_ptr<algorithm::LineIntersector> li;
    00086
    00088         TaggedLineString* line;
    00089
    00090         const geom::CoordinateSequence* linePts;
    00091
    00092         double distanceTolerance;
    00093
    00094         void simplifySection(size_t i, size_t j,
    00095                         size_t depth);
    00096
    00097         static size_t findFurthestPoint(
    00098                         const geom::CoordinateSequence* pts,
    00099                         size_t i, size_t j,
    00100                         double& maxDistance);
    00101
    00102         bool hasBadIntersection(const TaggedLineString* parentLine,
    00103                        const std::vector<size_t>& sectionIndex,
    00104                        const geom::LineSegment& candidateSeg);
    00105
    00106         bool hasBadInputIntersection(const TaggedLineString* parentLine,
    00107                        const std::vector<size_t>& sectionIndex,
    00108                        const geom::LineSegment& candidateSeg);
    00109
    00110         bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
    00111
    00112         bool hasInteriorIntersection(const geom::LineSegment& seg0,
    00113                         const geom::LineSegment& seg1) const;
    00114
    00115         std::auto_ptr<TaggedLineSegment> flatten(
    00116                         size_t start, size_t end);
    00117
    00126         static bool isInLineSection(
    00127                 const TaggedLineString* parentLine,
    00128                 const std::vector<size_t>& sectionIndex,
    00129                 const TaggedLineSegment* seg);
    00130
    00139         void remove(const TaggedLineString* line,
    00140                         size_t start,
    00141                         size_t end);
    00142
    00143 };
    00144
    00145 inline void
    00146 TaggedLineStringSimplifier::setDistanceTolerance(double d)
    00147 {
    00148         distanceTolerance = d;
    00149 }
    00150
    00151 } // namespace geos::simplify
    00152 } // namespace geos
    00153
    00154 #endif // _GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H_
    00155
    00156 /**********************************************************************
    00157  * $Log$
    00158  * Revision 1.3  2006/04/13 21:52:34  strk
    00159  * Many debugging lines and assertions added. Fixed bug in TaggedLineString class.
    00160  *
    00161  * Revision 1.2  2006/04/13 10:39:12  strk
    00162  * Initial implementation of TaggedLinesSimplifier class
    00163  *
    00164  * Revision 1.1  2006/04/12 17:19:57  strk
    00165  * Ported TaggedLineStringSimplifier class, made LineSegment class
    00166  * polymorphic to fix derivation of TaggedLineSegment
    00167  *
    00168  **********************************************************************/