示例#1
0
        /// <summary>
        /// 创建3级索引
        /// </summary>
        /// <param name="featureClassSDO"></param>
        public void CreateSpatialIndex(FeatureClassSDO featureClassSDO)
        {
            if (string.IsNullOrEmpty(this.DataBlockCode) || string.Equals("0", this.DataBlock))
            {
                LogUtil.Error("不是第一个节点");
                throw new ArgumentException("该节点不是第一个节点");
            }
            Envelope[] envelopes     = CreateSubdeEnvelope(featureClassSDO.Envelope);
            int        featuresCount = featureClassSDO.Features.Count;

            Parallel.For(0, featuresCount, (t) =>
            {
                Feature feature;
                featureClassSDO.Features.TryTake(out feature);
                for (int i = 0; i < 4; i++)
                {
                    Envelope envelope = envelopes[i];
                    SpatialIndexNode spatialIndexNode = new SpatialIndexNode(envelope, featureClassSDO.Name,
                                                                             this.IndexLeve, i, this.ParentCode);
                    this.Subnode[i] = spatialIndexNode;
                    if (envelope.Contains(feature.Geometry.EnvelopeInternal))
                    {
                        spatialIndexNode.CreateSpatialIndex(feature, envelope);
                    }
                    else
                    {
                        this.DataBlock.AddFeature(feature);
                    }
                }
            });
        }
示例#2
0
        /// <summary>
        /// 向下层级创建索引
        /// </summary>
        /// <param name="feature"></param>
        /// <param name="envelope"></param>
        private void CreateSpatialIndex(Feature feature, Envelope envelope)
        {
            Envelope[] envelopes = CreateSubdeEnvelope(envelope);

            for (int i = 0; i < 4; i++)
            {
                Envelope         envelopeTemp     = envelopes[i];
                SpatialIndexNode spatialIndexNode = new SpatialIndexNode(envelope, this.DataBlockName,
                                                                         this.IndexLeve, i, this.ParentCode);
                this.Subnode[i] = spatialIndexNode;
                if (envelope.Contains(feature.Geometry.EnvelopeInternal))
                {
                    if (this.DataBlockCode.Length == 4)
                    {
                        this.DataBlock.AddFeature(feature);
                        return;
                    }
                    spatialIndexNode.CreateSpatialIndex(feature, envelopeTemp);
                    return;
                }
            }
            this.DataBlock.AddFeature(feature);
        }