private Point CopyPoint(Point pt)
        {
            // if pm is floating, the point coordinate is not changed
            if (OverlayUtility.IsFloating(_pm))
            {
                return((Point)pt.Copy());
            }

            // pm is fixed.  Round off X&Y ordinates, copy other ordinates unchanged
            var seq  = pt.CoordinateSequence;
            var seq2 = seq.Copy();

            seq2.SetOrdinate(0, Ordinate.X, _pm.MakePrecise(seq.GetX(0)));
            seq2.SetOrdinate(0, Ordinate.Y, _pm.MakePrecise(seq.GetY(0)));
            return(_geometryFactory.CreatePoint(seq2));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unions a collection of geometries
        /// using a given precision model.
        /// <para/>
        /// This class is most useful for performing UnaryUnion using
        /// a fixed-precision model.
        /// For unary union using floating precision,
        /// <see cref="OverlayNGRobust.Union(Geometry)"/> should be used.
        /// </summary>
        /// <param name="geom">The geometry to union</param>
        /// <param name="pm">The precision model to use</param>
        /// <returns>The union of the geometries</returns>
        /// <seealso cref="OverlayNGRobust"/>
        public static Geometry Union(Geometry geom, PrecisionModel pm)
        {
            if (geom == null)
            {
                throw new ArgumentNullException(nameof(geom));
            }

            var unionSRFun = new UnionStrategy((g0, g1) =>
                                               OverlayNG.Overlay(g0, g1, SpatialFunction.Union, pm), OverlayUtility.IsFloating(pm));

            var op = new UnaryUnionOp(geom)
            {
                UnionStrategy = unionSRFun
            };

            return(op.Union());
        }