# GeometrySnapper.h

    00001 /**********************************************************************
    00002  * $Id: GeometrySnapper.h 1948 2006-12-18 18:44:20Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    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 rev. 1.6
    00017  * (we should move in GEOS too, probably)
    00018  *
    00019  **********************************************************************/
    00020
    00021 #ifndef GEOS_PRECISION_GEOMETRYSNAPPER_H
    00022 #define GEOS_PRECISION_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 precision { // geos.precision
    00040
    00045 class GeometrySnapper {
    00046
    00047 public:
    00048
    00049         GeometrySnapper(const geom::Geometry& g)
    00050                 :
    00051                 srcGeom(g)
    00052         {
    00053         }
    00054
    00064         std::auto_ptr<geom::Geometry> snapTo(const geom::Geometry& g, double snapTolerance);
    00065
    00073         static double computeOverlaySnapTolerance(const geom::Geometry& g);
    00074
    00075         static double computeSizeBasedSnapTolerance(const geom::Geometry& g);
    00076
    00080         static double computeOverlaySnapTolerance(const geom::Geometry& g1,
    00081                         const geom::Geometry& g2);
    00082
    00083
    00084 private:
    00085
    00086         // eventually this will be determined from the geometry topology
    00087         //static const double snapTol; //  = 0.000001;
    00088
    00089         static const double snapPrecisionFactor; //  = 10e-10
    00090
    00091         const geom::Geometry& srcGeom;
    00092
    00094         std::auto_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates(
    00095                         const geom::Geometry& g);
    00096 };
    00097
    00098
    00099 } // namespace geos.precision
    00100 } // namespace geos
    00101
    00102 #endif // GEOS_PRECISION_GEOMETRYSNAPPER_H
    00103
    00104 /**********************************************************************
    00105  * $Log$
    00106  * Revision 1.1  2006/07/21 17:09:14  strk
    00107  * Added new precision::LineStringSnapper class + test
    00108  * and precision::GeometrySnapper (w/out test)
    00109  *
    00110  **********************************************************************/