private ShapeIndexList ParseIndex(string shx) { using (BinaryReader reader = new BinaryReader(File.OpenRead(shx))) { ShapeIndexList list = new ShapeIndexList(); byte[] headerArray = new byte[100]; int read = reader.Read(headerArray, 0, 100); list.FileCode = ReadInt(headerArray, 0, false); list.FileLength = ReadInt(headerArray, 24, false); list.Version = ReadInt(headerArray, 28, true); list.GlobalShapeType = (GeometryType)ReadInt(headerArray, 32, true); list.XMin = ReadDouble(headerArray, 36, true); list.YMin = ReadDouble(headerArray, 44, true); list.XMax = ReadDouble(headerArray, 52, true); list.YMax = ReadDouble(headerArray, 60, true); list.ZMin = ReadDouble(headerArray, 68, true); list.ZMax = ReadDouble(headerArray, 76, true); list.MMin = ReadDouble(headerArray, 84, true); list.MMax = ReadDouble(headerArray, 92, true); byte[] recordHeader = new byte[8]; while (reader.Read(recordHeader, 0, 8) != 0) { ShapeIndex shapeIndex = new ShapeIndex(); shapeIndex.Offset = ReadInt(recordHeader, 0, false); shapeIndex.ContentLength = ReadInt(recordHeader, 4, false); list.Add(shapeIndex); } return(list); } }
public ShapeIndex ShapeIndexToBlockIndex(ShapeIndex index) { index.x = (Mathf.Abs(index.x)) / MapBlock.BLOCK_SIZE; index.z = (Mathf.Abs(index.z)) / MapBlock.BLOCK_SIZE; index.y = (Mathf.Abs(index.y)) / MapBlock.BLOCK_HEIGHT; return(index); }
public MapBlock CreateOrGetBlock(WorldSpaceType type, ShapeIndex block_index) { MapBlock block = null; var block_array = GetMapBlocks(type); if (block_array != null) { int array_index = GetBlockArrayIndex(block_index); if (block_array.Length <= array_index) { int len = (block_index.z + EXPAND_BLOCK_SIZE) * BLOCKMAP_SIZE * BLOCKMAP_SIZE; MapBlock[] bs = new MapBlock[len]; Array.Copy(block_array, bs, block_array.Length); SetMapBlocks(type, bs); block_array = bs; } block = block_array[array_index]; if (block == null) { block = new MapBlock(); block.SpaceType = type; block.Index = block_index; block.Init(); block_array[array_index] = block; } } return(block); }
public int SwicthWorldIndexToBlock(ShapeIndex index) { int data_start = Mathf.Abs(index.y) % (BLOCK_HEIGHT); int cell_start = Mathf.Abs(index.z) % (BLOCK_SIZE); int row_start = Mathf.Abs(index.x) % (BLOCK_SIZE); return(BLOCK_SIZE * BLOCK_SIZE * data_start + row_start * BLOCK_SIZE + cell_start); }
public int GetBlockArrayIndex(ShapeIndex block_index) { int z = block_index.y * BLOCKMAP_SIZE * BLOCKMAP_SIZE; int cell = block_index.z; int row = block_index.x * BLOCKMAP_SIZE; return(z + row + cell); }
public ShapeInfo GetShape(ShapeIndex index) { int i = SwicthWorldIndexToBlock(index); if (i > 0) { return(m_Shapes[i]); } return(null); }
public void AddShapeInfo(ShapeInfo info) { ShapeIndex index = ShapeIndexToBlockIndex(info.Index); MapBlock block = CreateOrGetBlock(info.SpaceType, index); if (block != null) { block.AddShape(info); } }
/// <summary> /// Forces the geometry to update its envelope, and then updates the cached envelope of the feature. /// </summary> public void UpdateEnvelope() { if (_basicGeometry == null) { return; } _basicGeometry.UpdateEnvelope(); if (ShapeIndex != null) { ShapeIndex.CalculateExtents(); //Changed by jany_ (2015-07-09) must be updated because sometimes ShapeIndizes are used although IndexMode is false } }
public MapBlock GetMapBlock(WorldSpaceType type, ShapeIndex index) { var block_array = GetMapBlocks(type); if (block_array != null) { int array_index = GetBlockArrayIndex(index); if (array_index >= 0 && array_index < block_array.Length) { return(block_array[array_index]); } } return(null); }
public bool RemoveShape(ShapeIndex index) { int i = SwicthWorldIndexToBlock(index); if (i > 0) { var shape = m_Shapes[i]; m_Shapes[i] = null; if (shape != null) { Count--; return(true); } } return(false); }
public override int GetHashCode() { int hash = 1; if (ArgIndex != 0) { hash ^= ArgIndex.GetHashCode(); } if (ShapeIndex != 0) { hash ^= ShapeIndex.GetHashCode(); } if (PaddingArgIndex != 0) { hash ^= PaddingArgIndex.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void UpdatePosition(ShapeIndex index) { this.transform.position = index; }
public Record <T> GetShape <T>(string sourceName, BaseShapeParser <T> parser, ShapeIndex index) { using (BinaryReader reader = new BinaryReader(File.OpenRead(sourceName + ".shp"))) { byte[] bytesHeader = new byte[8]; byte[] bytesRecord = new byte[2 * index.ContentLength]; reader.BaseStream.Seek(2 * index.Offset, SeekOrigin.Begin); reader.Read(bytesHeader, 0, 8); var recordNumber = ReadInt(bytesHeader, 0, false); var contentLength = ReadInt(bytesHeader, 4, false); reader.Read(bytesRecord, 0, 2 * index.ContentLength); T shape = parser.Parse(bytesRecord, ReadInt, ReadDouble); Record <T> record = new Record <T>(recordNumber, shape, index.Metadatas); return(record); } }
public MapBlock GetMapBlock(ShapeInfo info) { ShapeIndex index = ShapeIndexToBlockIndex(info.Index); return(GetMapBlock(info.SpaceType, index)); }