/// <summary> /// Get the z values and populate each one of them in Coordinate.Z /// If there are M values, return an array with those. /// </summary> /// <param name="file">The reader</param> /// <param name="totalRecordLength">Total number of bytes in this record</param> /// <param name="currentlyReadBytes">How many bytes are read from this record</param> /// <param name="buffer">The coordinate buffer</param> /// <param name="skippedList">A list of indices which have not been added to the buffer</param> protected void GetZMValues(BigEndianBinaryReader file, int totalRecordLength, ref int currentlyReadBytes, ICoordinateBuffer buffer, HS skippedList = null) { if (skippedList == null) skippedList = new HS(); var numPoints = buffer.Capacity; if (HasZValue()) { boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); var numSkipped = 0; for (var i = 0; i < numPoints; i++) { var z = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); if (!skippedList.Contains(i)) buffer.SetZ(i-numSkipped, z); else numSkipped++; } } // Trond: Note that M value is always optional per the shapefile spec. So we need to test total read record bytes // v.s. read bytes to see if we have them or not // Also: If we have Z we might have M. Per shapefile defn. if ((HasMValue() || HasZValue()) && currentlyReadBytes < totalRecordLength) { boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); var numSkipped = 0; for (var i = 0; i < numPoints; i++) { var m = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); if (!skippedList.Contains(i)) buffer.SetM(i - numSkipped, m); else numSkipped++; } } if (currentlyReadBytes < totalRecordLength) { int remaining = totalRecordLength - currentlyReadBytes; file.ReadBytes(remaining * 2); } }
/// <summary> /// Get the z values and populate each one of them in Coordinate.Z /// If there are M values, return an array with those. /// </summary> /// <param name="file">The reader</param> /// <param name="totalRecordLength">Total number of bytes in this record</param> /// <param name="currentlyReadBytes">How many bytes are read from this record</param> /// <param name="buffer">The coordinate buffer</param> /// <param name="skippedList">A list of indices which have not been added to the buffer</param> protected void GetZMValues(BigEndianBinaryReader file, int totalRecordLength, ref int currentlyReadBytes, ICoordinateBuffer buffer, HS skippedList = null) { if (skippedList == null) { skippedList = new HS(); } var numPoints = buffer.Capacity; if (HasZValue()) { boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); var numSkipped = 0; for (var i = 0; i < numPoints; i++) { var z = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); if (!skippedList.Contains(i)) { buffer.SetZ(i - numSkipped, z); } else { numSkipped++; } } } // Trond: Note that M value is always optional per the shapefile spec. So we need to test total read record bytes // v.s. read bytes to see if we have them or not // Also: If we have Z we might have M. Per shapefile defn. if ((HasMValue() || HasZValue()) && currentlyReadBytes < totalRecordLength) { boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); boundingBox[boundingBoxIndex++] = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); var numSkipped = 0; for (var i = 0; i < numPoints; i++) { var m = ReadDouble(file, totalRecordLength, ref currentlyReadBytes); if (!skippedList.Contains(i)) { buffer.SetM(i - numSkipped, m); } else { numSkipped++; } } } if (currentlyReadBytes < totalRecordLength) { int remaining = totalRecordLength - currentlyReadBytes; file.ReadBytes(remaining * 2); } }