Beispiel #1
0
        /// <summary>
        /// Gets the <see cref="IMultiPoint"/> containing the generated point
        /// </summary>
        /// <returns>A MultiPoint</returns>
        public override IGeometry GetGeometry()
        {
            var nCells = (int)Math.Sqrt(NumPoints) + 1;

            // ensure that at least numPts points are generated
            if (nCells * nCells < NumPoints)
            {
                nCells += 1;
            }

            var gridDX = Extent.Width / nCells;
            var gridDY = Extent.Height / nCells;

            var gutterFrac    = MathUtil.Clamp(GutterFraction, 0.0, 1.0);
            var gutterOffsetX = gridDX * gutterFrac / 2;
            var gutterOffsetY = gridDY * gutterFrac / 2;
            var cellFrac      = 1.0 - gutterFrac;
            var cellDX        = cellFrac * gridDX;
            var cellDY        = cellFrac * gridDY;

            var pts   = new Coordinate[nCells * nCells];
            var index = 0;

            for (var i = 0; i < nCells; i++)
            {
                for (var j = 0; j < nCells; j++)
                {
                    var orgX = Extent.MinX + i * gridDX + gutterOffsetX;
                    var orgY = Extent.MinY + j * gridDY + gutterOffsetY;
                    pts[index++] = RandomPointInCell(orgX, orgY, cellDX, cellDY);
                }
            }
            return(GeomFactory.CreateMultiPointFromCoords(pts));
        }
        public override IGeometry GetGeometry()
        {
            var pts = new Coordinate[NumPoints];
            int i   = 0;

            while (i < NumPoints)
            {
                var p = CreateRandomCoord(Extent);
                if (_extentLocator != null && !IsInExtent(p))
                {
                    continue;
                }
                pts[i++] = p;
            }
            return(GeomFactory.CreateMultiPointFromCoords(pts));
        }