public List<string> GetSurfaceNamesFromMap(IMap map, bool IncludeTinLayers = false)
{
var list = new List<string>();
for (int x = 0; x < map.LayerCount; x++)
{
try
{
var layer = map.get_Layer(x);
if (layer == null)
continue;
var tin = layer as ITinLayer;
if (tin != null)
{
if (IncludeTinLayers)
list.Add(layer.Name);
continue;
}
var rasterSurface = new RasterSurfaceClass() as IRasterSurface;
ISurface surface = null;
var ml = layer as IMosaicLayer;
if (ml != null)
{
if (ml.PreviewLayer != null && ml.PreviewLayer.Raster != null)
{
rasterSurface.PutRaster(ml.PreviewLayer.Raster, 0);
surface = rasterSurface as ISurface;
if (surface != null)
list.Add(layer.Name);
}
continue;
}
var rasterLayer = layer as IRasterLayer;
if (rasterLayer != null && rasterLayer.Raster != null)
{
rasterSurface.PutRaster(rasterLayer.Raster, 0);
surface = rasterSurface as ISurface;
if (surface != null)
list.Add(layer.Name);
continue;
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
return list;
}