GeometrySnapper.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2009-2010  Sandro Santilli <strk@keybit.net>
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 Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  ***********************************************************************
00015  *
00016  * Last port: operation/overlay/snap/GeometrySnapper.java r320 (JTS-1.12)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_OP_OVERLAY_SNAP_GEOMETRYSNAPPER_H
00021 #define GEOS_OP_OVERLAY_SNAP_GEOMETRYSNAPPER_H
00022 
00023 #include <geos/geom/Coordinate.h>
00024 
00025 #include <memory>
00026 #include <vector>
00027 
00028 // Forward declarations
00029 namespace geos {
00030         namespace geom { 
00031                 //class PrecisionModel;
00032                 class Geometry;
00033                 class CoordinateSequence;
00034                 struct GeomPtrPair;
00035         }
00036 }
00037 
00038 namespace geos {
00039 namespace operation { // geos::operation
00040 namespace overlay { // geos::operation::overlay
00041 namespace snap { // geos::operation::overlay::snap
00042 
00058 class GEOS_DLL GeometrySnapper {
00059 
00060 public:
00061 
00062         typedef std::auto_ptr<geom::Geometry> GeomPtr;
00063 
00073         static void snap(const geom::Geometry& g0,
00074                                 const geom::Geometry& g1,
00075                                 double snapTolerance, geom::GeomPtrPair& ret);
00076 
00077         static GeomPtr snapToSelf(const geom::Geometry& g0,
00078                                 double snapTolerance, bool cleanResult);
00079 
00085         GeometrySnapper(const geom::Geometry& g)
00086                 :
00087                 srcGeom(g)
00088         {
00089         }
00090 
00100         std::auto_ptr<geom::Geometry> snapTo(const geom::Geometry& g,
00101                                              double snapTolerance);
00102 
00112         std::auto_ptr<geom::Geometry> snapToSelf(double snapTolerance,
00113                                                  bool cleanResult);
00114 
00122         static double computeOverlaySnapTolerance(const geom::Geometry& g);
00123 
00124         static double computeSizeBasedSnapTolerance(const geom::Geometry& g);
00125 
00129         static double computeOverlaySnapTolerance(const geom::Geometry& g1,
00130                         const geom::Geometry& g2);
00131 
00132 
00133 private:
00134 
00135         // eventually this will be determined from the geometry topology
00136         //static const double snapTol; //  = 0.000001;
00137 
00138         static const double snapPrecisionFactor; //  = 10e-10
00139 
00140         const geom::Geometry& srcGeom;
00141 
00143         std::auto_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates(
00144                         const geom::Geometry& g);
00145 
00146     // Declare type as noncopyable
00147     GeometrySnapper(const GeometrySnapper& other);
00148     GeometrySnapper& operator=(const GeometrySnapper& rhs);
00149 };
00150 
00151 
00152 } // namespace geos::operation::overlay::snap
00153 } // namespace geos::operation::overlay
00154 } // namespace geos::operation
00155 } // namespace geos
00156 
00157 #endif // GEOS_OP_OVERLAY_SNAP_GEOMETRYSNAPPER_H
00158 

Generated on 23 Sep 2013 for GEOS by  doxygen 1.4.7