当前位置: 首页>>代码示例>>C#>>正文


C# Envelope.expandToInclude方法代码示例

本文整理汇总了C#中Envelope.expandToInclude方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.expandToInclude方法的具体用法?C# Envelope.expandToInclude怎么用?C# Envelope.expandToInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Envelope的用法示例。


在下文中一共展示了Envelope.expandToInclude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        private void Initialize()
        {
            // Cache the .dbf header
            _dbfHeader = new DbaseFileHeader();

            using (BinaryReader dbfReader = new BinaryReader(File.OpenRead(Path.Combine(Path.GetDirectoryName(_path), Path.GetFileNameWithoutExtension(_path) + ".dbf"))))
            {
                _dbfHeader.ReadHeader(dbfReader);
                _dbfHeaderOffset = dbfReader.BaseStream.Position;
            }

            // Need to make one pass over the geometries and pull out the bounding boxes
            _spatialIndex = new com.vividsolutions.jts.index.strtree.STRtree();
            _extents = new Envelope();

            using (BigEndianBinaryReader shpReader = new BigEndianBinaryReader(File.OpenRead(_path)))
            using (ShapefileIndexReader shxReader = new ShapefileIndexReader(Path.Combine(Path.GetDirectoryName(_path), Path.GetFileNameWithoutExtension(_path) + ".shx")))
            {
                // Get the shape type
                _type = new ShapefileHeader(shpReader).ShapeType;

                while (shxReader.Read())
                {
                    int offset = shxReader.GetOffest();
                    int length = shxReader.GetLength();

                    // Move to the start of geometry
                    shpReader.BaseStream.Position = offset * 2;

                    double xMin;
                    double yMin;
                    double xMax;
                    double yMax;

                    int recordNumber = shpReader.ReadIntBE();
                    int contentLength = shpReader.ReadIntBE();

                    // Read shape type
                    int type = shpReader.ReadInt32();

                    if (type != 1)
                    {
                        xMin = shpReader.ReadDouble();
                        yMin = shpReader.ReadDouble();
                        xMax = shpReader.ReadDouble();
                        yMax = shpReader.ReadDouble();
                    }
                    else
                    {
                        // Point - read x and y
                        xMin = shpReader.ReadDouble();
                        yMin = shpReader.ReadDouble();
                        xMax = yMin;
                        yMax = yMin;
                    }

                    // Build the envelope
                    Envelope extents = new Envelope(xMin, xMax, yMin, yMax);

                    // Add to total extents
                    _extents.expandToInclude(extents);

                    // Insert the index of the record into the spatial index
                    _spatialIndex.insert(extents, new ShapefileRecordPointer(recordNumber, offset * 2, contentLength, (int)_dbfHeaderOffset + (_dbfHeader.RecordLength * (recordNumber - 1))));
                }

                // Build the index once
                _spatialIndex.build();
            }
        }
开发者ID:vmoll,项目名称:geotools,代码行数:70,代码来源:QueryableShapefileReader.cs


注:本文中的Envelope.expandToInclude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。