GEOS 3.2.2
|
00001 /********************************************************************** 00002 * $Id: GeometrySnapper.h 2809 2009-12-06 01:05:24Z mloskot $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2009 Sandro Santilli <strk@keybit.net> 00008 * Copyright (C) 2006 Refractions Research Inc. 00009 * 00010 * This is free software; you can redistribute and/or modify it under 00011 * the terms of the GNU Lesser General Public Licence as published 00012 * by the Free Software Foundation. 00013 * See the COPYING file for more information. 00014 * 00015 *********************************************************************** 00016 * 00017 * Last port: operation/overlay/snap/GeometrySnapper.java rev 1.8 (JTS-1.10) 00018 * 00019 **********************************************************************/ 00020 00021 #ifndef GEOS_OP_OVERLAY_SNAP_GEOMETRYSNAPPER_H 00022 #define GEOS_OP_OVERLAY_SNAP_GEOMETRYSNAPPER_H 00023 00024 #include <geos/geom/Coordinate.h> 00025 00026 #include <memory> 00027 #include <vector> 00028 00029 // Forward declarations 00030 namespace geos { 00031 namespace geom { 00032 //class PrecisionModel; 00033 class Geometry; 00034 class CoordinateSequence; 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 00047 class GEOS_DLL GeometrySnapper { 00048 00049 public: 00050 00051 typedef std::auto_ptr<geom::Geometry> GeomPtr; 00052 typedef std::pair<GeomPtr, GeomPtr> GeomPtrPair; 00053 00063 static void snap(const geom::Geometry& g0, 00064 const geom::Geometry& g1, 00065 double snapTolerance, GeomPtrPair& ret); 00066 00072 GeometrySnapper(const geom::Geometry& g) 00073 : 00074 srcGeom(g) 00075 { 00076 } 00077 00087 std::auto_ptr<geom::Geometry> snapTo(const geom::Geometry& g, 00088 double snapTolerance); 00089 00097 static double computeOverlaySnapTolerance(const geom::Geometry& g); 00098 00099 static double computeSizeBasedSnapTolerance(const geom::Geometry& g); 00100 00104 static double computeOverlaySnapTolerance(const geom::Geometry& g1, 00105 const geom::Geometry& g2); 00106 00107 00108 private: 00109 00110 // eventually this will be determined from the geometry topology 00111 //static const double snapTol; // = 0.000001; 00112 00113 static const double snapPrecisionFactor; // = 10e-10 00114 00115 const geom::Geometry& srcGeom; 00116 00118 std::auto_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates( 00119 const geom::Geometry& g); 00120 00121 // Declare type as noncopyable 00122 GeometrySnapper(const GeometrySnapper& other); 00123 GeometrySnapper& operator=(const GeometrySnapper& rhs); 00124 }; 00125 00126 00127 } // namespace geos::operation::overlay::snap 00128 } // namespace geos::operation::overlay 00129 } // namespace geos::operation 00130 } // namespace geos 00131 00132 #endif // GEOS_OP_OVERLAY_SNAP_GEOMETRYSNAPPER_H 00133