GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2006 Refractions Research Inc. 00007 * 00008 * This is free software; you can redistribute and/or modify it under 00009 * the terms of the GNU Lesser General Licence as published 00010 * by the Free Software Foundation. 00011 * See the COPYING file for more information. 00012 * 00013 ********************************************************************** 00014 * 00015 * Last port: simplify/DouglasPeuckerLineSimplifier.java rev. 1.4 00016 * 00017 **********************************************************************/ 00018 00019 #ifndef GEOS_SIMPLIFY_DOUBGLASPEUCKERLINESIMPLIFIER_H 00020 #define GEOS_SIMPLIFY_DOUBGLASPEUCKERLINESIMPLIFIER_H 00021 00022 #include <geos/export.h> 00023 #include <vector> 00024 #include <memory> // for auto_ptr 00025 00026 #ifdef _MSC_VER 00027 #pragma warning(push) 00028 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00029 #endif 00030 00031 // Forward declarations 00032 namespace geos { 00033 namespace geom { 00034 class Coordinate; 00035 } 00036 } 00037 00038 namespace geos { 00039 namespace simplify { // geos::simplify 00040 00045 class GEOS_DLL DouglasPeuckerLineSimplifier { 00046 00047 public: 00048 00049 typedef std::vector<short int> BoolVect; 00050 typedef std::auto_ptr<BoolVect> BoolVectAutoPtr; 00051 00052 typedef std::vector<geom::Coordinate> CoordsVect; 00053 typedef std::auto_ptr<CoordsVect> CoordsVectAutoPtr; 00054 00055 00060 static CoordsVectAutoPtr simplify( 00061 const CoordsVect& nPts, 00062 double distanceTolerance); 00063 00064 DouglasPeuckerLineSimplifier(const CoordsVect& nPts); 00065 00074 void setDistanceTolerance(double nDistanceTolerance); 00075 00080 CoordsVectAutoPtr simplify(); 00081 00082 private: 00083 00084 const CoordsVect& pts; 00085 BoolVectAutoPtr usePt; 00086 double distanceTolerance; 00087 00088 void simplifySection(std::size_t i, std::size_t j); 00089 00090 // Declare type as noncopyable 00091 DouglasPeuckerLineSimplifier(const DouglasPeuckerLineSimplifier& other); 00092 DouglasPeuckerLineSimplifier& operator=(const DouglasPeuckerLineSimplifier& rhs); 00093 }; 00094 00095 } // namespace geos::simplify 00096 } // namespace geos 00097 00098 #ifdef _MSC_VER 00099 #pragma warning(pop) 00100 #endif 00101 00102 #endif // GEOS_SIMPLIFY_DOUBGLASPEUCKERLINESIMPLIFIER_H