GeometryPrecisionReducer.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2012 Sandro Santilli <strk@keybit.net>
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Public Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  ***********************************************************************
00014  *
00015  * Last port: precision/GeometryPrecisionReducer.cpp rev. 1.10 (JTS-1.7)
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H
00020 #define GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H
00021 
00022 #include <geos/export.h>
00023 #include <memory> // for auto_ptr
00024 
00025 // Forward declarations
00026 namespace geos {
00027   namespace geom { 
00028     class PrecisionModel;
00029     class GeometryFactory;
00030     class Geometry;
00031   }
00032 }
00033 
00034 namespace geos {
00035 namespace precision { // geos.precision
00036 
00042 class GEOS_DLL GeometryPrecisionReducer {
00043 
00044 private:
00045 
00046   // Externally owned
00047   const geom::GeometryFactory *newFactory;
00048 
00049   const geom::PrecisionModel &targetPM;
00050 
00051   bool removeCollapsed;
00052 
00053   bool isPointwise;
00054 
00055   std::auto_ptr<geom::Geometry> reducePointwise( const geom::Geometry& geom );
00056 
00057   std::auto_ptr<geom::Geometry> fixPolygonalTopology(
00058                                                  const geom::Geometry& geom );
00059 
00060   std::auto_ptr<geom::GeometryFactory> createFactory(
00061                                           const geom::GeometryFactory& oldGF,
00062                                           const geom::PrecisionModel& newPM );
00063 
00064   GeometryPrecisionReducer(GeometryPrecisionReducer const&); /*= delete*/
00065   GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
00066 
00067 public:
00068 
00080   static std::auto_ptr<geom::Geometry> reduce(
00081                                 const geom::Geometry &g,
00082                                 const geom::PrecisionModel &precModel )
00083   {
00084     GeometryPrecisionReducer reducer(precModel);
00085     return reducer.reduce(g);
00086   }
00087 
00099   static std::auto_ptr<geom::Geometry> reducePointwise(
00100                                 const geom::Geometry &g,
00101                                 const geom::PrecisionModel &precModel )
00102   {
00103     GeometryPrecisionReducer reducer(precModel);
00104     reducer.setPointwise(true);
00105     return reducer.reduce(g);
00106   }
00107 
00108   GeometryPrecisionReducer(const geom::PrecisionModel &pm)
00109       :
00110       newFactory(0),
00111       targetPM(pm),
00112       removeCollapsed(true),
00113       isPointwise(false)
00114   {}
00115 
00126   GeometryPrecisionReducer(const geom::GeometryFactory &gf);
00127 
00135   void setRemoveCollapsedComponents(bool remove) {
00136     removeCollapsed = remove;
00137   }
00138 
00150   void setPointwise(bool pointwise)
00151   {
00152     isPointwise = pointwise;
00153   }
00154 
00155   std::auto_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
00156 
00157 };
00158 
00159 } // namespace geos.precision
00160 } // namespace geos
00161 
00162 #endif // GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H

Generated on 30 Dec 2015 for GEOS by  doxygen 1.4.7