Beispiel #1
0
        /// <summary>
        /// 根据ShpReader和DbfReader创建FeatureSet
        /// </summary>
        /// <param name="shpReader"></param>
        /// <param name="dbfReader"></param>
        /// <param name="recordNum"></param>
        /// <returns></returns>
        private static FeatureSet CreateFeatureSet(ShpReader shpReader, DbfReader dbfReader, int recordNum)
        {
            GeometryType geometryType = (GeometryType)shpReader.ShpHeader.ShapeType;
            var          featureType  = ShpUtil
                                        .GeometryType2FeatureType(geometryType);
            FeatureSet   fs       = new FeatureSet(featureType);
            IFeatureList features = new FeatureList(fs);

            for (int i = 0; i < recordNum; i++)
            {
                var spatialBytes = shpReader.GetNextRecord();
                dbfReader.GetNextRow();
                IGeometry geometry;
                switch (geometryType)
                {
                case GeometryType.Point:
                    geometry = BytesToGeometry.CreatePoint(spatialBytes);
                    break;

                case GeometryType.MultiPoint:
                    geometry = BytesToGeometry.CreateMultipoint(spatialBytes);
                    break;

                case GeometryType.PolyLine:
                    geometry = BytesToGeometry.CreatePolyLine(spatialBytes);
                    break;

                case GeometryType.Polygon:
                    geometry = BytesToGeometry.CreatePolygon(spatialBytes);
                    break;

                default:
                    geometry = null;
                    break;
                }

                IFeature feature = new Feature(geometry);
                features.Add(feature);
            }

            fs.Features.Set(features);
            fs.AttrTable = dbfReader.DbfTable;
            var header = shpReader.ShpHeader;

            //fs.Envelope = new Envelope(header.XMin, header.YMin,
            //    header.XMax, header.YMax,
            //    header.ZMin, header.ZMax);

            return(fs);
        }