public IPointCloudBinarySource CreateSparseSegment(PointCloudBinarySourceEnumeratorSparseRegion regions)
        {
            var regionSegments = new List <IPointCloudBinarySource>();

            foreach (var region in regions)
            {
                long pointIndex = (long)regions.PointsPerChunk * region.ChunkStart;
                long pointCount = (long)regions.PointsPerChunk * region.ChunkCount;

                if (pointIndex + pointCount > Count)
                {
                    long diff = pointIndex + pointCount - Count;
                    if (diff < regions.PointsPerChunk)
                    {
                        pointCount -= diff;
                    }
                    else
                    {
                        throw new Exception("right off the end");
                    }
                }

                var regionSegment = CreateSegment(pointIndex, pointCount);
                regionSegments.Add(regionSegment);
            }

            var sparseComposite = new PointCloudBinarySourceComposite(FileHandler, Extent, regionSegments.ToArray());

            return(sparseComposite);
        }
        public IPointCloudBinarySource CreateSparseSegment(PointCloudBinarySourceEnumeratorSparseRegion regions)
        {
            // break into segments that do not span files
            var regionSegments = new List <IPointCloudBinarySource>();

            foreach (var region in regions)
            {
                long pointIndex           = regions.PointsPerChunk * region.ChunkStart;
                long pointCount           = regions.PointsPerChunk * region.ChunkCount;
                var  regionSegmentSources = CreateSegmentSources(pointIndex, pointCount);
                regionSegments.AddRange(regionSegmentSources);
            }

            var sparseComposite = new PointCloudBinarySourceComposite(FileHandler, Extent, regionSegments.ToArray());

            return(sparseComposite);
        }