コード例 #1
0
ファイル: DxfFile.cs プロジェクト: Sony-NS/SharpMap
        /// <summary>
        /// Returns all objects whose boundingbox intersects bbox.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Please note that this method doesn't guarantee that the geometries returned actually intersect 'bbox', but only
        /// that their boundingbox intersects 'bbox'.
        /// </para>
        /// </remarks>
        /// <param name="bbox"></param>
        /// <returns></returns>
        public virtual IList GetFeatures(IEnvelope bbox)
        {
            if (!IsOpen)
            {
                Open(Path);
            }

            if (!_IsOpen)
            {
                return(new List <IFeature>());         //return empty list in case there is no connection
            }
            var table = _DxfFile.NewTable();

            foreach (FeatureDataRow fdr in _FeatureTable)
            {
                if (fdr.Geometry != null)
                {
                    if (fdr.Geometry.EnvelopeInternal.Intersects(bbox))
                    {
                        if (FilterDelegate == null || FilterDelegate(fdr))
                        {
                            FeatureDataRow dr = table.NewRow();
                            dr[DxfSchema.GIS_DXF_FLD_ID]         = fdr[DxfSchema.GIS_DXF_FLD_ID];
                            dr[DxfSchema.GIS_DXF_FLD_HANDLE]     = fdr[DxfSchema.GIS_DXF_FLD_HANDLE];
                            dr[DxfSchema.GIS_DXF_FLD_LAYER_NAME] = fdr[DxfSchema.GIS_DXF_FLD_LAYER_NAME];
                            dr[DxfSchema.GIS_DXF_FLD_SHAPE_TYPE] = fdr[DxfSchema.GIS_DXF_FLD_SHAPE_TYPE];
                            dr[DxfSchema.GIS_DXF_FLD_LABEL]      = fdr[DxfSchema.GIS_DXF_FLD_LABEL];
                            dr.Geometry = fdr.Geometry;
                            table.AddRow(dr);
                        }
                    }
                }
            }

            return(table);
        }