本文整理汇总了C#中FeatureLayerClass类的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayerClass类的具体用法?C# FeatureLayerClass怎么用?C# FeatureLayerClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureLayerClass类属于命名空间,在下文中一共展示了FeatureLayerClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InMemoryWorkspaceFactoryClass
private void 添加点型图层ToolStripMenuItem_Click(object sender, EventArgs e)
{
//创建要素类
#region 创建新的内存工作空间
IWorkspaceFactory pWSF = new InMemoryWorkspaceFactoryClass();
IWorkspaceName pWSName = pWSF.Create("", "Temp", null, 0);
IName pName = (IName)pWSName;
IWorkspace pMemoryWS = (IWorkspace)pName.Open();
#endregion
IField oField = new FieldClass();
IFields oFields = new FieldsClass();
IFieldsEdit oFieldsEdit = null;
IFieldEdit oFieldEdit = null;
IFeatureClass oFeatureClass = null;
IFeatureLayer oFeatureLayer = null;
oFieldsEdit = oFields as IFieldsEdit;
oFieldEdit = oField as IFieldEdit;
oFieldEdit.Name_2 = "OBJECTID";
oFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
oFieldEdit.IsNullable_2 = false;
oFieldEdit.Required_2 = false;
oFieldsEdit.AddField(oField);
oField = new FieldClass();
oFieldEdit = oField as IFieldEdit;
IGeometryDef pGeoDef = new GeometryDefClass();
IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
pGeoDefEdit.AvgNumPoints_2 = 5;
pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
pGeoDefEdit.GridCount_2 = 1;
pGeoDefEdit.HasM_2 = false;
pGeoDefEdit.HasZ_2 = false;
pGeoDefEdit.SpatialReference_2 = axMapControl1.SpatialReference;
oFieldEdit.Name_2 = "SHAPE";
oFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
oFieldEdit.GeometryDef_2 = pGeoDef;
oFieldEdit.IsNullable_2 = true;
oFieldEdit.Required_2 = true;
oFieldsEdit.AddField(oField);
oField = new FieldClass();
oFieldEdit = oField as IFieldEdit;
oFieldEdit.Name_2 = "Code";
oFieldEdit.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
//oFieldEdit.Length = 10;
oFieldEdit.IsNullable_2 = true;
oFieldsEdit.AddField(oField);
//创建要素类
oFeatureClass = (pMemoryWS as IFeatureWorkspace).CreateFeatureClass("Temp", oFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
oFeatureLayer = new FeatureLayerClass();
oFeatureLayer.Name = "PointLayer";
oFeatureLayer.FeatureClass = oFeatureClass;
//创建唯一值符号化对象
IUniqueValueRenderer pURender = new UniqueValueRendererClass();
pURender.FieldCount = 1;
pURender.set_Field(0, "Code");
pURender.UseDefaultSymbol = false;
//创建SimpleMarkerSymbolClass对象
ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
//创建RgbColorClass对象为pSimpleMarkerSymbol设置颜色
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 255;
pSimpleMarkerSymbol.Color = pRgbColor as IColor;
//设置pSimpleMarkerSymbol对象的符号类型,选择钻石
pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
//设置pSimpleMarkerSymbol对象大小,设置为5
pSimpleMarkerSymbol.Size = 5;
//显示外框线
pSimpleMarkerSymbol.Outline = true;
//为外框线设置颜色
IRgbColor pLineRgbColor = new RgbColorClass();
pLineRgbColor.Green = 255;
pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor;
//设置外框线的宽度
pSimpleMarkerSymbol.OutlineSize = 1;
//半透明颜色
pURender.AddValue("1", "", pSimpleMarkerSymbol as ISymbol);
//唯一值符号化内存图层
(oFeatureLayer as IGeoFeatureLayer).Renderer = pURender as IFeatureRenderer;
ILayerEffects pLyrEffect = oFeatureLayer as ILayerEffects;
//透明度
pLyrEffect.Transparency = 0;
oFeatureLayer.Visible = true;
this.axMapControl1.AddLayer(oFeatureLayer,axMapControl1.LayerCount);
insertpoint = true;
}
示例2: OnClick
protected override void OnClick()
{
string tablePath = Path.Combine(DataPath, @"File-Based\MajorCities.csv");
string tableName = Path.GetFileName(tablePath);
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.TextFileWorkspaceFactory");
IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
IWorkspace workspace = workspaceFactory.OpenFromFile(Path.GetDirectoryName(tablePath), 0);
ITable table = ((IFeatureWorkspace) workspace).OpenTable(tableName);
ISpatialReference sRef = CreateSpatialReference(esriSRGeoCSType.esriSRGeoCS_WGS1984);
IFeatureClass featureClass = CreateXYEventFeature(table, "POINT_X", "POINT_y", sRef);
IFeatureLayer featureLayer = new FeatureLayerClass
{
FeatureClass = featureClass,
Name = "CSV XY Event Table"
};
IFeatureLayerSourcePageExtension sourcePageExtension = new XYDataSourcePageExtensionClass();
((ILayerExtensions) featureLayer).AddExtension(sourcePageExtension);
ArcMap.Document.FocusMap.AddLayer(featureLayer);
ArcMap.Document.UpdateContents();
}
示例3: FindMyFeatureLayer
public static IFeatureLayer FindMyFeatureLayer(IMap inMap, string inName)
{
string isfound = "false";
ILayer tempLayer;
IFeatureLayer goodLayer = new FeatureLayerClass();
for (int i = 0; i < inMap.LayerCount; i++)
{
tempLayer = inMap.get_Layer(i);
if (tempLayer is IFeatureLayer)
{
if (tempLayer.Name == inName)
{
isfound = "true";
goodLayer = tempLayer as IFeatureLayer;
}
}
}
//duplicate name in the map.? How we deal with it
if (isfound == "true")
{
return goodLayer;
}
else
{
return null;
}
}
示例4: ClipByLayer
/// <summary>
/// 两图层进行裁剪运算
/// </summary>
/// <param name="inputLayer">被裁剪图层</param>
/// <param name="clipLayer">裁剪图层</param>
/// <param name="outputFullPath">输出图层完整路径</param>
public void ClipByLayer(ILayer inputLayer, ILayer clipLayer, string outputFullPath)
{
string inputPath = GetLayerPath(inputLayer);
string clipPath = GetLayerPath(clipLayer);
Clip clipTool = new Clip();
clipTool.in_features = inputPath;
clipTool.clip_features = clipPath;
clipTool.out_feature_class = outputFullPath;
Geoprocessor processor = new Geoprocessor();
IGPProcess process = null;
processor.OverwriteOutput = true;
process = clipTool;
processor.Validate(process, true);
processor.Execute(process, null);
FileInfo fi = new FileInfo(outputFullPath);
string pathDir = fi.Directory.FullName;
string name = fi.Name;
IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace fws = wsf.OpenFromFile(pathDir, 0) as IFeatureWorkspace;
IFeatureClass featCls = fws.OpenFeatureClass(name);
IFeatureLayer layer = new FeatureLayerClass();
layer.FeatureClass = featCls;
layer.Name = featCls.AliasName;
m_mapControl.Map.AddLayer(layer as ILayer);
}
示例5: CreateBlobber
public static Blobber CreateBlobber()
{
BlobberRepository repository = new BlobberRepository();
repository.StartEdit();
Blobber b = repository.Create();
b.BlobberId = BLOBBER_ID;
IFeatureLayer layer = new FeatureLayerClass();
layer.Name = BLOBBER_VALUE_1;
IPropertySet properties = new PropertySetClass();
properties.SetProperty("VALUE1", BLOBBER_VALUE_1);
properties.SetProperty("VALUE2", BLOBBER_VALUE_2);
properties.SetProperty("VALUE3", BLOBBER_VALUE_3);
b.Properties = properties;
b.Store();
repository.StopEdit(true);
return b;
}
示例6: OnClick
protected override void OnClick()
{
//
// TODO: Sample code showing how to access button host
//
// ArcMap.Application.CurrentTool = null;
// Nohe did this
//IDocument doc = ArcMap.Application.Document;
//IMxDocument mxDoc = doc as IMxDocument;
//int value = ArcMap.Application.hWnd;
//IActiveView av = mxDoc.ActiveView as IActiveView;
//IMap map = mxDoc.FocusMap as IMap;
//frddie
IMap map = ArcMap.Document.ActiveView.FocusMap;
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory wsf = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
//nohe
//IWorkspaceFactory wsf = new FileGDBWorkspaceFactory();
IFeatureWorkspace ws = wsf.OpenFromFile(@"C:\Users\alex7370\Documents\GitHub\MyAddins\AddingAFeature\features.gdb", 0) as IFeatureWorkspace;
IFeatureLayer featureLayer = new FeatureLayerClass { FeatureClass = ws.OpenFeatureClass("pointFeature")};
featureLayer.Name = featureLayer.FeatureClass.AliasName;
map.AddLayer(featureLayer);
ArcMap.Document.ActiveView.Refresh();
}
示例7: btnGO_Click
private void btnGO_Click(object sender, EventArgs e)
{
string fileName;
string shpFile;
int startX, endX;
string shpDir;
try
{
if (bDataPath == true)
{
fileName=txtOutputData.Text;
shpDir =fileName.Substring(0, fileName.LastIndexOf("\\"));
startX=fileName.LastIndexOf("\\");
endX=fileName.Length;
shpFile=fileName.Substring(startX+1,endX-startX-1);
}
else
{
shpDir=txtOutputData.Text;
shpFile="��ֵ��";
}
if (m_pRasterLyr != null)
{
double dInterval=Convert.ToDouble(txtConInterval.Text);
double dBaseLine=Convert.ToDouble(txtBaseLine.Text);
object objBaseLine=dBaseLine;
ISurfaceOp pRasterSurfaceOp = new RasterSurfaceOpClass();
IRaster pInRaster = m_pRasterLyr.Raster;
IFeatureClass pOutFClass= pRasterSurfaceOp.Contour(pInRaster as IGeoDataset , dInterval, ref objBaseLine) as IFeatureClass ;
//2. QI to IDataset
IDataset pFDS=pOutFClass as IDataset ;
//3. Get a shapefile workspace
IWorkspaceFactory pSWF=new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace pFWS=pSWF.OpenFromFile(shpDir,0) as IFeatureWorkspace ;
//4. Copy contour output to a new shapefile
IWorkspace pWS = pFWS as IWorkspace;
if (pWS.Exists() == true)
Utility.DelFeatureFile(shpDir, shpFile + ".shp");
pFDS.Copy(shpFile,pFWS as IWorkspace );
IFeatureLayer pFeatLyr = new FeatureLayerClass();
pFeatLyr.FeatureClass = pOutFClass;
pFeatLyr.Name = pOutFClass.AliasName;
pFeatLyr.Visible = true;
pMainFrm.getMapControl().AddLayer(pFeatLyr, 0);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例8: addFeatureClassToMap
/// <summary> Add feature class to active View and then zoom to its extend </summary>
/// <param name="view">the current active view</param>
/// <param name="inFeatureClass">the feature class to add</param>
/// <param name="zoomTo">zoom to loaded feature class</param>
/// <returns>the created layer</returns>
public static IFeatureLayer addFeatureClassToMap(IActiveView view, IFeatureClass inFeatureClass, bool zoomTo = false)
{
IFeatureLayer featureLayer = new FeatureLayerClass();
featureLayer.FeatureClass = inFeatureClass;
featureLayer.Name = inFeatureClass.AliasName;
featureLayer.Visible = true;
view.FocusMap.AddLayer(featureLayer);
if(zoomTo) view.Extent = featureLayer.AreaOfInterest;
return featureLayer;
}
示例9: btnApply_Click
private void btnApply_Click(object sender, EventArgs e)
{
if (isSelectNode == true)
{
IFeatureClass pFeatCls = m_pFeatureWorkspace.OpenFeatureClass(m_strSelFeatLayer);
IFeatureLayer pFeatLayer = new FeatureLayerClass();
pFeatLayer.FeatureClass = pFeatCls;
pFeatLayer.Visible = true;
pFeatLayer.Name = pFeatCls.AliasName;
AxMapControl axMap = pMainFrm.getMapControl();
axMap.AddLayer(pFeatLayer);
axMap.Refresh();
}
}
示例10: init
public void init(int programID, AxMapControl mc, Intersect.ProgramStepUserControl.OnFinish of, MainWindow mw)
{
inited = true;
if (program == null)
program = new Program();
program.id = programID;
program.select();
if (project == null)
project = new Project();
project.id = program.projectID;
project.select();
NetSizeUserControl.init(program.id);
ConditionUserControl.init(program.id);
mapControl = mc;
onFinish = of;
mainWindow = mw;
mapControlMouseDown = null;
//在初始化时就要对valid进行判断.
Thread t = new Thread(delegate()
{
System.Threading.Thread.Sleep(500);
Dispatcher.BeginInvoke((ThreadStart)delegate()
{
if (isValid())
{
valid = true;
onFinish(true);
IFeatureClass resultFeatureClass;
if ((resultFeatureClass = GisUtil.getFeatureClass(System.IO.Path.GetDirectoryName(project.path), "评价结果.shp")) != null)
{
IFeatureLayer resultFeatureLayer = new FeatureLayerClass();
resultFeatureLayer.FeatureClass = resultFeatureClass;
mapControl.AddLayer(resultFeatureLayer);
}
else
{
SiteSelector siteSelector = new SiteSelector(mapControl, program.id);
siteSelector.startSelectSite();
}
}
});
});
t.Start();
}
示例11: MainForm_Load
private void MainForm_Load(object sender, EventArgs e)
{
m_mapControl = (IMapControl3) axMapControl1.Object;
//relative file path to the sample data from EXE location
string filePath = @"..\..\..\data\USAMajorHighways";
//Add Lakes layer
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd);
IFeatureLayer featureLayer = new FeatureLayerClass();
featureLayer.Name = "Lakes";
featureLayer.Visible = true;
featureLayer.FeatureClass = workspace.OpenFeatureClass("us_lakes");
#region create a SimplerRenderer
IRgbColor color = new RgbColorClass();
color.Red = 190;
color.Green = 232;
color.Blue = 255;
ISimpleFillSymbol sym = new SimpleFillSymbolClass();
sym.Color = color;
ISimpleRenderer renderer = new SimpleRendererClass();
renderer.Symbol = sym as ISymbol;
#endregion
((IGeoFeatureLayer)featureLayer).Renderer = renderer as IFeatureRenderer;
axMapControl1.Map.AddLayer((ILayer)featureLayer);
//Add Highways layer
featureLayer = new FeatureLayerClass();
featureLayer.Name = "Highways";
featureLayer.Visible = true;
featureLayer.FeatureClass = workspace.OpenFeatureClass("usa_major_highways");
axMapControl1.Map.AddLayer((ILayer)featureLayer);
//******** Important *************
//store a reference to this form (Mainform) using the EditHelper class
EditHelper.TheMainForm = this;
EditHelper.IsEditorFormOpen = false;
//add the EditCmd command to the toolbar
axEditorToolbar.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axEditorToolbar.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axEditorToolbar.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axEditorToolbar.AddItem(new EditCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
}
示例12: ThematicView2_Load
void ThematicView2_Load(object sender, EventArgs e)
{
SdeConnection conn = new SdeConnection();
ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
IFeatureClass fcThua = fw.OpenFeatureClass("sde.thixa_thua");
IFeatureLayer flThua = new FeatureLayerClass();
flThua.FeatureClass = fcThua;
ILayer layerThua = (ILayer)flThua;
IFeatureClass fcDuong = fw.OpenFeatureClass("sde.thixa_duong");
IFeatureLayer flDuong = new FeatureLayerClass();
flDuong.FeatureClass = fcDuong;
ILayer layerDuong = (ILayer)flDuong;
layerDuong.Name = fcDuong.AliasName;
layerThua.Name = fcThua.AliasName;
_mapController.AddLayer(layerDuong);
_mapController.AddLayer(layerThua);
}
示例13: showMap
private void showMap()
{
SdeConnection conn = new SdeConnection();
ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
IFeatureClass fcHem = fw.OpenFeatureClass("sde.thixa_hem");
IFeatureLayer flHem = new FeatureLayerClass();
flHem.FeatureClass = fcHem;
ILayer layerThua = (ILayer)flHem;
IFeatureClass fcDuong = fw.OpenFeatureClass("sde.thixa_duong");
IFeatureLayer flDuong = new FeatureLayerClass();
flDuong.FeatureClass = fcDuong;
ILayer layerDuong = (ILayer)flDuong;
layerDuong.Name = fcDuong.AliasName;
layerThua.Name = fcHem.AliasName;
_mapController.AddLayer(flHem);
_mapController.AddLayer(flDuong);
}
示例14: AddData_CAD
public static void AddData_CAD(AxMapControl axMapControl1)
{
IWorkspaceFactory pWorkspaceFactory;
IFeatureWorkspace pFeatureWorkspace;
IFeatureLayer pFeatureLayer;
IFeatureDataset pFeatureDataset;
//获取当前路径和文件名
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
string strFullPath = dlg.FileName;
if (strFullPath == "") return;
int Index = strFullPath.LastIndexOf("//");
string filePath = strFullPath.Substring(0, Index);
string fileName = strFullPath.Substring(Index + 1);
//打开CAD数据集
pWorkspaceFactory = new CadWorkspaceFactoryClass();
pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0);
//打开一个要素集
pFeatureDataset = pFeatureWorkspace.OpenFeatureDataset(fileName);
//IFeaturClassContainer可以管理IFeatureDataset中的每个要素类
IFeatureClassContainer pFeatClassContainer = (IFeatureClassContainer)pFeatureDataset;
//对CAD文件中的要素进行遍历处理
for (int i = 0; i < pFeatClassContainer.ClassCount - 1; i++)
{
IFeatureClass pFeatClass = pFeatClassContainer.get_Class(i);
if (pFeatClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
//如果是注记,则添加注记层
pFeatureLayer = new CadAnnotationLayerClass();
else
//如果是点、线、面,则添加要素层
pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.Name = pFeatClass.AliasName;
pFeatureLayer.FeatureClass = pFeatClass;
axMapControl1.Map.AddLayer(pFeatureLayer);
axMapControl1.ActiveView.Refresh();
}
ILayer layer = axMapControl1.get_Layer(0);
axMapControl1.Extent = layer.AreaOfInterest;
}
}
示例15: OracleQueryLayer
public IFeatureLayer OracleQueryLayer()
{
// 创建SqlWorkspaceFactory的对象
Type pFactoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SqlWorkspaceFactory");
IWorkspaceFactory pWorkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(pFactoryType);
// 构造连接数据库的参数
IPropertySet pConnectionProps = new PropertySetClass();
pConnectionProps.SetProperty("dbclient", "Oracle11g");
pConnectionProps.SetProperty("serverinstance", "esri");
pConnectionProps.SetProperty("authentication_mode", "DBMS");
pConnectionProps.SetProperty("user", "scott");
pConnectionProps.SetProperty("password", "arcgis");
// 打开工作空间
IWorkspace workspace = pWorkspaceFactory.Open(pConnectionProps, 0);
ISqlWorkspace pSQLWorkspace = workspace as ISqlWorkspace;
//获取数据库中的所有表的名称
//IStringArray pStringArray= pSQLWorkspace.GetTables();
//for (int i = 0; i < pStringArray.Count; i++)
//{
// MessageBox.Show(pStringArray.get_Element(i));
//}
// 构造过滤条件 SELECT * FROM PointQueryLayer
IQueryDescription queryDescription = pSQLWorkspace.GetQueryDescription("SELECT * FROM TEST");
ITable pTable = pSQLWorkspace.OpenQueryClass("QueryLayerTest", queryDescription);
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.FeatureClass = pTable as IFeatureClass;
return pFeatureLayer;
}