/// <summary> /// Render City and Village /// </summary> /// <param name="currentLayer"></param> /// <author>Shen Yongyuan</author> /// <date>20091114</date> public static void RenderCityVillage(ILayer currentLayer) { IUniqueValueRenderer pUniqueValueR = new UniqueValueRendererClass(); pUniqueValueR.FieldCount = 1; string fieldName = Town.Constant.Constant.TmpTableDevide + "." + Town.Constant.Constant.TmpFieldName; pUniqueValueR.set_Field(0, fieldName); ISimpleFillSymbol pFillSymbolDef = new SimpleFillSymbolClass(); pFillSymbolDef.Color = Town.ArcGIS.Color.ToEsriColor(System.Drawing.Color.Gray); pUniqueValueR.DefaultSymbol = pFillSymbolDef as ISymbol; pUniqueValueR.UseDefaultSymbol = true; ISimpleFillSymbol citySymbol = new SimpleFillSymbolClass(); citySymbol.Color = Town.ArcGIS.Color.ToEsriColor(System.Drawing.Color.Yellow); pUniqueValueR.AddValue("城镇", "城镇", citySymbol as ISymbol); ISimpleFillSymbol vilageSymbol = new SimpleFillSymbolClass(); vilageSymbol.Color = Town.ArcGIS.Color.ToEsriColor(System.Drawing.Color.Tomato); pUniqueValueR.AddValue("乡村", "乡村", vilageSymbol as ISymbol); IGeoFeatureLayer geoFeaLayer = currentLayer as IGeoFeatureLayer; geoFeaLayer.Renderer = pUniqueValueR as IFeatureRenderer; }
///<summary> ///设置要素图层唯一值符号化 ///</summary> ///<param name="pFeatureLayer"></param> private void UniqueValueRenderFlyr(AxMapControl axMapControl1, IFeatureLayer pFeatureLayer) { try { //创建UniqueValueRendererClass对象 IUniqueValueRenderer pUVRender = new UniqueValueRendererClass(); List <string> pFieldValues = new List <string>(); pFieldValues.Add("Hospital 2"); pFieldValues.Add("School 1"); pFieldValues.Add("Airport"); for (int i = 0; i < pFieldValues.Count; i++) { ISymbol pSymbol = new SimpleMarkerSymbolClass(); pSymbol = GetSymbol(@"D:\Program Files\ArcGIS\Styles\ESRI.ServerStyle", "Marker Symbols", pFieldValues[i]); //添加唯一值符号化字段值和相对应的符号 pUVRender.AddValue(pFieldValues[i], pFieldValues[i], pSymbol); } //设置唯一值符号化的字段个数和字段名 pUVRender.FieldCount = 1; pUVRender.set_Field(0, "类别"); IGeoFeatureLayer pGFeatureLyr = pFeatureLayer as IGeoFeatureLayer; //设置IGeofeatureLayer的Renderer属性 pGFeatureLyr.Renderer = pUVRender as IFeatureRenderer; } catch (Exception Err) { MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected void simpleRender(IFeatureLayer layer, IColor borderColor, double borderWidth) { ISimpleRenderer simpleRender = null; IFillSymbol fillSymbol = null; ILineSymbol lineSymbol = null; IColor fillColor = null; IGeoFeatureLayer geoLayer = null; if (layer != null && borderColor != null) { fillColor = new RgbColorClass(); fillColor.NullColor = true; fillSymbol = new SimpleFillSymbolClass(); lineSymbol = new SimpleLineSymbolClass(); fillSymbol.Color = fillColor; lineSymbol.Color = borderColor; lineSymbol.Width = borderWidth; fillSymbol.Outline = lineSymbol; geoLayer = layer as IGeoFeatureLayer; if (geoLayer != null) { simpleRender = new SimpleRendererClass(); simpleRender.Symbol = fillSymbol as ISymbol; geoLayer.Renderer = simpleRender as IFeatureRenderer; } } }
public static void ApplySimpleRenderer(IGeoFeatureLayer fl) { ISimpleRenderer sr = new SimpleRendererClass(); sr.Symbol = (ISymbol)CreateSimpleFillSymbol(255, 0, 0); fl.Renderer = (IFeatureRenderer)sr; }
private void 更换控制点符号ToolStripMenuItem_Click(object sender, EventArgs e) { //layer = (IFeatureLayer)axMapControl1.get_Layer(0); int iIndex; for (iIndex = 0; iIndex < axMapControl1.LayerCount; iIndex++) { ILayer pLayer = axMapControl1.get_Layer(iIndex); IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFClass = pFLayer.FeatureClass; if (pFClass.ShapeType == esriGeometryType.esriGeometryPoint) { IGeoFeatureLayer geoFeatureLayer = pLayer as IGeoFeatureLayer; SimpleRenderer simpleRender = new SimpleRendererClass(); ISimpleMarkerSymbol pMarkerSymbol; Random rd = new Random(); Color mycolor = Color.FromArgb(0, rd.Next(0, 256), rd.Next(0, 256), rd.Next(0, 256)); IColor color = Color2IColor(mycolor); pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = (esriSimpleMarkerStyle)rd.Next(0, 5); pMarkerSymbol.Color = color; pMarkerSymbol.Angle = 60; pMarkerSymbol.Size = 6; simpleRender.Symbol = pMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; axMapControl1.Refresh(); } } }
/// <summary> /// Tries to detect the main color used to draw the features of this layer. /// </summary> /// <param name="layer">The layer to get the color from.</param> /// <returns>The color used by this layer.</returns> public static IColor DetectLayerMainColor(IGeoFeatureLayer layer) { ISymbol symbol = null; if (layer.Renderer is ISimpleRenderer simpleRenderer) { symbol = simpleRenderer.Symbol; } else if (layer.Renderer is IUniqueValueRenderer uniqueValueRenderer) { symbol = uniqueValueRenderer.DefaultSymbol; } if (symbol is ISimpleLineSymbol lineSymbol) { return(lineSymbol.Color); } else if (symbol is ISimpleMarkerSymbol markerSymbol) { return(markerSymbol.Color); } else { return new RgbColorClass { RGB = 0 } }; }
private void Form1_Load(object sender, System.EventArgs e) { //Find sample data by navigating two folders up string sFilePath = @"..\..\..\Data\World\Continents.lyr"; //Add sample 'country' shapefile data axMapControl1.AddLayerFromFile(sFilePath); //Set the extent axMapControl1.Extent = axMapControl1.get_Layer(0).AreaOfInterest; //Grab hold of the IgeoFeaturelayer interface on the layer //in the map control in order to symbolize the data IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)axMapControl1.get_Layer(0); //Create a simple renderer and grab hold of ISimpleRenderer interface ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Create a fill symbol and grab hold of the ISimpleFillSymbol interface ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); //Create a line symbol and grab hold of the ISimpleLineSymbol interface ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); //Assign line symbol and fill symbol properties lineSymbol.Width = 0.1; lineSymbol.Color = GetRGBColor(255, 0, 0); //Red fillSymbol.Outline = lineSymbol; fillSymbol.Color = GetRGBColor(0, 0, 255); //Blue //Set the symbol property of the renderer simpleRenderer.Symbol = (ISymbol)fillSymbol; //Set the renderer property of the geo feature layer geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; }
private void sure_Click(object sender, EventArgs e) { string layer_name = layers1.Text; ILayer choose = null; double @base = double.Parse(basenumber.Text); double interval = double.Parse(dis.Text); ILayer temp_lay; for (int i = 0; i < m_hookHelper.FocusMap.LayerCount; i++) { temp_lay = m_hookHelper.FocusMap.get_Layer(i); if (temp_lay.Name == layer_name) { choose = temp_lay; } } IRasterLayer chooseras = choose as IRasterLayer; ISurfaceOp2 pSurfaceOp = default(ISurfaceOp2); pSurfaceOp = new RasterSurfaceOp() as ISurfaceOp2; IGeoDataset pRasterDataset = chooseras as IGeoDataset; IWorkspace pShpWS = default(IWorkspace); IWorkspaceFactory pShpWorkspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory(); pShpWS = pShpWorkspaceFactory.OpenFromFile(FilePath, 0); pSurfaceOp = new RasterSurfaceOp() as ISurfaceOp2; IRasterAnalysisEnvironment pRasterAEnv = (IRasterAnalysisEnvironment)pSurfaceOp; pRasterAEnv.OutWorkspace = pShpWS; IGeoDataset pOutput = default(IGeoDataset); IFeatureClass pFeatureClass = default(IFeatureClass); IFeatureLayer pFLayer = default(IFeatureLayer); object tmpbase; tmpbase = (object)@base; object tmpmy = 1; pOutput = pSurfaceOp.Contour(pRasterDataset, interval, ref tmpbase, ref tmpmy); pFeatureClass = (IFeatureClass)pOutput; pFLayer = new FeatureLayer(); pFLayer.FeatureClass = pFeatureClass; IGeoFeatureLayer pGeoFL = default(IGeoFeatureLayer); pGeoFL = (IGeoFeatureLayer)pFLayer; pGeoFL.DisplayAnnotation = false; pGeoFL.DisplayField = "CONTOUR"; pGeoFL.Name = "CONTOUR"; m_hookHelper.FocusMap.AddLayer(pGeoFL); }
/// <summary> /// 根据线要素,及图层获取符号,及线类型 /// </summary> /// <param name="pFeature">线要素</param> /// <param name="pLayer">图层</param> /// <param name="linetype">线类新</param> /// <returns>符号</returns> public static ILineSymbol GetLineSymbol(IFeature pFeature, IFeatureLayer pLayer, out epcLineSymbol linetype) { IGeoFeatureLayer pGeofLayer = pLayer as IGeoFeatureLayer; IFeatureRenderer pFRenderer = pGeofLayer.Renderer; ISymbol pSymbol = pFRenderer.get_SymbolByFeature(pFeature); linetype = epcLineSymbol.epcNull; if (pSymbol is ISimpleLineSymbol) { linetype = epcLineSymbol.epcSimple; } else if (pSymbol is ICartographicLineSymbol) { linetype = epcLineSymbol.epcCartoGraphic; } else if (pSymbol is IPictureLineSymbol) { linetype = epcLineSymbol.epcPicture; } else if (pSymbol is IMultiLayerLineSymbol) { linetype = epcLineSymbol.epcMultiLayer; } if (linetype == epcLineSymbol.epcNull) { return(null); } return(pSymbol as ILineSymbol); }
private static void MapUsingSimpleMarkerRenderer() { string layerName = CboLayers.GetSelectedLayer(); ILayer layer = GetLayerByName(layerName); string colorName = CboColors.GetSelectedColor(); ICmykColor markerColor = ColorbrewerExtension.GetSingleCMYKColor(); ISimpleMarkerSymbol marker = new SimpleMarkerSymbol(); marker.Style = esriSimpleMarkerStyle.esriSMSCircle; marker.Color = markerColor; marker.Size = 5; ISimpleRenderer renderer = new SimpleRenderer(); renderer.Symbol = marker as ISymbol; renderer.Label = layer.Name; IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer; gFLayer.Renderer = renderer as IFeatureRenderer; IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument; IMap map = mxDoc.FocusMap; mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, gFLayer, mxDoc.ActiveView.Extent); mxDoc.UpdateContents(); }
public void SetObjects(ESRI.ArcGIS.esriSystem.ISet objects) { // supplies the page with the object(s) to be edited including the map, feature layer, // feature class, and renderer // note: the feature renderer passed in as part of Objects is the one created // in CreateCompatibleObject object pObj = null; if (objects.Count <= 0) return; objects.Reset(); pObj = objects.Next(); IMap pMap = null; IGeoFeatureLayer pGeoLayer = null; // in this implementation we need info from the map and the renderer while (pObj != null) { if (pObj is IMap) pMap = pObj as IMap; if (pObj is IGeoFeatureLayer) pGeoLayer = pObj as IGeoFeatureLayer; if (pObj is IFeatureRenderer) m_pRend = pObj as IFeatureRenderer; pObj = objects.Next(); } if ((pMap != null) & (pGeoLayer != null) & (m_pRend != null)) { m_Page.InitControls(m_pRend as IMultivariateRenderer, pMap, pGeoLayer); } }
public RenderLayerPoint(IFeatureLayer featureLayer, MainForm frm) { InitializeComponent(); m_featureLayer = featureLayer; m_fraMain = frm; //Get properties of the current symbol IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer; IFeatureRenderer featureRenderer = geoFeatureLayer.Renderer; if (featureRenderer is ISimpleRenderer) { ISimpleRenderer simpleRenderer = geoFeatureLayer.Renderer as ISimpleRenderer; ISimpleMarkerSymbol simpleMarkerSymbol = simpleRenderer.Symbol as ISimpleMarkerSymbol; if (simpleMarkerSymbol != null) { //Get the current size of points tbSize.Text = simpleMarkerSymbol.Size.ToString(); //Get the current color of points IRgbColor rgbColor = new RgbColorClass(); rgbColor = simpleMarkerSymbol.Color as IRgbColor; tbRed.Text = rgbColor.Red.ToString(); tbGreen.Text = rgbColor.Green.ToString(); tbBlue.Text = rgbColor.Blue.ToString(); //Change the value of track bar tkbSize.Value = int.Parse(tbSize.Text); } } }
private void button9_Click(object sender, EventArgs e) { IFeatureLayer FoucsedLayer = axMapControl1.ActiveView.FocusMap.get_Layer(comboBox18.SelectedIndex) as IFeatureLayer; IGeoFeatureLayer GLayer = FoucsedLayer as IGeoFeatureLayer; UniqueValueMultiCondition(GLayer, comboBox17.SelectedItem.ToString(), comboBox19.SelectedItem.ToString()); }
private void btnOK_Click(object sender, EventArgs e) { IGeoFeatureLayer geoFeatureLayer = m_featureLayer as IGeoFeatureLayer; //Create a new simple marker symbol ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = int.Parse(tbSize.Text); //Change symbol's color IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = int.Parse(tbRed.Text); rgbColor.Blue = int.Parse(tbBlue.Text); rgbColor.Green = int.Parse(tbGreen.Text); simpleMarkerSymbol.Color = rgbColor; //Change properties of points ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = simpleMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer; m_fraMain.RefreshMap(); m_fraMain.RefreshTOCControl(); this.Close(); }
private void TOC_LabelLayer(ILayer pLayer) { if (pLayer == null) { return; } if (!(pLayer is IFeatureLayer)) { return; } IGeoFeatureLayer pGeoFeaturelayer = (IGeoFeatureLayer)pLayer; bool boolKG = pGeoFeaturelayer.DisplayAnnotation; m_pMainForm.m_TM_LableLayer.Checked = !boolKG; if (m_pMainForm.m_TM_LableLayer.Checked == true) { //Select Field Name from Current Layers FrmSelectField frm = new FrmSelectField((IFeatureLayer)pLayer, "name"); string sFieldName = "NAME"; if (frm.ShowDialog() == DialogResult.Cancel) { return; } sFieldName = frm.strDefFieldName; GeoBaseLib.InitLabel(pGeoFeaturelayer, sFieldName); pGeoFeaturelayer.DisplayAnnotation = true; } else { pGeoFeaturelayer.DisplayAnnotation = false; } m_pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, m_pMapControl.Extent); }
private IFillSymbol method_2(IGeoFeatureLayer igeoFeatureLayer_1) { if (igeoFeatureLayer_1.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) { } return(null); }
private void 生成等高线ToolStripMenuItem_Click(object sender, EventArgs e) { //获取TIN图层 ITinLayer pTinLayer = axSceneControl1.Scene.get_Layer(0) as ITinLayer; ITin pTin = pTinLayer.Dataset as ITin; string contourFileName = pTinLayer.Name + "_Contour"; string contourFileName_shp = WorkSpaceName + @"/" + contourFileName + ".shp"; if (System.IO.File.Exists(contourFileName_shp)) { System.IO.File.Delete(contourFileName_shp); System.IO.File.Delete(System.IO.Path.ChangeExtension(contourFileName_shp, ".dbf")); System.IO.File.Delete(System.IO.Path.ChangeExtension(contourFileName_shp, ".shx")); } IFeatureClass contourFeatureClass = Create_ContourLine(pTin, WorkSpaceName, contourFileName); //添加等高线图层 IFeatureLayer pFeatureLayer = new FeatureLayerClass(); pFeatureLayer.FeatureClass = contourFeatureClass; IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer; pGeoFeatureLayer.DisplayAnnotation = true; pGeoFeatureLayer.DisplayField = "Contour"; pGeoFeatureLayer.Name = contourFileName + "_Contour"; //设置线样式 ILineSymbol pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Color = Get_RGBColor(100, 50, 30); pLineSymbol.Width = 2; ISimpleRenderer pRender = pGeoFeatureLayer.Renderer as ISimpleRenderer; pRender.Symbol = pLineSymbol as ISymbol; axMapControl1.AddLayer(pFeatureLayer as ILayer); }
private static void MapUsingSimpleFillRenderer() { string layerName = CboLayers.GetSelectedLayer(); ILayer layer = GetLayerByName(layerName); string colorName = CboColors.GetSelectedColor(); ICmykColor fillColor = ColorbrewerExtension.GetSingleCMYKColor(); ISimpleFillSymbol fill = new SimpleFillSymbol(); fill.Style = esriSimpleFillStyle.esriSFSSolid; fill.Color = fillColor; ISimpleRenderer simpleRenderer = new SimpleRenderer(); simpleRenderer.Symbol = fill as ISymbol; simpleRenderer.Label = layer.Name; IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer; gFLayer.Renderer = simpleRenderer as IFeatureRenderer; IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument; IMap map = mxDoc.FocusMap; mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography , gFLayer, mxDoc.ActiveView.Extent); }
public static ISymbol GetSymbolByLayer(ILayer layer) { //判断图层是否获取成功 if (layer == null) { return(null); } //利用IFeatureLayer接口访问目标图层,获取图层的第一个要素 //如果获取失败,返回空值 IFeatureLayer featurelayer = layer as IFeatureLayer; IFeatureCursor featurecursor = featurelayer.Search(null, false); IFeature feature = featurecursor.NextFeature(); if (feature == null) { return(null); } //通过IGeoFeatureLayer访问图层,获取图层渲染器 //如果获取失败,返回空值 IGeoFeatureLayer geofeaturelayer = featurelayer as IGeoFeatureLayer; IFeatureRenderer featurerender = geofeaturelayer.Renderer; if (featurerender == null) { return(null); } ISymbol symbol = featurerender.get_SymbolByFeature(feature); /* ISimpleLineSymbol spl = (ISimpleLineSymbol)symbol; * spl.Style = esriSimpleLineStyle.esriSLSDash; * symbol = (ISymbol)spl;*/ return(symbol); }
public static void SetLayerInfoFromXml(IGeoFeatureLayer pGeaFeatureLayer) { IAnnotateLayerPropertiesCollection pAnnoLayerProperCol = pGeaFeatureLayer.AnnotationProperties; pAnnoLayerProperCol.Clear(); ILabelEngineLayerProperties pLabelEngineLayerPro = new LabelEngineLayerPropertiesClass(); IAnnotateLayerProperties pAnnoLayerProperties = pLabelEngineLayerPro as IAnnotateLayerProperties; //从图层节点的XML中读取标注设置(会覆盖上面语句的设置结果) try { XmlNode nodeLayerXml = GetSelectNodeXml(pGeaFeatureLayer); if (nodeLayerXml != null) { ReadLabelConfigFromXML(ref pAnnoLayerProperties, nodeLayerXml, pGeaFeatureLayer.FeatureClass.ShapeType.ToString()); } pAnnoLayerProperCol.Add(pAnnoLayerProperties); //shduan 20110623 添加 pGeaFeatureLayer.DisplayAnnotation = true; } catch { } }
public static ISymbol GetSymbolFromLayer(ILayer layer) { if (layer == null) { return(null); } IFeatureLayer featureLayer = layer as IFeatureLayer; IFeatureCursor featureCursor = featureLayer.Search(null, false); IFeature feature = featureCursor.NextFeature(); if (feature == null) { return(null); } IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer; IFeatureRenderer featureRenderer = geoFeatureLayer.Renderer; if (featureRenderer == null) { return(null); } ISymbol symbol = featureRenderer.get_SymbolByFeature(feature); return(symbol); }
/// <summary> /// Dot Density Render /// </summary> /// <param name="currentLayer"></param> /// <param name="breakCount"></param> /// <author>Shen Yongyuan</author> /// <date>20091114</date> public static void DotDensityRender(ILayer currentLayer, string fieldName) { IGeoFeatureLayer pGeoFeatureL = currentLayer as IGeoFeatureLayer; pGeoFeatureL.ScaleSymbols = true; //Dot Density Render IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass(); IRendererFields pRendererFields = (IRendererFields)pDotDensityRenderer; pRendererFields.AddField(fieldName, "生态"); //Dot Style IDotDensityFillSymbol pDotDensityFillS = new DotDensityFillSymbolClass(); pDotDensityFillS.DotSize = 4; pDotDensityFillS.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(0, 0, 0)); pDotDensityFillS.BackgroundColor = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(239, 228, 190)); //Symbol Array ISymbolArray pSymbolArray = (ISymbolArray)pDotDensityFillS; ISimpleMarkerSymbol pSimpleMarkerS = new SimpleMarkerSymbolClass(); pSimpleMarkerS.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerS.Size = 4; pSimpleMarkerS.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(128, 128, 255)); pSymbolArray.AddSymbol((ISymbol)pSimpleMarkerS); pDotDensityRenderer.DotDensitySymbol = pDotDensityFillS; pDotDensityRenderer.DotValue = 0.05; pDotDensityRenderer.CreateLegend(); pGeoFeatureL.Renderer = (IFeatureRenderer)pDotDensityRenderer; }
public static ArrayList GetIntersectFeature(IGeoFeatureLayer pLayer, IGeometry pGeom) { ArrayList list = new ArrayList(); if (pLayer != null) { if ((pGeom == null) || pGeom.IsEmpty) { return(list); } ISpatialReference reference = (pLayer.FeatureClass as IGeoDataset).SpatialReference; if (reference != null) { pGeom.SpatialReference = reference; pGeom.SnapToSpatialReference(); } ISpatialFilter filter = new SpatialFilter(); filter.Geometry = pGeom; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor o = pLayer.FeatureClass.Search(filter, false); for (IFeature feature = o.NextFeature(); feature != null; feature = o.NextFeature()) { list.Add(feature); } Marshal.ReleaseComObject(o); } return(list); }
private void LabelHighWay(ILayer pLayer) { IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer; if (pGeoFeatureLayer != null) { IAnnotateLayerPropertiesCollection panAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties; panAnnotateLayerPropertiesCollection.Clear(); IRgbColor pColor = new RgbColor(); pColor.Red = 0; pColor.Blue = 0; pColor.Green = 0; IFormattedTextSymbol pTextSymbol = new TextSymbol(); //ITextSymbol pTextSymbol = new TextSymbol(); pTextSymbol.Background = CreateBalloonCallout() as ITextBackground; pTextSymbol.Color = pColor; pTextSymbol.Size = 10; pTextSymbol.Direction = esriTextDirection.esriTDHorizontal; Font font = new System.Drawing.Font("宋体", 10); pTextSymbol.Font = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as stdole.IFontDisp; IBasicOverposterLayerProperties properties = new BasicOverposterLayerProperties(); IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; switch (pFeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPolygon: properties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon; break; case esriGeometryType.esriGeometryPoint: properties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint; break; case esriGeometryType.esriGeometryPolyline: properties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; break; } ILabelEngineLayerProperties2 properties2 = new LabelEngineLayerProperties() as ILabelEngineLayerProperties2; if (properties2 != null) { properties2.Expression = "[LXDM]"; properties2.Symbol = pTextSymbol; properties2.BasicOverposterLayerProperties = properties; IAnnotateLayerProperties p = properties2 as IAnnotateLayerProperties; // p.AnnotationMaximumScale = maxScale; // p.AnnotationMinimumScale = minScale; panAnnotateLayerPropertiesCollection.Add(p); } } if (pGeoFeatureLayer != null) { pGeoFeatureLayer.DisplayAnnotation = true; } _mxDocument.ActivatedView.Refresh(); }
private void SimpleFillToolStripMenuItem_Click(object sender, EventArgs e) { //获得面图层,要求当前地图文档第三个图层为面图层 IFeatureLayer layer = axMapControl1.get_Layer(2) as IFeatureLayer; IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; ISimpleRenderer simpleRender = new SimpleRendererClass(); IColor pLineColor = new RgbColorClass(); pLineColor.RGB = 2256; IColor pFillColor = new RgbColorClass(); pFillColor.RGB = 255; ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Width = 5; pSimpleLineSymbol.Color = pLineColor; ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSCross; pSimpleFillSymbol.Outline = pSimpleLineSymbol; pSimpleFillSymbol.Color = pFillColor; simpleRender.Symbol = pSimpleFillSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; axMapControl1.Refresh(); axTOCControl1.Update(); }
private void ImagePointToolStripMenuItem_Click(object sender, EventArgs e) { IFeatureLayer layer; layer = axMapControl1.get_Layer(0) as IFeatureLayer; //QI到IGeoFeatureLayer IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; //新建SimpleRendererClass对象 SimpleRenderer simpleRender = new SimpleRendererClass(); //指定图片存放的位置 OpenFileDialog pOpenFileDialog = new OpenFileDialog { //Filter = "Image(*.img)|*.img", Title = "打开Image文件" }; pOpenFileDialog.ShowDialog(); string path = pOpenFileDialog.FileName; //string path = Application.StartupPath + @"\symbol\pointPic.BMP"; IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass(); pPictureMarkerSymbol.Size = 40; pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, path); simpleRender.Symbol = pPictureMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; axMapControl1.Refresh(); axTOCControl1.Update(); }
private void lineSimpleDye(ILayer pLayer) { try { IGeoFeatureLayer pGeoFeatLyr = pLayer as IGeoFeatureLayer; //设置线符号 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Width = 0; //定义线的宽度 simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSInsideFrame; //定义线的样式 simpleLineSymbol.Color = pColor; //定义线的颜色 ISymbol symbol = simpleLineSymbol as ISymbol; //更改符号样式 ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = symbol; pGeoFeatLyr.Renderer = pSimpleRenderer as IFeatureRenderer; axMapControl1.Refresh(); axMapControl1.Update(); } catch (Exception ex) { } }
private void button6_Click(object sender, EventArgs e) { IFeatureLayer FoucsedLayer = axMapControl1.ActiveView.FocusMap.get_Layer(comboBox15.SelectedIndex) as IFeatureLayer; IGeoFeatureLayer GLayer = FoucsedLayer as IGeoFeatureLayer; CategoryUniqueValues(GLayer, comboBox16.SelectedItem.ToString()); }
private void DotDensity(IFeatureLayer pFeatLyr, string sFieldName, int intRendererDensity) { IGeoFeatureLayer pGeoFeatureLayer = pFeatLyr as IGeoFeatureLayer; IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass(); IRendererFields pRendererFields = pDotDensityRenderer as IRendererFields; //设置渲染字段 pRendererFields.AddField(sFieldName); //设置填充背景色 IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass(); pDotDensityFillSymbol.DotSize = 3; pDotDensityFillSymbol.BackgroundColor = GetRgbColor(0, 255, 0); //设置渲染符号 ISymbolArray pSymbolArray = pDotDensityFillSymbol as ISymbolArray; ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Color = GetRgbColor(0, 0, 255); pSymbolArray.AddSymbol(pSimpleMarkerSymbol as ISymbol); pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol; //设置渲染密度,即每个点符号所代表的数值大小 pDotDensityRenderer.DotValue = intRendererDensity; //创建图例 pDotDensityRenderer.CreateLegend(); pGeoFeatureLayer.Renderer = pDotDensityRenderer as IFeatureRenderer; axMapControl1.Refresh(); axMapControl1.Update(); Close(); }
public void EnableFeatureLayerLabel(IFeatureLayer pFeaturelayer, string sLableField, IRgbColor pRGB, int size, string angleField) { //判断图层是否为空 if (pFeaturelayer == null) { return; } IGeoFeatureLayer pGeoFeaturelayer = (IGeoFeatureLayer)pFeaturelayer; IAnnotateLayerPropertiesCollection pAnnoLayerPropsCollection; pAnnoLayerPropsCollection = pGeoFeaturelayer.AnnotationProperties; pAnnoLayerPropsCollection.Clear(); stdole.IFontDisp pFont = new stdole.StdFont() as stdole.IFontDisp;; //字体 ITextSymbol pTextSymbol; pFont.Name = "黑体"; pFont.Size = 4; //未指定字体颜色则默认为黑色 if (pRGB == null) { pRGB = new RgbColorClass(); pRGB.Red = 0; pRGB.Green = 0; pRGB.Blue = 0; } pTextSymbol = new TextSymbolClass(); pTextSymbol.Color = (IColor)pRGB; pTextSymbol.Size = size; //标注大小 IBasicOverposterLayerProperties4 pBasicOverposterlayerProps4 = new BasicOverposterLayerPropertiesClass(); switch (pFeaturelayer.FeatureClass.ShapeType)//判断图层类型 { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; break; } pBasicOverposterlayerProps4.PointPlacementMethod = esriOverposterPointPlacementMethod.esriRotationField; //pBasicOverposterlayerProps4.RotationField = angleField; ILabelEngineLayerProperties pLabelEnginelayerProps = new LabelEngineLayerPropertiesClass(); pLabelEnginelayerProps.Expression = "[" + sLableField + "]"; pLabelEnginelayerProps.Symbol = pTextSymbol; pLabelEnginelayerProps.BasicOverposterLayerProperties = pBasicOverposterlayerProps4 as IBasicOverposterLayerProperties; pAnnoLayerPropsCollection.Add((IAnnotateLayerProperties)pLabelEnginelayerProps); pGeoFeaturelayer.DisplayAnnotation = true;//很重要,必须设置 //刷新地图 axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); }
public static void ApplyUniqueValueRenderer(IGeoFeatureLayer fl) { //COD (101,103...) IUniqueValueRenderer uvr = new CustomUniqueValueRenderer(); // UniqueValueRendererClass(); uvr.FieldCount = 1; uvr.set_Field(0, "code"); uvr.DefaultSymbol = (ISymbol)CreateSimpleFillSymbol(0, 0, 255); uvr.UseDefaultSymbol = true; //add values uvr.AddValue("CA01", "CA01", (ISymbol)CreateSimpleFillSymbol(255, 0, 0)); uvr.AddValue("CA02", "CA02", (ISymbol)CreateSimpleFillSymbol(0, 255, 0)); //render fl.Renderer = (IFeatureRenderer)uvr; }
public static void SetLayerColor(IGeoFeatureLayer geolyr, int r, int g, int b) { //ILineSymbol pLineSymbol = new SimpleLineSymbolClass(); //pLineSymbol.Color = CvtRGB(r, g, b); ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = CvtRGB(r, g, b); //pFillSymbol.Outline = pLineSymbol; ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = (ISymbol)pFillSymbol; geolyr.Renderer = pSimpleRenderer as IFeatureRenderer; }
public static void SetLayerAnnotation(IGeoFeatureLayer geolyr, string field) { geolyr.AnnotationProperties.Clear(); IBasicOverposterLayerProperties pBasic = new BasicOverposterLayerPropertiesClass(); ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass(); ITextSymbol textSymbol = new TextSymbolClass(); string lable = "[" + field + "]"; pLableEngine.Expression = lable; pLableEngine.IsExpressionSimple = true; pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape; pLableEngine.BasicOverposterLayerProperties = pBasic; pLableEngine.Symbol = textSymbol; geolyr.AnnotationProperties.Add(pLableEngine as IAnnotateLayerProperties); }
private static Dictionary<string, int> GetAllValues(string fieldName, IGeoFeatureLayer layer) { var results = new Dictionary<string, int>(); IQueryFilter query = new QueryFilter { SubFields = fieldName }; using (var comReleaser = new ComReleaser()) { IFeatureCursor cursor = layer.Search(query, true); comReleaser.ManageLifetime(cursor); IFeature feature; int fieldIndex = cursor.FindField(fieldName); while ((feature = cursor.NextFeature()) != null) { results[feature.Value[fieldIndex].ToString()] = 1; } } return results; }
/// <summary> /// 点图层的简单渲染 /// </summary> /// <param name="pGeoFeatureLayer"></param> public void DefinePointSimpleValueRenderer(IGeoFeatureLayer pGeoFeatureLayer) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Size = 5; pSimpleMarkerSymbol.Outline = true; IRgbColor pLineRgbColor = new RgbColorClass(); pLineRgbColor.RGB = 0; // pLineRgbColor.Red = 0; // pLineRgbColor.Green = 0; // pLineRgbColor.Blue = 0; pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor; pLineRgbColor.Red = 34; pLineRgbColor.Green = 139; pLineRgbColor.Blue = 34; pSimpleMarkerSymbol.Color = pLineRgbColor as IColor; ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = pSimpleMarkerSymbol as ISymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)simpleRender; }
private static void UnHideSelectedFeatures(IGeoFeatureLayer actionLayer) { UpdateRows(actionLayer, null); }
static void UpdateRows(IGeoFeatureLayer actionLayer, string status) { const string sql = "EXEC [dbo].[Location_UpdateStatus] @ProjectId, @AnimalId, @FixDate, @Status;"; string connectionString = BuildConnectionString(actionLayer); using (var connection = new SqlConnection(connectionString)) { using (var cmd = new SqlCommand(sql, connection)) { cmd.Parameters.Add("@ProjectId", SqlDbType.NVarChar, 255); cmd.Parameters.Add("@AnimalId", SqlDbType.NVarChar, 255); cmd.Parameters.Add("@FixDate", SqlDbType.DateTime2); cmd.Parameters.Add("@Status", SqlDbType.Char, 1); cmd.Parameters["@Status"].Value = (object)status ?? DBNull.Value; connection.Open(); var features = ((IFeatureSelection) actionLayer).SelectionSet; ICursor cursor; features.Search(null, true, out cursor); int projectIndex = cursor.FindField("ProjectId"); int animalIndex = cursor.FindField("AnimalId"); int dateIndex = cursor.FindField("FixDate"); IRow row = cursor.NextRow(); while (row != null) { cmd.Parameters["@ProjectId"].Value = row.Value[projectIndex]; cmd.Parameters["@AnimalId"].Value = row.Value[animalIndex]; cmd.Parameters["@FixDate"].Value = row.Value[dateIndex]; cmd.ExecuteNonQuery(); row = cursor.NextRow(); } } } }
public static void DefineUniqueValueRenderer(IGeoFeatureLayer geoFealyr,string fieldName) { // Create color ramp for the symbol in rendere IRandomColorRamp randomColorRamp = new RandomColorRampClass(); randomColorRamp.MinSaturation = 20; randomColorRamp.MaxSaturation = 40; randomColorRamp.MinValue = 85; randomColorRamp.MaxValue = 100; randomColorRamp.StartHue = 76; randomColorRamp.EndHue = 188; randomColorRamp.UseSeed = true; randomColorRamp.Seed = 43; // Create a symbol ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; simpleFillSymbol.Outline.Width = 0.4; // Create the renderer IUniqueValueRenderer uniqueValueRender = new UniqueValueRendererClass(); uniqueValueRender.FieldCount = 1; uniqueValueRender.set_Field(0, fieldName); uniqueValueRender.DefaultSymbol = simpleFillSymbol as ISymbol; uniqueValueRender.UseDefaultSymbol = true; IDisplayTable displayTable = geoFealyr as IDisplayTable; IFeatureCursor feacursor = displayTable.SearchDisplayTable(null, false) as IFeatureCursor; IFeature fea = feacursor.NextFeature(); bool valfound; int fieldIndex; IFields fields = feacursor.Fields; fieldIndex = fields.FindField(fieldName); while(fea!=null) { ISimpleFillSymbol classSymbol = new SimpleFillSymbolClass(); classSymbol.Style = esriSimpleFillStyle.esriSFSSolid; classSymbol.Outline.Width = 0.4; string classValue; classValue = fea.get_Value(fieldIndex) as string; valfound = false; for(int i=0;i<=uniqueValueRender.ValueCount-1;i++) { if(uniqueValueRender.get_Value(i)==classValue) { valfound = true; break; } } if(valfound==false) { uniqueValueRender.AddValue(classValue, fieldName, classSymbol as ISymbol); uniqueValueRender.set_Label(classValue, classValue); uniqueValueRender.set_Symbol(classValue, classSymbol as ISymbol); } fea = feacursor.NextFeature(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(feacursor); randomColorRamp.Size = uniqueValueRender.ValueCount; bool bOK; randomColorRamp.CreateRamp(out bOK); IEnumColors enumColors = randomColorRamp.Colors; enumColors.Reset(); for(int j=0;j<=uniqueValueRender.ValueCount-1;j++) { string xv; xv = uniqueValueRender.get_Value(j); if(xv!="") { ISimpleFillSymbol simplefs = uniqueValueRender.get_Symbol(xv) as ISimpleFillSymbol; simplefs.Color = enumColors.Next(); uniqueValueRender.set_Symbol(xv, simplefs as ISymbol); } } uniqueValueRender.ColorScheme = "Custome"; ITable tbl = displayTable as ITable; bool isString = tbl.Fields.get_Field(fieldIndex).Type == esriFieldType.esriFieldTypeString; uniqueValueRender.set_FieldType(0, isString); geoFealyr.Renderer = uniqueValueRender as IFeatureRenderer; IUID uid = new UIDClass(); uid.Value = "{25AE5C2F-0B57-41C6-A492-31352BAD3A37}"; geoFealyr.RendererPropertyPageClassID = uid as UIDClass; }
protected override void OnActivate() { _moveDeviceAlongLineOnInsert = false; IFeatureLayer layer = ExtensionInfo.FeatureLyrByFCName.ContainsKey(Associated_FeatureClassName) ? ExtensionInfo.FeatureLyrByFCName[Associated_FeatureClassName] : null; if (layer != null) { _currentTargetLayer = layer as IGeoFeatureLayer; if (_currentTargetLayer != null) { _movePointFeedback.Display = ArcMap.Document.ActiveView.ScreenDisplay; _workspace = ExtensionInfo.Editor.EditWorkspace; if (_currentTargetLayer != null) { if (this is IElectricPrimaryDeviceClass && this is IStepTransformerBankClass == false) _moveDeviceAlongLineOnInsert = true; } } else DeactivateCurrentTool(); } }
private void applyRenderer(IGeoFeatureLayer geoLayer, IServerContext mapContext, string fieldName, Classifier classifier) { IClassBreaksRenderer cbRenderer = (IClassBreaksRenderer)mapContext.CreateObject("esriCarto.ClassBreaksRenderer"); cbRenderer.Field = fieldName; ILegendInfo legendInfo = (ILegendInfo)cbRenderer; ILegendGroup legendGroup = legendInfo.get_LegendGroup(0); legendGroup.Heading = "Counts"; int breaks = classifier.getBreaks(); IColor [] pColors = new IColor[breaks]; ISimpleFillSymbol [] symbols = new ISimpleFillSymbol[breaks]; double breakValue; cbRenderer.BreakCount = breaks; IAlgorithmicColorRamp colorRamp = (IAlgorithmicColorRamp)mapContext.CreateObject("esriDisplay.AlgorithmicColorRamp"); IColor startColor, endColor; startColor = createRGBColor(mapContext, 255, 255, 0); endColor = createRGBColor(mapContext, 255, 0, 0); colorRamp.FromColor = startColor; colorRamp.ToColor = endColor; colorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm; colorRamp.Size = breaks; bool created; try { colorRamp.CreateRamp(out created); } catch { this.Label2.Text = "There is not enough data associated with the current extents and attributes selected. A map was not generated. Please try selecting other attributes."; return; } IEnumColors iterColors = colorRamp.Colors; double[] classBreaksArray = (double[])classifier.getClassBreaksArray(); for (int i = 0; i < breaks; i++) { pColors[i] = iterColors.Next(); symbols[i] = (ISimpleFillSymbol)mapContext.CreateObject("esriDisplay.SimpleFillSymbol"); symbols[i].Color = pColors[i]; cbRenderer.set_Symbol(i, (ISymbol)symbols[i]); breakValue = classBreaksArray[i + 1]; cbRenderer.set_Break(i, breakValue); string breakValueString = String.Format("{0:0.00}", breakValue); if (i == 0) { cbRenderer.set_Label(i, "<" + breakValueString); } else { string prevValueString = String.Format("{0:0.00}", classBreaksArray[i]); string label = prevValueString + " < " + breakValueString; cbRenderer.set_Label(i, label); } } geoLayer.Renderer = (IFeatureRenderer)cbRenderer; this.Toc1.ExpandDepth = 1; this.Toc1.Refresh(); }
private void doUniqueValueRenderer(IGeoFeatureLayer gfl) { TesterUtilities.ApplyUniqueValueRenderer(gfl); }
public void InitControls(IMultivariateRenderer pMultiRend, IMap pMap, IGeoFeatureLayer pGeoLayer) { // copy properties from the renderer and map to the form m_eColorCombinationMethod = pMultiRend.ColorCombinationMethod; m_pShapePatternRend = pMultiRend.ShapePatternRend; m_pColorRend1 = pMultiRend.ColorRend1; m_pColorRend2 = pMultiRend.ColorRend2; m_pSizeRend = pMultiRend.SizeRend; if (m_pShapePatternRend != null) { chkShapePattern.CheckState = System.Windows.Forms.CheckState.Checked; cboShapePattern.Enabled = true; } if (m_eColorCombinationMethod == EColorCombinationType.enuComponents) { radComponents.Checked = true; radCombination.Checked = false; UpdateColorComb(); } else { //disabled //radComponents.Checked = false; //radCombination.Checked = true; radComponents.Checked = true; radCombination.Checked = false; UpdateColorComb(); } if (m_pColorRend1 != null) { chkColor.CheckState = System.Windows.Forms.CheckState.Checked; radComponents.Enabled = true; //disabled //radCombination.Enabled = true; radCombination.Enabled = false; } if (m_pSizeRend != null) { chkSize.CheckState = System.Windows.Forms.CheckState.Checked; cboSize1.Enabled = true; } IRotationRenderer pRotRend = null; pRotRend = pMultiRend as IRotationRenderer; if (pRotRend.RotationField != "") { chkRotation.CheckState = System.Windows.Forms.CheckState.Checked; butRotation.Enabled = true; } //ITransparencyRenderer pTransRend = null; //pTransRend = pMultiRend as ITransparencyRenderer; //if (pTransRend.TransparencyField != "") //{ // chkTransparency.CheckState = System.Windows.Forms.CheckState.Checked; // butTransparency.Enabled = true; //} m_pMap = pMap; m_pCurrentLayer = pGeoLayer; m_pRend = pMultiRend as IFeatureRenderer; // we need this object to support the root transparency dialogs m_PageIsDirty = false; }
/// <summary> /// //标注 /// </summary> /// <param name="pGeoFeatLyr"></param> /// <param name="pMap"></param> /// <param name="annoField">字段名称</param> public static void Annotation(IGeoFeatureLayer pGeoFeatLyr, IMap pMap, string annoField,AxMapControl axMapControl1) { IAnnotateMap pAnnoMap=new AnnotateMapClass(); //pAnnoMap = new MaplexAnnotateMapClass(); pMap.AnnotationEngine = pAnnoMap; IGeoFeatureLayer pGeoFeatLayer; pGeoFeatLayer = pGeoFeatLyr; IAnnotateLayerPropertiesCollection pAnnoProps; pAnnoProps = pGeoFeatLyr.AnnotationProperties; pAnnoProps.Clear(); ILabelEngineLayerProperties2 pLabelEngine2 = new MaplexLabelEngineLayerPropertiesClass(); pLabelEngine2.Expression = "[" + annoField + "]"; IMaplexOverposterLayerProperties pMaplexPro = new MaplexOverposterLayerPropertiesClass(); pMaplexPro.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon; pMaplexPro.PolygonPlacementMethod = esriMaplexPolygonPlacementMethod.esriMaplexHorizontalInPolygon; pMaplexPro.CanPlaceLabelOutsidePolygon = false; pMaplexPro.CanRemoveOverlappingLabel = false; pMaplexPro.RepeatLabel = false; pLabelEngine2.OverposterLayerProperties = pMaplexPro as IOverposterLayerProperties; IMapOverposter pMapPos = axMapControl1.Map as IMapOverposter; IOverposterProperties pOP = pMapPos.OverposterProperties; IMaplexOverposterProperties pMaplexOP = pOP as IMaplexOverposterProperties; pMaplexOP.LabelLargestPolygon = false; pAnnoProps.Add(pLabelEngine2 as IAnnotateLayerProperties); pGeoFeatLyr.DisplayAnnotation = true; }
private void styleGipodLyr( IGeoFeatureLayer geolayer ) { IUniqueValueRenderer renderer = new UniqueValueRendererClass(); renderer.FieldCount = 1; renderer.set_Field(0, "hinder"); renderer.set_FieldType(0, false); //renderer.UseDefaultSymbol = true; renderer.DefaultLabel = "other"; ISimpleMarkerSymbol trueMarkerSymbol = new SimpleMarkerSymbolClass(); trueMarkerSymbol.Color = new RgbColorClass(){Red= 255, Blue= 0, Green= 255 }; trueMarkerSymbol.Outline = true; trueMarkerSymbol.OutlineColor = new RgbColorClass() { Red = 0, Blue = 0, Green = 0 }; ; trueMarkerSymbol.Size = 5; trueMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; ISimpleMarkerSymbol falseMarkerSymbol = new SimpleMarkerSymbolClass(); falseMarkerSymbol.Color = new RgbColorClass() { Red = 255, Blue = 0, Green = 0 }; falseMarkerSymbol.Outline = true; falseMarkerSymbol.OutlineColor = new RgbColorClass() { Red = 0, Blue = 0, Green = 0 }; ; falseMarkerSymbol.Size = 5; falseMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; renderer.AddValue("0","", falseMarkerSymbol as ISymbol); renderer.set_Label("0", "Geen hinder"); renderer.AddValue("1", "", trueMarkerSymbol as ISymbol); renderer.set_Label("1", "Veel hinder"); geolayer.Renderer = renderer as IFeatureRenderer; IMxDocument mxDoc = ArcMap.Document; mxDoc.CurrentContentsView.Refresh(null); }
public static ArrayList GetIntersectFeature(IGeoFeatureLayer pLayer, IPolygon pPoly) { return GetIntersectFeature(pLayer, (IGeometry)pPoly); }
public static double QueryXYUnit(IGeoFeatureLayer paramLayer) { if (paramLayer != null) { return QueryXYUnit(paramLayer.FeatureClass); } return double.NaN; }
public static ArrayList GetIntersectFeature(IGeoFeatureLayer pLayer, IGeometry pGeom) { ArrayList list = new ArrayList(); if (pLayer != null) { if ((pGeom == null) || pGeom.IsEmpty) { return list; } ISpatialReference reference = (pLayer.FeatureClass as IGeoDataset).SpatialReference; if (reference != null) { pGeom.SpatialReference = reference; pGeom.SnapToSpatialReference(); } ISpatialFilter filter = new SpatialFilterClass(); filter.Geometry = pGeom; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor o = pLayer.FeatureClass.Search(filter, false); for (IFeature feature = o.NextFeature(); feature != null; feature = o.NextFeature()) { list.Add(feature); } System.Runtime.InteropServices.Marshal.ReleaseComObject(o); } return list; }
private static string BuildConnectionString(IGeoFeatureLayer actionLayer) { // See http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Working_with_SQL_workspaces/0001000003z8000000/SQL // for a description the connection properties: "DBCLIENT", "SERVERINSTANCE", "DATABASE", "AUTHENTICATION_MODE", "USER", "PASSWORD". var connectionProperties = GetProperties(((IDataset)actionLayer).Workspace.ConnectionProperties); #if ARCGIS_10_0 string localServer = connectionProperties["SERVERINSTANCE"]; #else string localServer = connectionProperties["DB_CONNECTION_PROPERTIES"]; #endif string localDatabase = connectionProperties["DATABASE"]; string connectionString = string.Format("server={0};Database={1};", localServer, localDatabase); if (connectionProperties["AUTHENTICATION_MODE"] == "OSA") connectionString += "Trusted_Connection=True;"; else connectionString += "Trusted_Connection=False;" + string.Format("User Id={0};Password={1};", connectionProperties["USER"], connectionProperties["PASSWORD"]); //Connect to the local server to find the master server, and change the connection string appropriately using (var connection = new SqlConnection(connectionString)) { connection.Open(); using (var cmd = new SqlCommand("SELECT [Connection],[Database] FROM [dbo].[LookupQueryLayerServers] WHERE [Location] = 'AKRO'", connection)) { SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); var masterServer = (string)reader["Connection"]; var masterDatabase = (string)reader["Database"]; connectionString = connectionString.Replace(localServer, masterServer).Replace(localDatabase, masterDatabase); } } } return connectionString; }
private void doSimpleRenderer(IGeoFeatureLayer gfl) { TesterUtilities.ApplySimpleRenderer(gfl); }
void IThematic.SingleRender() { //_ftLayer = (IFeatureLayer)_mapControl.get_Layer(0); _geoFeatureLayer = (IGeoFeatureLayer)_ftLayer; _ftClass = _ftLayer.FeatureClass; _table = (ITable)_ftClass; _interval = (this._maxValue - this._minValue) / this._breakCount; _renderer.Field = _fieldName; _renderer.BreakCount = _breakCount; _renderer.SortClassesAscending = true; _colorFrom.Hue = 60; _colorFrom.Saturation = 100; _colorFrom.Value = 96; _colorTo.Hue = 0; _colorTo.Saturation = 100; _colorTo.Value = 96; _algClrRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm; _algClrRamp.FromColor = _colorFrom; _algClrRamp.ToColor = _colorTo; _algClrRamp.Size = _breakCount; bool ok; _algClrRamp.CreateRamp(out ok); _enumColors = _algClrRamp.Colors; IColor pColor; _currentValue = _minValue;//_renderer.MinimumBreak; for (int breakIndex = 0; breakIndex < _breakCount; breakIndex++) { pColor = _enumColors.Next(); _symbol = new SimpleFillSymbolClass(); _symbol.Color = pColor; _symbol.Style = esriSimpleFillStyle.esriSFSSolid; _renderer.set_Break(breakIndex, _currentValue); _renderer.set_Symbol(breakIndex, (ISymbol)_symbol); _currentValue += _interval; } _mapControl.AddLayer(_ftLayer,0); _geoFeatureLayer.Renderer = (IFeatureRenderer)_renderer; _mapControl.ActiveView.Refresh(); _tocControl.Update(); //_tableHistogram.Field = _fieldName; //_tableHistogram.Table = _table; //_classify. }
private void setColor(IGeoFeatureLayer IGFL) { int classCount = 10; ITableHistogram tableHistogram; IBasicHistogram basicHistogram; ITable table; IGeoFeatureLayer geoFeatureLayer; geoFeatureLayer = IGFL; ILayer layer = geoFeatureLayer as ILayer; table = layer as ITable; tableHistogram = new BasicTableHistogramClass(); tableHistogram.Table = table; tableHistogram.Field = "HighTemperature"; basicHistogram = tableHistogram as IBasicHistogram; object values; object frequencys; basicHistogram.GetHistogram(out values, out frequencys); IClassifyGEN classifyGEN = new QuantileClass(); classifyGEN.Classify(values, frequencys, ref classCount); double[] classes; classes = classifyGEN.ClassBreaks as double[]; IEnumColors enumColors = CreateAlgorithmicColorRamp(classes.Length).Colors; IColor color; IClassBreaksRenderer classBreaksRenderer = new ClassBreaksRendererClass(); classBreaksRenderer.Field = "HighTemperature"; classBreaksRenderer.BreakCount = classCount + 1; classBreaksRenderer.SortClassesAscending = true; ISimpleFillSymbol simpleFillSymbol; for (int i = 0; i < classes.Length; i++) { color = enumColors.Next(); simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = color; simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; classBreaksRenderer.set_Symbol(i, simpleFillSymbol as ISymbol); classBreaksRenderer.set_Break(i, classes[i]); } if (geoFeatureLayer != null) geoFeatureLayer.Renderer = classBreaksRenderer as IFeatureRenderer; axMapControl1.ActiveView.Refresh(); }
void IJoin.Perform() { _relClassEdit = (IRelationshipClassCollectionEdit)_featureLayer; _relClassEdit.RemoveAllRelationshipClasses(); _geoFeatureLayer = (IGeoFeatureLayer)_featureLayer; _dspRel = (IDisplayRelationshipClass)_geoFeatureLayer; _memRelFact = new MemoryRelationshipClassFactoryClass(); IObjectClass tblObj = (IObjectClass)_table; _relClass = _memRelFact.Open("test", _geoFeatureLayer.FeatureClass, _joinFieldOnLayer, tblObj, _joinFieldOnTable, "Forwards", "Backwards", _cardinality); _dspRel.DisplayRelationshipClass(_relClass, _type); }
/// <summary> /// 按聚类号对凸包进行渲染 /// </summary> /// <param name="pGeoFeatureLayer"></param> /// <param name="fieldName"></param> public void DefinePointUniqueValueRenderer(IGeoFeatureLayer pGeoFeatureLayer, string fieldName) { IRandomColorRamp pRandomColorRamp = new RandomColorRampClass(); //Create the color ramp for the symbols in the renderer. pRandomColorRamp.MinSaturation = 20; pRandomColorRamp.MaxSaturation = 40; pRandomColorRamp.MinValue = 85; pRandomColorRamp.MaxValue = 100; pRandomColorRamp.StartHue = 76; pRandomColorRamp.EndHue = 188; pRandomColorRamp.UseSeed = true; pRandomColorRamp.Seed = 43; //Create the renderer. IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass(); /* ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; pSimpleFillSymbol.Outline.Width = 0.4; */ ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Size = 5; pSimpleMarkerSymbol.Outline = true; IRgbColor pLineRgbColor = new RgbColorClass(); pLineRgbColor.Red = 0; pLineRgbColor.Green = 0; pLineRgbColor.Blue = 0; pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor; //These properties should be set prior to adding values. pUniqueValueRenderer.FieldCount = 1; pUniqueValueRenderer.set_Field(0, fieldName); pUniqueValueRenderer.DefaultSymbol = pSimpleMarkerSymbol as ISymbol; pUniqueValueRenderer.UseDefaultSymbol = true; IDisplayTable pDisplayTable = pGeoFeatureLayer as IDisplayTable; IFeatureCursor pFeatureCursor = pDisplayTable.SearchDisplayTable(null, false) as IFeatureCursor; IFeature pFeature = pFeatureCursor.NextFeature(); bool ValFound; int fieldIndex; IFields pFields = pFeatureCursor.Fields; fieldIndex = pFields.FindField(fieldName); while (pFeature != null) { /* ISimpleFillSymbol pClassSymbol = new SimpleFillSymbolClass(); pClassSymbol.Style = esriSimpleFillStyle.esriSFSSolid; pClassSymbol.Outline.Width = 0.4; */ ISimpleMarkerSymbol pClassSymbol = new SimpleMarkerSymbolClass(); pClassSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pClassSymbol.Size = 5; pClassSymbol.Outline = true; pClassSymbol.OutlineColor = pLineRgbColor as IColor; string classValue; classValue = pFeature.get_Value(fieldIndex).ToString(); //Test to see if this value was added to the renderer. If not, add it. ValFound = false; for (int i = 0; i <= pUniqueValueRenderer.ValueCount - 1; i++) { if (pUniqueValueRenderer.get_Value(i) == classValue) { ValFound = true; break; //Exit the loop if the value was found. } } //If the value was not found, it's new and will be added. if (ValFound == false) { pUniqueValueRenderer.AddValue(classValue, fieldName, pClassSymbol as ISymbol); pUniqueValueRenderer.set_Label(classValue, classValue); pUniqueValueRenderer.set_Symbol(classValue, pClassSymbol as ISymbol); } pFeature = pFeatureCursor.NextFeature(); } //Since the number of unique values is known, the color ramp can be sized and the colors assigned. pRandomColorRamp.Size = pUniqueValueRenderer.ValueCount; bool bOK; pRandomColorRamp.CreateRamp(out bOK); IEnumColors pEnumColors = pRandomColorRamp.Colors; pEnumColors.Reset(); for (int j = 0; j <= pUniqueValueRenderer.ValueCount - 1; j++) { string xv; xv = pUniqueValueRenderer.get_Value(j); if (xv != "") { ISimpleMarkerSymbol pSimpleMarkerColor = pUniqueValueRenderer.get_Symbol(xv) as ISimpleMarkerSymbol; pSimpleMarkerColor.Color = pEnumColors.Next(); pUniqueValueRenderer.set_Symbol(xv, pSimpleMarkerColor as ISymbol); } } pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer; pGeoFeatureLayer.DisplayField = fieldName; }