• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

LineStringSnapper.h

00001 /**********************************************************************
00002  * $Id: LineStringSnapper.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/lineStringSnapper.java rev 1.5 (JTS-1.10)
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         {
00069                 size_t s = srcPts.size();
00070                 isClosed = ( s < 2 || srcPts[0].equals2D(srcPts[s-1]) );
00071         }
00072 
00073         // Snap points are assumed to be all distinct points (a set would be better, uh ?)
00074         std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
00075 
00076 private:
00077 
00078         const geom::Coordinate::Vect& srcPts;
00079 
00080         double snapTolerance;
00081 
00082         bool isClosed;
00083 
00084 
00085         // Modifies first arg
00086         void snapVertices(geom::CoordinateList& srcCoords,
00087                         const geom::Coordinate::ConstVect& snapPts);
00088 
00089 
00090         // Returns snapPts.end() if no snap point is close enough (within snapTol distance)
00091         geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
00092                         const geom::Coordinate::ConstVect& snapPts);
00093 
00094         // Modifies first arg
00095         void snapSegments(geom::CoordinateList& srcCoords,
00096                         const geom::Coordinate::ConstVect& snapPts);
00097 
00101         //
00119         geom::CoordinateList::iterator findSegmentToSnap(
00120                         const geom::Coordinate& snapPt,
00121                         geom::CoordinateList::iterator from,
00122                         geom::CoordinateList::iterator too_far);
00123 
00124     // Declare type as noncopyable
00125     LineStringSnapper(const LineStringSnapper& other);
00126     LineStringSnapper& operator=(const LineStringSnapper& rhs);
00127 };
00128 
00129 
00130 } // namespace geos::operation::overlay::snap
00131 } // namespace geos::operation::overlay
00132 } // namespace geos::operation
00133 } // namespace geos
00134 
00135 #endif // GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00136 

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1