Esempio n. 1
0
        /// <summary>
        /// adds a layer to the active view
        /// </summary>
        /// <param name="path">full path name</param>
        /// <returns>Ilayer</returns>
        public ILayer addLayer(string path)
        {
            IMap map = (IMap)acView;
            geoDatabaseUtility geoUtil = new geoDatabaseUtility();
            esriDatasetType    dType   = geoUtil.getDataType(path);
            ILayer             lyr     = null;

            switch (dType)
            {
            case esriDatasetType.esriDTFeatureClass:
                IFeatureLayer ftrLayer = new FeatureLayerClass();
                ftrLayer.FeatureClass = geoUtil.getFeatureClass(path);
                lyr      = (ILayer)ftrLayer;
                lyr.Name = ftrLayer.FeatureClass.AliasName;
                map.AddLayer(lyr);
                break;

            case esriDatasetType.esriDTRasterBand:
            case esriDatasetType.esriDTRasterCatalog:
            case esriDatasetType.esriDTRasterDataset:
                IRasterLayer rasterLayer = new RasterLayerClass();
                rasterLayer.CreateFromDataset(geoUtil.getRasterDataset(path));
                rasterLayer.Name = rasterLayer.Name;
                map.AddLayer((ILayer)rasterLayer);
                break;

            case esriDatasetType.esriDTTable:
                ITable           tbl             = geoUtil.getTable(path);
                ITableCollection tableCollection = (ITableCollection)map;
                tableCollection.AddTable(tbl);
                break;

            default:
                break;
            }
            acView.Refresh();
            return(lyr);
        }