예제 #1
0
        public virtual IPointCloudBinarySource CreateSegment(long pointIndex, long pointCount)
        {
            long offset  = PointDataOffset + pointIndex * PointSizeBytes;
            var  segment = new PointCloudBinarySource(FileHandler, pointCount, Extent, Quantization, offset, PointSizeBytes);

            return(segment);
        }
예제 #2
0
파일: LASFile.cs 프로젝트: PCLC7Z2/cloudae
        protected virtual IPointCloudBinarySource CreateBinaryWrapper()
        {
            // params I need?
            // (skip global encoding)
            // (skip file creation date)
            // vlrs
            // evlrs
            // attributes that make up point format
            // point count
            // quantization
            // extent
            // points by return

            // create parameters
            //Parameter<Extent3D>.Define("Extent", m_extent);
            //Parameter<SQuantization3D>.Define("Quantization", m_header.Quantization);
            //Parameter<ulong>.Define("PointCount", m_header.PointCount);

            var source = new PointCloudBinarySource(this, Count, m_extent, m_header.Quantization, PointDataOffset, PointSizeBytes);

            return(source);
        }
예제 #3
0
파일: XYZFile.cs 프로젝트: jdauie/cloudae
        public unsafe PointCloudBinarySource ConvertTextToBinary(string binaryPath, ProgressManager progressManager)
        {
            short pointSizeBytes = 3 * sizeof(double);

            double minX = 0, minY = 0, minZ = 0;
            double maxX = 0, maxY = 0, maxZ = 0;
            int pointCount = 0;

            using (var process = progressManager.StartProcess("ConvertTextToBinary"))
            {
                BufferInstance inputBuffer = process.AcquireBuffer(true);
                BufferInstance outputBuffer = process.AcquireBuffer(true);

                int pointsPerBuffer = outputBuffer.Length / pointSizeBytes;
                int usableBytesPerBuffer = pointsPerBuffer * pointSizeBytes;

                byte* inputBufferPtr = inputBuffer.DataPtr;
                byte* outputBufferPtr = outputBuffer.DataPtr;

                int bufferIndex = 0;
                int skipped = 0;

                using (var inputStream = StreamManager.OpenReadStream(FilePath))
                {
                    long inputLength = inputStream.Length;
                    long estimatedOutputLength = inputLength;

                    using (var outputStream = StreamManager.OpenWriteStream(binaryPath, estimatedOutputLength, 0, true))
                    {
                        int bytesRead;
                        int readStart = 0;

                        while ((bytesRead = inputStream.Read(inputBuffer.Data, readStart, inputBuffer.Length - readStart)) > 0)
                        {
                            bytesRead += readStart;
                            readStart = 0;
                            int i = 0;

                            while (i < bytesRead)
                            {
                                // identify line start
                                while (i < bytesRead && (inputBufferPtr[i] == '\r' || inputBufferPtr[i] == '\n'))
                                {
                                    ++i;
                                }

                                int lineStart = i;

                                // identify line end
                                while (i < bytesRead && inputBufferPtr[i] != '\r' && inputBufferPtr[i] != '\n')
                                {
                                    ++i;
                                }

                                // handle buffer overlap
                                if (i == bytesRead)
                                {
                                    Array.Copy(inputBuffer.Data, lineStart, inputBuffer.Data, 0, i - lineStart);
                                    readStart = i - lineStart;
                                    break;
                                }

                                // this may get overwritten if this is not a valid parse
                                double* p = (double*)(outputBufferPtr + bufferIndex);

                                if (!ParseXYZFromLine(inputBufferPtr, lineStart, i, p))
                                {
                                    ++skipped;
                                    continue;
                                }

                                if (pointCount == 0)
                                {
                                    minX = maxX = p[0];
                                    minY = maxY = p[1];
                                    minZ = maxZ = p[2];
                                }
                                else
                                {
                                    if (p[0] < minX) minX = p[0];
                                    else if (p[0] > maxX) maxX = p[0];
                                    if (p[1] < minY) minY = p[1];
                                    else if (p[1] > maxY) maxY = p[1];
                                    if (p[2] < minZ) minZ = p[2];
                                    else if (p[2] > maxZ) maxZ = p[2];
                                }

                                bufferIndex += pointSizeBytes;
                                ++pointCount;

                                // write usable buffer chunk
                                if (usableBytesPerBuffer == bufferIndex)
                                {
                                    outputStream.Write(outputBuffer.Data, 0, bufferIndex);
                                    bufferIndex = 0;
                                }
                            }

                            if (!process.Update((float)inputStream.Position / inputLength))
                                break;
                        }

                        // write remaining buffer
                        if (bufferIndex > 0)
                            outputStream.Write(outputBuffer.Data, 0, bufferIndex);
                    }
                }

                process.Log("Skipped {0} lines", skipped);
                process.LogTime("Copied {0:0,0} points", pointCount);
            }

            var extent = new Extent3D(minX, minY, minZ, maxX, maxY, maxZ);

            var source = new PointCloudBinarySource(this, pointCount, extent, null, 0, pointSizeBytes);

            return source;
        }
