GEOS: LineStringSnapper.h Source File

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

- File List

# LineStringSnapper.h

    00001 /**********************************************************************
    00002  * $Id: LineStringSnapper.h 3225 2011-02-21 14:02:37Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2009-2010  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/LineStringSnapper.java r320 (JTS-1.12)
    00018  *
    00019  **********************************************************************/
    00020
    00021 #ifndef GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
    00022 #define GEOS_OP_OVERLAY_SNAP_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 operation { // geos::operation
    00042 namespace overlay { // geos::operation::overlay
    00043 namespace snap { // geos::operation::overlay::snap
    00044
    00052 class GEOS_DLL LineStringSnapper {
    00053
    00054 public:
    00055
    00063         LineStringSnapper(const geom::Coordinate::Vect& nSrcPts,
    00064                                                   double nSnapTol)
    00065                 :
    00066                 srcPts(nSrcPts),
    00067                 snapTolerance(nSnapTol),
    00068                 allowSnappingToSourceVertices(false)
    00069         {
    00070                 size_t s = srcPts.size();
    00071                 isClosed = s < 2 ? false : srcPts[0].equals2D(srcPts[s-1]);
    00072         }
    00073
    00074         // Snap points are assumed to be all distinct points (a set would be better, uh ?)
    00075         std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
    00076
    00077         void setAllowSnappingToSourceVertices(bool allow) {
    00078                 allowSnappingToSourceVertices = allow;
    00079         }
    00080
    00081 private:
    00082
    00083         const geom::Coordinate::Vect& srcPts;
    00084
    00085         double snapTolerance;
    00086
    00087         bool allowSnappingToSourceVertices;
    00088         bool isClosed;
    00089
    00090
    00091         // Modifies first arg
    00092         void snapVertices(geom::CoordinateList& srcCoords,
    00093                         const geom::Coordinate::ConstVect& snapPts);
    00094
    00095
    00096         // Returns snapPts.end() if no snap point is close enough (within snapTol distance)
    00097         geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
    00098                         const geom::Coordinate::ConstVect& snapPts);
    00099
    00115   void snapSegments(geom::CoordinateList& srcCoords,
    00116                     const geom::Coordinate::ConstVect& snapPts);
    00117
    00121         //
    00145         geom::CoordinateList::iterator findSegmentToSnap(
    00146                         const geom::Coordinate& snapPt,
    00147                         geom::CoordinateList::iterator from,
    00148                         geom::CoordinateList::iterator too_far);
    00149
    00150     // Declare type as noncopyable
    00151     LineStringSnapper(const LineStringSnapper& other);
    00152     LineStringSnapper& operator=(const LineStringSnapper& rhs);
    00153 };
    00154
    00155
    00156 } // namespace geos::operation::overlay::snap
    00157 } // namespace geos::operation::overlay
    00158 } // namespace geos::operation
    00159 } // namespace geos
    00160
    00161 #endif // GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
    00162