- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# LineStringSnapper.h

    00001 /**********************************************************************
    00002  * $Id: LineStringSnapper.h 1940 2006-12-13 10:51:18Z 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/lineStringSnapper.java rev. 1.1
    00017  * (we should move in GEOS too, probably)
    00018  *
    00019  **********************************************************************/
    00020
    00021 #ifndef GEOS_PRECISION_LINESTRINGSNAPPER_H
    00022 #define GEOS_PRECISION_LINESTRINGSNAPPER_H
    00023
    00024 #include <geos/geom/Coordinate.h>
    00025 #include <geos/geom/CoordinateSequence.h>
    00026 #include <geos/geom/CoordinateList.h>
    00027
    00028 #include <memory>
    00029
    00030 // Forward declarations
    00031 namespace geos {
    00032         namespace geom {
    00033                 //class PrecisionModel;
    00034                 //class CoordinateSequence;
    00035                 class CoordinateList;
    00036                 class Geometry;
    00037         }
    00038 }
    00039
    00040 namespace geos {
    00041 namespace precision { // geos.precision
    00042
    00048 class LineStringSnapper {
    00049
    00050 public:
    00051
    00052         LineStringSnapper(const geom::Coordinate::Vect& nSrcPts, double nSnapTol)
    00053                 :
    00054                 srcPts(nSrcPts),
    00055                 snapTolerance(nSnapTol)
    00056         {
    00057                 size_t s = srcPts.size();
    00058                 isClosed = ( s < 2 || srcPts[0].equals2D(srcPts[s-1]) );
    00059         }
    00060
    00061         // Snap points are assumed to be all distinct points (a set would be better, uh ?)
    00062         std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
    00063
    00064 private:
    00065
    00066         const geom::Coordinate::Vect& srcPts;
    00067
    00068         double snapTolerance;
    00069
    00070         bool isClosed;
    00071
    00072
    00073         // Modifies first arg
    00074         void snapVertices(geom::CoordinateList& srcCoords,
    00075                         const geom::Coordinate::ConstVect& snapPts);
    00076
    00077
    00078         // Returns snapPts.end() if no snap point is close enough (within snapTol distance)
    00079         geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
    00080                         const geom::Coordinate::ConstVect& snapPts);
    00081
    00082         // Modifies first arg
    00083         void snapSegments(geom::CoordinateList& srcCoords,
    00084                         const geom::Coordinate::ConstVect& snapPts);
    00085
    00089         //
    00107         geom::CoordinateList::iterator findSegmentToSnap(
    00108                         const geom::Coordinate& snapPt,
    00109                         geom::CoordinateList::iterator from,
    00110                         geom::CoordinateList::iterator too_far);
    00111
    00112 };
    00113
    00114
    00115 } // namespace geos.precision
    00116 } // namespace geos
    00117
    00118 #endif // GEOS_PRECISION_LINESTRINGSNAPPER_H
    00119
    00120 /**********************************************************************
    00121  * $Log$
    00122  * Revision 1.1  2006/07/21 17:09:14  strk
    00123  * Added new precision::LineStringSnapper class + test
    00124  * and precision::GeometrySnapper (w/out test)
    00125  *
    00126  **********************************************************************/