Пример #1
0
        /// <summary>
        ///  Snaps the vertices in the component <see cref="ILineString" />s
        ///  of the source geometry to the vertices of the given snap geometry.
        /// </summary>
        /// <param name="g">a geometry to snap the source to</param>
        /// <param name="tolerance"></param>
        /// <returns>a new snapped Geometry</returns>
        public IGeometry SnapTo(IGeometry g, double tolerance)
        {
            var snapPts = ExtractTargetCoordinates(g);

            var snapTrans = new SnapTransformer(tolerance, snapPts);

            return(snapTrans.Transform(_srcGeom));
        }
Пример #2
0
        /// Snaps the vertices in the component <see cref="ILineString" />s
        /// of the source geometry to the vertices of the same geometry.
        /// Allows optionally cleaning the result to ensure it is topologically valid
        /// (which fixes issues such as topology collapses in polygonal inputs).
        /// <param name="snapTolerance">The snapping tolerance</param>
        /// <param name="cleanResult">Whether the result should be made valid</param>
        /// <returns>The geometry snapped to itself</returns>
        public IGeometry SnapToSelf(double snapTolerance, bool cleanResult)
        {
            var snapPts = ExtractTargetCoordinates(_srcGeom);

            var snapTrans   = new SnapTransformer(snapTolerance, snapPts, true);
            var snappedGeom = snapTrans.Transform(_srcGeom);
            var result      = snappedGeom;

            if (cleanResult && result is IPolygonal)
            {
                // TODO: use better cleaning approach
                result = snappedGeom.Buffer(0);
            }
            return(result);
        }
Пример #3
0
        /// Snaps the vertices in the component <see cref="ILineString" />s
        /// of the source geometry to the vertices of the same geometry.
        /// Allows optionally cleaning the result to ensure it is topologically valid
        /// (which fixes issues such as topology collapses in polygonal inputs).
        /// <param name="snapTolerance">The snapping tolerance</param>
        /// <param name="cleanResult">Whether the result should be made valid</param>
        /// <returns>The geometry snapped to itself</returns>
        public IGeometry SnapToSelf(double snapTolerance, bool cleanResult)
        {
            var snapPts = ExtractTargetCoordinates(_srcGeom);

            var snapTrans = new SnapTransformer(snapTolerance, snapPts, true);
            var snappedGeom = snapTrans.Transform(_srcGeom);
            var result = snappedGeom;
            if (cleanResult && result is IPolygonal)
            {
                // TODO: use better cleaning approach
                result = snappedGeom.Buffer(0);
            }
            return result;
        }
Пример #4
0
        /// <summary>
        ///  Snaps the vertices in the component <see cref="ILineString" />s
        ///  of the source geometry to the vertices of the given snap geometry.
        /// </summary>
        /// <param name="g">a geometry to snap the source to</param>
        /// <param name="tolerance"></param>
        /// <returns>a new snapped Geometry</returns>
        public IGeometry SnapTo(IGeometry g, double tolerance)
        {
            Coordinate[] snapPts = ExtractTargetCoordinates(g);

            SnapTransformer snapTrans = new SnapTransformer(tolerance, snapPts);
            return snapTrans.Transform(_srcGeom);
        }