private Geometry SelfSnap(Geometry geom)
        {
            var snapper0 = new GeometrySnapper(geom);
            var snapGeom = snapper0.SnapTo(geom, _snapTolerance);

            //System.out.println("Self-snapped: " + snapGeom);
            //System.out.println();
            return(snapGeom);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private Geometry[] Snap(Geometry[] geom)
        {
            var remGeom = RemoveCommonBits(geom);

            // MD - testing only
            // Geometry[] remGeom = geom;

            var snapGeom = GeometrySnapper.Snap(remGeom[0], remGeom[1], _snapTolerance);

            // MD - may want to do this at some point, but it adds cycles
            // CheckValid(snapGeom[0]);
            // CheckValid(snapGeom[1]);
            return(snapGeom);
        }
        /// <summary>
        /// Snaps two geometries together with a given tolerance.
        /// </summary>
        /// <param name="g0"></param>
        /// <param name="g1"></param>
        /// <param name="snapTolerance"></param>
        /// <returns></returns>
        public static Geometry[] Snap(Geometry g0, Geometry g1, double snapTolerance)
        {
            var snapGeom = new Geometry[2];

            var snapper0 = new GeometrySnapper(g0);

            snapGeom[0] = snapper0.SnapTo(g1, snapTolerance);

            /*
             * Snap the second geometry to the snapped first geometry
             * (this strategy minimizes the number of possible different points in the result)
             */
            var snapper1 = new GeometrySnapper(g1);

            snapGeom[1] = snapper1.SnapTo(snapGeom[0], snapTolerance);
            return(snapGeom);
        }
        /// <summary>
        /// Snaps a geometry to itself.
        /// Allows optionally cleaning the result to ensure it is topologically valid
        /// (which fixes issues such as topology collapses in polygonal inputs).
        /// Snapping a geometry to itself can remove artifacts such as very narrow slivers, gores and spikes.
        /// </summary>
        /// <param name="geom">the geometry to snap</param>
        /// <param name="snapTolerance">the snapping tolerance</param>
        /// <param name="cleanResult">whether the result should be made valid</param>
        /// <returns>a new snapped <see cref="Geometry"/></returns>
        public static Geometry SnapToSelf(Geometry geom, double snapTolerance, bool cleanResult)
        {
            var snapper0 = new GeometrySnapper(geom);

            return(snapper0.SnapToSelf(snapTolerance, cleanResult));
        }
 /// <summary>
 ///
 /// </summary>
 private void ComputeSnapTolerance()
 {
     _snapTolerance = GeometrySnapper.ComputeOverlaySnapTolerance(_geom[0], _geom[1]);
 }