Quotes around otherwise ambiguous (underline containing) name
[geos.git] / src / operation / overlay / snap / SnapOverlayOp.cpp
blob9f9431a1f9a686773dcd4cdcc8e19fe87e9a046a
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2009 Sandro Santilli <strk@kbt.io>
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 ***********************************************************************
15 * Last port: operation/overlay/snap/SnapOverlayOp.java r320 (JTS-1.12)
17 **********************************************************************/
19 #include <geos/operation/overlay/snap/SnapOverlayOp.h>
20 #include <geos/operation/overlay/snap/GeometrySnapper.h>
21 #include <geos/precision/CommonBitsRemover.h>
22 #include <geos/geom/Geometry.h>
24 #include <cassert>
25 #include <limits> // for numeric_limits
26 #include <memory> // for auto_ptr
28 #ifndef GEOS_DEBUG
29 #define GEOS_DEBUG 0
30 #endif
32 using namespace std;
33 using namespace geos::geom;
35 namespace geos {
36 namespace operation { // geos.operation
37 namespace overlay { // geos.operation.overlay
38 namespace snap { // geos.operation.overlay.snap
40 /* private */
41 void
42 SnapOverlayOp::computeSnapTolerance()
44 snapTolerance = GeometrySnapper::computeOverlaySnapTolerance(geom0,
45 geom1);
47 // cout << "Snap tol = " << snapTolerance << endl;
50 /* public */
51 auto_ptr<Geometry>
52 SnapOverlayOp::getResultGeometry(OverlayOp::OpCode opCode)
54 geom::GeomPtrPair prepGeom;
55 snap(prepGeom);
56 GeomPtr result ( OverlayOp::overlayOp(prepGeom.first.get(),
57 prepGeom.second.get(), opCode) );
58 prepareResult(*result);
59 return result;
62 /* private */
63 void
64 SnapOverlayOp::snap(geom::GeomPtrPair& snapGeom)
66 geom::GeomPtrPair remGeom;
67 removeCommonBits(geom0, geom1, remGeom);
69 GeometrySnapper::snap(*remGeom.first, *remGeom.second,
70 snapTolerance, snapGeom);
72 // MD - may want to do this at some point, but it adds cycles
73 // checkValid(snapGeom[0]);
74 // checkValid(snapGeom[1]);
77 System.out.println("Snapped geoms: ");
78 System.out.println(snapGeom[0]);
79 System.out.println(snapGeom[1]);
84 /* private */
85 void
86 SnapOverlayOp::removeCommonBits(const geom::Geometry& geom0,
87 const geom::Geometry& geom1,
88 geom::GeomPtrPair& remGeom)
90 cbr.reset(new precision::CommonBitsRemover());
91 cbr->add(&geom0);
92 cbr->add(&geom1);
94 remGeom.first.reset( cbr->removeCommonBits(geom0.clone()) );
95 remGeom.second.reset( cbr->removeCommonBits(geom1.clone()) );
98 /*private*/
99 void
100 SnapOverlayOp::prepareResult(geom::Geometry& geom)
102 cbr->addCommonBits(&geom);
106 } // namespace geos.operation.snap
107 } // namespace geos.operation.overlay
108 } // namespace geos.operation
109 } // namespace geos