catch (Exception Err) { return null; } }
private IPolygon MergePolygons(IPolygon firstPolygon, IPolygon SecondPolygon) { try {
//创建一个Polygon对象
IGeometryCollection pGCollection1 = new PolygonClass();
IGeometryCollection pGCollection2 = firstPolygon as IGeometryCollection; IGeometryCollection pGCollection3 = SecondPolygon as IGeometryCollection; //添加firstPolygon
pGCollection1.AddGeometryCollection(pGCollection2); //添加SecondPolygon
pGCollection1.AddGeometryCollection(pGCollection3); //QI至ITopologicalOperator
ITopologicalOperator pTopological = pGCollection1 as ITopologicalOperator; //执行Simplify操作 pTopological.Simplify();
IPolygon pPolygon = pGCollection1 as IPolygon; //返回Polygon对象 return pPolygon; }
catch (Exception Err) { return null; } }
唯一值渲染代码:
public UniqueValueRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer,int pCount, string pFieldName) {
IGeoFeatureLayer pGeoFeaturelayer = pFtLayer as IGeoFeatureLayer; IUniqueValueRenderer pUnique = new UniqueValueRendererClass(); pUnique.FieldCount = 1;
pUnique.set_Field(0, pFieldName);
ISimpleFillSymbol pSimFill = new SimpleFillSymbolClass(); //给颜色
IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);
IFeature pFt = pFtCursor.NextFeature(); IFillSymbol pFillSymbol1; ////添加第一个符号
//pFillSymbol1 = new SimpleFillSymbolClass();
//pFillSymbol1.Color = GetRGBColor(103, 252, 179) as IColor; ////添加第二个符号
//IFillSymbol pFillSymbol2 = new SimpleFillSymbolClass(); //pFillSymbol2.Color = GetRGBColor(125, 155, 251) as IColor;
//创建并设置随机色谱从上面的的图可以看出我们要给每一个值定义一种颜色,我们可以创建色谱,但是色谱的这些参数
IRandomColorRamp pColorRamp = new RandomColorRampClass(); pColorRamp.StartHue = 0; pColorRamp.MinValue = 20; pColorRamp.MinSaturation = 15; pColorRamp.EndHue = 360; pColorRamp.MaxValue = 100; pColorRamp.MaxSaturation = 30; pColorRamp.Size = pCount ;
//pColorRamp.Size = pUniqueValueRenderer.ValueCount; bool ok = true;
pColorRamp.CreateRamp(out ok);
IEnumColors pEnumRamp = pColorRamp.Colors; //IColor pColor = pEnumRamp.Next(); int pIndex =pFt.Fields.FindField(pFieldName);
//因为我只有24条记录,所以改变这些,这些都不会超过255或者为负数.求余 int i = 0;
while (pFt != null) {
IColor pColor = pEnumRamp.Next(); if(pColor ==null) {
pEnumRamp.Reset(); pColor = pEnumRamp.Next(); }
//以下注释代码为自定义的两种颜色 ,如果不使用随机的颜色,可以采用这样的 //if (i % 2 == 0) //{
// pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol1 as ISymbol); //} //else //{
// pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol2 as ISymbol);
//} //i++;
pFillSymbol1 = new SimpleFillSymbolClass(); pFillSymbol1.Color = pColor;
pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol1 as ISymbol);
pFt = pFtCursor.NextFeature(); // pColor = pEnumRamp.Next(); }
pGeoFeaturelayer.Renderer = pUnique as IFeatureRenderer;
pMapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); }
private IRgbColor GetRGBColor(int R, int G, int B)//子类赋给父类 {
IRgbColor pRGB;
pRGB = new RgbColorClass(); pRGB.Red = R; pRGB.Green = G; pRGB.Green = B; return pRGB; } }
第二部分 AO GIS应用开发
1、 ArcView、AecEdit和ArcInfo并不是一个软件的名称,
它是桌面版GIS的一种版本代码,这三种版本的软件系统都是由ArcMap、ArcCatalog、ArcScene等单个软件组成的,但是他们包含的GIS功能不一样。其中ArcInfo功能最强。
2、 GIS服务器可以通过网络发布地理信息,它包括ArcGIS Server、
ArcIMS和ArcSDE三种软件。ArcGIS Server,通常用于建构企
业级别的互联网GIS应用;ArcIMS则是一个可定制扩展的,能够在网络上发布地理信息的网络地图发布系统;ArcSDE是一个空间数据引擎,他可以用于管理关系数据库,以实现地理数据的海量存储等高级特性。