Fix TopologyPreservingSimplifier invalid output on closed line (#508)
[geos.git] / include / geos / simplify / TopologyPreservingSimplifier.h
blob9c4781988339d3adb3eaa8d5e06074934a7206e0
1 /**********************************************************************
2 * $Id$
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
7 * Copyright (C) 2006 Refractions Research Inc.
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
14 **********************************************************************
16 * Last port: simplify/TopologyPreservingSimplifier.java r536 (JTS-1.12+)
18 **********************************************************************
20 * NOTES:
22 **********************************************************************/
24 #ifndef GEOS_SIMPLIFY_TOPOLOGYPRESERVINGSIMPLIFIER_H
25 #define GEOS_SIMPLIFY_TOPOLOGYPRESERVINGSIMPLIFIER_H
27 #include <geos/export.h>
28 #include <geos/geom/Geometry.h>
29 #include <geos/simplify/TaggedLinesSimplifier.h>
30 #include <memory> // for auto_ptr
31 #include <map>
33 #ifdef _MSC_VER
34 #pragma warning(push)
35 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
36 #endif
38 namespace geos {
39 namespace simplify { // geos::simplify
41 /** \brief
43 * Simplifies a geometry, ensuring that
44 * the result is a valid geometry having the
45 * same dimension and number of components as the input.
47 * The simplification uses a maximum distance difference algorithm
48 * similar to the one used in the Douglas-Peucker algorithm.
50 * In particular, if the input is an areal geometry
51 * ( Polygon or MultiPolygon )
53 * - The result has the same number of shells and holes (rings) as the input,
54 * in the same order
55 * - The result rings touch at <b>no more</b> than the number of touching point in the input
56 * (although they may touch at fewer points)
59 class GEOS_DLL TopologyPreservingSimplifier
62 public:
64 static std::auto_ptr<geom::Geometry> simplify(
65 const geom::Geometry* geom,
66 double tolerance);
68 TopologyPreservingSimplifier(const geom::Geometry* geom);
70 /** \brief
71 * Sets the distance tolerance for the simplification.
73 * All vertices in the simplified geometry will be within this
74 * distance of the original geometry.
75 * The tolerance value must be non-negative. A tolerance value
76 * of zero is effectively a no-op.
78 * @param distanceTolerance the approximation tolerance to use
80 void setDistanceTolerance(double tolerance);
82 std::auto_ptr<geom::Geometry> getResultGeometry();
84 private:
86 const geom::Geometry* inputGeom;
88 std::auto_ptr<TaggedLinesSimplifier> lineSimplifier;
92 } // namespace geos::simplify
93 } // namespace geos
95 #ifdef _MSC_VER
96 #pragma warning(pop)
97 #endif
99 #endif // GEOS_SIMPLIFY_TOPOLOGYPRESERVINGSIMPLIFIER_H
101 /**********************************************************************
102 * $Log$
103 * Revision 1.3 2006/04/13 16:04:10 strk
104 * Made TopologyPreservingSimplifier implementation successfully build
106 * Revision 1.2 2006/04/13 14:25:17 strk
107 * TopologyPreservingSimplifier initial port
109 **********************************************************************/