public void WriteIndexNode(IndexNode indexNode) { indexOffsets.Add(indexNode.Id, indexFileStreamWriter.BaseStream.Position); indexFileStreamWriter.Write(indexNode.AdjacentNodes.Count); foreach (IndexAdjacentNode adjacentNode in indexNode.AdjacentNodes) { indexFileStreamWriter.Write(adjacentNode.Id); indexFileStreamWriter.Write(adjacentNode.Cost); } }
public void WriteIndexNode(IndexNode indexNode) { indexOffsets.Add(indexNode.Id, indexFileStreamWriter.BaseStream.Position); indexFileStreamWriter.Write(indexNode.AdjacentNodes.Count); foreach (IndexAdjacentNode adjacentNode in indexNode.AdjacentNodes) { indexFileStreamWriter.Write(adjacentNode.Id); indexFileStreamWriter.Write(adjacentNode.Cost); } }
public IndexNode ReadIndexNode(int nodeIndex) { int indexOffset = nodeIndex * 8; readingCache.SeekForward(indexOffset); // move the the position where record the position of adjacent ids. long recordPosition = readingCache.ReadLong(); readingCache.Seek(recordPosition); IndexNode indexNode = new IndexNode(nodeIndex); int adjacentCount = readingCache.ReadInt32(); for (int i = 0; i < adjacentCount; i++) { int id = readingCache.ReadInt32(); float cost = readingCache.ReadFloat(); indexNode.AdjacentNodes.Add(new IndexAdjacentNode(id, cost)); } return indexNode; }
public IndexNode ReadIndexNode(int nodeIndex) { int indexOffset = nodeIndex * 8; readingCache.SeekForward(indexOffset); // move the the position where record the position of adjacent ids. long recordPosition = readingCache.ReadLong(); readingCache.Seek(recordPosition); IndexNode indexNode = new IndexNode(nodeIndex); int adjacentCount = readingCache.ReadInt32(); for (int i = 0; i < adjacentCount; i++) { int id = readingCache.ReadInt32(); float cost = readingCache.ReadFloat(); indexNode.AdjacentNodes.Add(new IndexAdjacentNode(id, cost)); } return(indexNode); }
public void WriteIndexNode(IndexNode indexNode) { indexOffsets.Add(indexNode.Id, attributionFileStreamWriter.BaseStream.Position); attributionFileStreamWriter.Write(indexNode.AdjacentNodes.Count); Collection<int> recordOffsets = new Collection<int>(); int currentOffset = indexNode.AdjacentNodes.Count * 8; int currentFeatureIdLength = 0; foreach (IndexAdjacentNode adjacentNode in indexNode.AdjacentNodes) { attributionFileStreamWriter.Write(adjacentNode.Id); attributionFileStreamWriter.Write(currentOffset + currentFeatureIdLength); currentFeatureIdLength += adjacentNode.FeatureId.Length; } foreach (IndexAdjacentNode adjacentNode in indexNode.AdjacentNodes) { //attributionFileStreamWriter.Write(adjacentNode.FeatureId.Length); attributionFileStreamWriter.Write(adjacentNode.FeatureId); } }