예제 #1
0
        public static BasFeatureEntity Convert(BasEntity entity)
        {
            BasFeatureEntity basFeature = new BasFeatureEntity();

            basFeature.Offset = entity.Offset;
            ReadColumns(basFeature, entity.HeaderResult);
            ReadGeometry(basFeature, entity.CoordinatesResult);
            ReadAnnocation(basFeature, entity.AnnotationsResult);
            return(basFeature);
        }
예제 #2
0
        public BasFeatureEntity GetFeatureEntityByOffset(long offset)
        {
            BasFeatureEntity feature = null;

            basReader.BaseStream.Seek(offset, SeekOrigin.Begin);

            BasEntity entity = BasEntityParser.Parse(basReader);

            if (entity != null)
            {
                feature = BasEntityToFeatureEntityConverter.Convert(entity);
            }

            return(feature);
        }
예제 #3
0
        public Collection <BasFeatureEntity> GetAllFeatureEntities()
        {
            Collection <BasFeatureEntity> features = new Collection <BasFeatureEntity>();

            basReader.BaseStream.Seek(0, SeekOrigin.Begin);
            while (basReader.BaseStream.Position != -1 && basReader.BaseStream.Length - basReader.BaseStream.Position > 80)
            {
                BasEntity entity = BasEntityParser.Parse(basReader);

                if (entity != null)
                {
                    features.Add(BasEntityToFeatureEntityConverter.Convert(entity));
                }
            }
            return(features);
        }
예제 #4
0
        public Collection <string> GetColumns()
        {
            Collection <string> allColumns = new Collection <string>();

            basReader.BaseStream.Seek(0, SeekOrigin.Begin);
            BasEntity firstRecord = BasEntityParser.Parse(basReader);

            if (firstRecord != null)
            {
                foreach (var column in Enum.GetValues(typeof(BasDefaultColumns)))
                {
                    allColumns.Add(column.ToString());
                }
                foreach (var column in firstRecord.HeaderResult.VariableData.Keys)
                {
                    allColumns.Add(column);
                }
            }

            return(allColumns);
        }
예제 #5
0
        public static BasEntity Parse(BinaryReader br)
        {
            BasEntity entity = new BasEntity();

            entity.Offset       = br.BaseStream.Position;
            entity.HeaderResult = ReadHeader(br);

            if (br.BaseStream.Length - br.BaseStream.Position > 2)
            {
                br.BaseStream.Seek(2, SeekOrigin.Current); // Skip "\r\n"
            }

            do
            {
                BasRecordType.DataType type = BasHelper.GetType(br);

                if (type == BasRecordType.DataType.Annotation)
                {
                    entity.AnnotationsResult.Add(ReadAnnotation(br));
                }
                else if (type == BasRecordType.DataType.Coordinate)
                {
                    entity.CoordinatesResult.Add(ReadCoordinate(br));
                }
                else
                {
                    break;
                }

                // Skip "\r\n"
                if (br.BaseStream.Length - br.BaseStream.Position > 2)
                {
                    br.BaseStream.Seek(2, SeekOrigin.Current);
                }
            }while (true);

            return(entity);
        }