예제 #4
0
파일: LASFile.cs 프로젝트: jdauie/cloudae
        protected virtual IPointCloudBinarySource CreateBinaryWrapper()
        {
            // params I need?
            // (skip global encoding)
            // (skip file creation date)
            // vlrs
            // evlrs
            // attributes that make up point format
            // point count
            // quantization
            // extent
            // points by return

            // create parameters
            //Parameter<Extent3D>.Define("Extent", m_extent);
            //Parameter<SQuantization3D>.Define("Quantization", m_header.Quantization);
            //Parameter<ulong>.Define("PointCount", m_header.PointCount);

            var source = new PointCloudBinarySource(this, Count, m_extent, m_header.Quantization, PointDataOffset, PointSizeBytes);

            return source;
        }
예제 #5
0
 public virtual IPointCloudBinarySource CreateSegment(long pointIndex, long pointCount)
 {
     long offset = PointDataOffset + pointIndex * PointSizeBytes;
     var segment = new PointCloudBinarySource(FileHandler, pointCount, Extent, Quantization, offset, PointSizeBytes);
     return segment;
 }
예제 #6
0
        public unsafe PointCloudBinarySource ConvertTextToBinary(string binaryPath, ProgressManager progressManager)
        {
            short pointSizeBytes = 3 * sizeof(double);

            double minX = 0, minY = 0, minZ = 0;
            double maxX = 0, maxY = 0, maxZ = 0;
            int    pointCount = 0;

            using (var process = progressManager.StartProcess("ConvertTextToBinary"))
            {
                BufferInstance inputBuffer  = process.AcquireBuffer(true);
                BufferInstance outputBuffer = process.AcquireBuffer(true);

                int pointsPerBuffer      = outputBuffer.Length / pointSizeBytes;
                int usableBytesPerBuffer = pointsPerBuffer * pointSizeBytes;

                byte *inputBufferPtr  = inputBuffer.DataPtr;
                byte *outputBufferPtr = outputBuffer.DataPtr;

                int bufferIndex = 0;
                int skipped     = 0;

                using (var inputStream = StreamManager.OpenReadStream(FilePath))
                {
                    long inputLength           = inputStream.Length;
                    long estimatedOutputLength = inputLength;

                    using (var outputStream = StreamManager.OpenWriteStream(binaryPath, estimatedOutputLength, 0, true))
                    {
                        int bytesRead;
                        int readStart = 0;

                        while ((bytesRead = inputStream.Read(inputBuffer.Data, readStart, inputBuffer.Length - readStart)) > 0)
                        {
                            bytesRead += readStart;
                            readStart  = 0;
                            int i = 0;

                            while (i < bytesRead)
                            {
                                // identify line start
                                while (i < bytesRead && (inputBufferPtr[i] == '\r' || inputBufferPtr[i] == '\n'))
                                {
                                    ++i;
                                }

                                int lineStart = i;

                                // identify line end
                                while (i < bytesRead && inputBufferPtr[i] != '\r' && inputBufferPtr[i] != '\n')
                                {
                                    ++i;
                                }

                                // handle buffer overlap
                                if (i == bytesRead)
                                {
                                    Array.Copy(inputBuffer.Data, lineStart, inputBuffer.Data, 0, i - lineStart);
                                    readStart = i - lineStart;
                                    break;
                                }

                                // this may get overwritten if this is not a valid parse
                                double *p = (double *)(outputBufferPtr + bufferIndex);

                                if (!ParseXYZFromLine(inputBufferPtr, lineStart, i, p))
                                {
                                    ++skipped;
                                    continue;
                                }

                                if (pointCount == 0)
                                {
                                    minX = maxX = p[0];
                                    minY = maxY = p[1];
                                    minZ = maxZ = p[2];
                                }
                                else
                                {
                                    if (p[0] < minX)
                                    {
                                        minX = p[0];
                                    }
                                    else if (p[0] > maxX)
                                    {
                                        maxX = p[0];
                                    }
                                    if (p[1] < minY)
                                    {
                                        minY = p[1];
                                    }
                                    else if (p[1] > maxY)
                                    {
                                        maxY = p[1];
                                    }
                                    if (p[2] < minZ)
                                    {
                                        minZ = p[2];
                                    }
                                    else if (p[2] > maxZ)
                                    {
                                        maxZ = p[2];
                                    }
                                }

                                bufferIndex += pointSizeBytes;
                                ++pointCount;

                                // write usable buffer chunk
                                if (usableBytesPerBuffer == bufferIndex)
                                {
                                    outputStream.Write(outputBuffer.Data, 0, bufferIndex);
                                    bufferIndex = 0;
                                }
                            }

                            if (!process.Update((float)inputStream.Position / inputLength))
                            {
                                break;
                            }
                        }

                        // write remaining buffer
                        if (bufferIndex > 0)
                        {
                            outputStream.Write(outputBuffer.Data, 0, bufferIndex);
                        }
                    }
                }

                process.Log("Skipped {0} lines", skipped);
                process.LogTime("Copied {0:0,0} points", pointCount);
            }

            var extent = new Extent3D(minX, minY, minZ, maxX, maxY, maxZ);

            var source = new PointCloudBinarySource(this, pointCount, extent, null, 0, pointSizeBytes);

            return(source);
        }