




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、學(xué)習(xí)圖層符號(hào)化地圖符號(hào)不僅具有確定的空間位置以及空間地物的性質(zhì):例如在一個(gè)城市管線系統(tǒng)中不同的線符號(hào)表示不同類(lèi)型的管線,不同的點(diǎn)符號(hào)表示不同類(lèi)型的設(shè)備等等,而且地圖符號(hào)也可以表達(dá)與空間位置相關(guān)的豐富信息:例如人口密度符號(hào)可以直觀的表示人口數(shù)量的空間分布情況。所以地圖數(shù)據(jù)的符號(hào)化決定著地圖以何種“面目”展現(xiàn)給地圖的使用者,自此空間數(shù)據(jù)的符號(hào)化對(duì)GIS開(kāi)發(fā)有非常重要的意義。ArcGISEngine9.3提供了豐富的控件和組件庫(kù)來(lái)實(shí)現(xiàn)圖層符號(hào)化的相關(guān)功能。ArcGIS Engine9.3提供了SymbologyControl控件用于顯示ArcGIS符號(hào)庫(kù)中的符號(hào)(關(guān)于ArcGIS符號(hào)請(qǐng)查找相關(guān)文檔)
2、,而組件庫(kù)中的組件對(duì)象分為Color ,Symbol, Renderer(渲染)三大系列,圖層符號(hào)化就是通過(guò)多個(gè)組件對(duì)象來(lái)合作完成。4.1目標(biāo) 1.熟悉ArcGIS Engine符號(hào)化之Color(顏色)體系2.熟悉ArcGIS Engine符號(hào)化之Symbol(符號(hào))體系3.熟悉ArcGIS Engine符號(hào)化之Renderer( 渲染)體系4.利用ESRI自帶的符號(hào)庫(kù)進(jìn)行符號(hào)化圖層4.2準(zhǔn)備工作 1.IDE:Visual Studio 2005/2008(集成開(kāi)發(fā)環(huán)境,簡(jiǎn)稱(chēng)IDE Integrated Develop Environment )2.ArcGIS Engine Develop
3、er kit 9.33.自造一份用于唯一值符號(hào)化的點(diǎn)數(shù)據(jù)(文章內(nèi)有說(shuō)明)4.3符號(hào)化Color(顏色)體系4.3.1 ArcGIS顏色模型 ArcGIS提供Color(顏色)的模型有多種分別是:· RGB顏色模型:最常用,所有顏色都是通過(guò)紅色(Red)、綠色(Green)、藍(lán)色(Blue)這三原色的混合來(lái)顯示。· CMY顏色模型:青(Cyan)、洋紅(Magenta)和黃(Yellow)三種顏色的簡(jiǎn)寫(xiě),是相減混色模式,用這種方法產(chǎn)生的顏色之所以稱(chēng)為相減色,主要用于印刷中。· HSV顏色模型:色彩(H-hue),純度(S-saturation飽和度),明度(V-va
4、lue純度)。· Gray模型:沒(méi)有彩色的,灰度圖像由位信息組成,并使用256級(jí)的灰色來(lái)模擬顏色層次。· HLS模型: Hue(色相)、Luminance(亮度)、Saturation(飽和度)。 圖 如上圖所示Color對(duì)象是一個(gè)抽象類(lèi),它包括個(gè)子類(lèi):它有5個(gè)顏色子類(lèi),即CmykColor(k-黑)、RGBColor、HSVColor、HLSColor和GrayColor,它們可以使用IColor接口定義的方法設(shè)置顏色對(duì)象的基本屬性。在ArcGIS engine中最常使用的兩種顏色模型是RGB和HSV,RGB類(lèi)實(shí)現(xiàn)IRgb
5、Color接口,而HSV類(lèi)則實(shí)現(xiàn)IHsvColor接口,兩個(gè)接口分別定義了設(shè)置一個(gè)RGBColor對(duì)象和RGBColor對(duì)象需傳遞的值。接下來(lái)以一個(gè)函數(shù)來(lái)通過(guò)R,G,B值來(lái)構(gòu)建一個(gè)RGBColor對(duì)象private IRgbColor GetRGB(int r,int g,int b)IRgbColor pRgbColor= new RgbColorClass();/構(gòu)建一個(gè)RgbColorClasspRgbColor.Red = r;/設(shè)置Red屬性pRgbColor.Green = g;/設(shè)置Green屬性pRgbColor.Blue = b;/設(shè)置Blue屬性return pRgbCol
6、or;4.3.2 ColorRamp對(duì)象在地圖符號(hào)化的過(guò)程中,需要的顏色常常不是一種,而是隨機(jī)或有序產(chǎn)生的一組顏色。如果對(duì)某一個(gè)圖層進(jìn)行符號(hào)化需要上百種顏色,如圖所示,程序開(kāi)發(fā)者肯定不能逐個(gè)產(chǎn)生出來(lái)。ArcGIS Engine提供了ColorRamp對(duì)象:圖ColorRamp類(lèi)的對(duì)象可以產(chǎn)生顏色帶,這個(gè)類(lèi)實(shí)現(xiàn)了IColorRamp接口,它定義了一系列顏色帶的屬性,如 Size(產(chǎn)生多少種顏色),Colors(顏色帶 IEnumColor)。ColorRamp類(lèi)是一個(gè)抽象類(lèi),它包括4個(gè)子類(lèi)分別是:RandomColorRamp(隨機(jī)顏色帶)、PresetColorRamp(預(yù)設(shè)顏色帶)、Algo
7、rithmicColorRamp(起止顏色帶)(Algorithmic算法的規(guī)則系統(tǒng)的algorithm梯度,斜坡)、MultiPartColorRamp(疊加顏色帶),它們的說(shuō)明如表一所示。表一RandomColorRamp 使用HSV顏色模型來(lái)確定一串顏色 PresetColorRamp 預(yù)設(shè)的顏色模式,可存儲(chǔ)13種顏色 AlgorithmicColorRamp 用起始顏色、終止顏色確定一個(gè)顏色帶,起始、終止顏色使用HSV模型 MultiPartColorRamp 疊加產(chǎn)生顏色帶 在GIS應(yīng)用開(kāi)發(fā)中用到比較多得是RandomColorRamp(隨機(jī)顏色帶)和AlgorithmicColor
8、Ramp(起止顏色帶)接下來(lái)詳細(xì)介紹一下這兩個(gè)顏色帶。AlgorithmicColorRamp是通過(guò)起止顏色來(lái)確定多個(gè)在這兩個(gè)顏色之間的色帶。AlgorithmicColorRamp類(lèi)實(shí)現(xiàn)了兩個(gè)接口:IColorRamp和IAlgorithmicColorRamp,兩個(gè)接口之間是接口繼承關(guān)系,后者包含了前者所有的方法和屬性。4.3.3生成顏色帶實(shí)例 接下來(lái)制作一個(gè)實(shí)例演示AlgorithmicColorRamp(起止顏色帶)的Demo:.創(chuàng)建一個(gè)窗體,在窗體上添加5個(gè)Picturebox用于分別顯示產(chǎn)生的包含5個(gè)顏色的起始顏色帶中的顏色,如圖3所示圖32.在“生成顏色帶
9、”Button的Click事件中生成顏色帶,代碼片段如下所示:private void button1_Click(object sender, EventArgs e)/創(chuàng)建一個(gè)新AlgorithmicColorRampClass對(duì)象IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();/創(chuàng)建起始顏色對(duì)象IRgbColor startColor = new RgbColor();startColor.Red = 255;startColor.Green = 0;startColor.Blue = 0;/創(chuàng)建終
10、止顏色對(duì)象IRgbColor endColor = new RgbColor();endColor.Red = 0;endColor.Green = 255;endColor.Blue = 0;/設(shè)置AlgorithmicColorRampClass的起止顏色屬性algColorRamp.ToColor = startColor;algColorRamp.FromColor = endColor;(ToColor-the last color;FromColor-the first color 代碼中位置是否顛倒?)/設(shè)置梯度類(lèi)型algColorRamp.Algorithm = esriCol
11、orRampAlgorithm.esriCIELabAlgorithm;以下補(bǔ)充內(nèi)容,用來(lái)指定運(yùn)算法則Algorithm的類(lèi)型( esriColorRampAlgorithm ConstantsConstantValueDescriptionesriHSVAlgorithm0Use the HSV colorramp algorithm.esriCIELabAlgorithm1Use the CIE Lab colorramp algorithm.CIE Lab標(biāo)準(zhǔn)色彩值esriLabLChAlgorithm2Use the LabLCh colorramp algorithm.)/設(shè)置顏色帶
12、顏色數(shù)量algColorRamp.Size = 5;/創(chuàng)建顏色帶bool bture = true;algColorRamp.CreateRamp(out bture);關(guān)于out 與ref的區(qū)別:兩種參數(shù)類(lèi)型的設(shè)計(jì)思想不同,ref的目的在于將值類(lèi)型參數(shù)當(dāng)作引用型參數(shù)傳遞到函數(shù),是函數(shù)的輸入?yún)?shù),并且在函數(shù)內(nèi)部的任何改變也都將影響函數(shù)外部該參數(shù)的值;而out的目的在于獲取函數(shù)的返回值,是輸出參數(shù),由函數(shù)內(nèi)部計(jì)算得到的值再回傳到函數(shù)外部,因此必須在函數(shù)內(nèi)部對(duì)該參數(shù)賦值,這將沖掉函數(shù)外部的任何賦值,使得函數(shù)外部賦值毫無(wú)意義。表現(xiàn)為: 1、out必須在函數(shù)體內(nèi)初始化,這使得在外面初始化變得沒(méi)意義。也
13、就是說(shuō),out型的參數(shù)在函數(shù)體內(nèi)不能得到外面?zhèn)鬟M(jìn)來(lái)的初始值。2、ref必須在函數(shù)體外初始化。3、兩者在函數(shù)體內(nèi)的任何修改都將影響到函數(shù)體外面。/使用IEnumColors獲取顏色帶IEnumColors pEnumColors = null;pEnumColors = algColorRamp.Colors;/設(shè)置個(gè)picturebox的背景色為產(chǎn)生顏色帶的個(gè)顏色this.pictureBox1.BackColor = ColorTranslator.FromOle(pEnumColors.Next().RGB);this.pictureBox2.BackColor = ColorTransl
14、ator.FromOle(pEnumColors.Next().RGB);this.pictureBox3.BackColor = ColorTranslator.FromOle(pEnumColors.Next().RGB);this.pictureBox4.BackColor = ColorTranslator.FromOle(pEnumColors.Next().RGB);this.pictureBox5.BackColor = ColorTranslator.FromOle(pEnumColors.Next().RGB);ColorTranslator :Translates an O
15、LE color value to a GDI+ Color structure.Object Linking and Embedding,對(duì)象連接與嵌入,簡(jiǎn)稱(chēng)OLE技術(shù)運(yùn)行點(diǎn)擊Button 結(jié)果如圖4所示:圖4RandomColorRamp對(duì)象產(chǎn)生隨機(jī)顏色帶,RandomColorRamp也需要設(shè)定一個(gè)范圍,但是這個(gè)范圍是HSV顏色模型的,顏色將在這個(gè)范圍內(nèi)隨機(jī)出現(xiàn)。 RandomColorRamp類(lèi)實(shí)現(xiàn)了IRandomColorRamp接口以下是生成RandomColorRamp的代碼片段IRandomColorRamp pRandomColorRamp = new RandomColor
16、RampClass(); /* 制作一系列介于橘黃色和藍(lán)綠色之間的隨機(jī)顏色pRandomColorRamp.StartHue = 40;int 0-360pRandomColorRamp.EndHue = 120;pRandomColorRamp.MinValue = 65; int 0-100pRandomColorRamp.MaxValue = 90;pRandomColorRamp.MinSaturation = 25; int 0-100pRandomColorRamp.MaxSaturation = 45;pRandomColorRamp.Size = 20; The number
17、of colors that will be generated by the CreateRamp method.pRandomColorRamp.Seed = 23; The seed of the random number generator.隨機(jī)數(shù)的種子bool bture = true;pRandomColorRamp.CreateRamp(out bture); Generates a color ramp with length determined by Size value.IEnumColors pEnumColors = pRandomColorRamp.Colors
18、/* 對(duì)pEnumColors進(jìn)行操作4.4符號(hào)化Symbol(符號(hào))體系A(chǔ)rcGIS Engine9.3為開(kāi)發(fā)人員提供了32種符號(hào),主要分為三大類(lèi)符號(hào)MarkerSymbol(點(diǎn)符號(hào))、 LineSymbol(線符號(hào))和FillSymbol(填充符號(hào))來(lái)繪制地理要素的幾何圖形。此外還有兩種特殊類(lèi)型的符號(hào):一種是TextSymbol用于文字標(biāo)注;另一種是3D Chart符號(hào),用于顯示餅圖等三維對(duì)象,如需詳細(xì)了解請(qǐng)查找?guī)椭臋n。MarkerSymbol用于修飾點(diǎn)對(duì)象的符號(hào),它擁有十三個(gè)子類(lèi)如表所示,其中不同的子類(lèi)可以產(chǎn)生不同類(lèi)型的點(diǎn)符號(hào)。所有的MarkerSymbol類(lèi)都實(shí)現(xiàn)了IMarkerSy
19、mbol接口,這個(gè)接口定義了標(biāo)記符號(hào)的公共方法和屬性,如角度、顏色、大小和X,Y偏移量等。表二點(diǎn)符號(hào)類(lèi)型描 述ArrowMarkerSymbol預(yù)定義的箭頭符號(hào)BarChartSymbol柱狀圖符號(hào)CharacterMarker3DSymbol三維字體符號(hào)CharacterMarkerSymbol字體符號(hào)Marker3DSymbol3D 符號(hào)MultiLayerMarkerSymbol多個(gè)符號(hào)疊加產(chǎn)生新點(diǎn)符號(hào)PictureMarkerSymbol圖片符號(hào)(bmp或emf)PiechartSymbol餅圖符號(hào)SimpleMarker3DSymbol簡(jiǎn)單3D符號(hào)SimpleMarkerSymbol
20、簡(jiǎn)單符號(hào)StackedChartSymbol堆疊符號(hào)TextMarkerSymbol文字符號(hào)用來(lái)符號(hào)化點(diǎn) 常用的有以下5種 類(lèi)型:圖如何創(chuàng)建MarkerSymbol?接下來(lái)以SimpleMarkerSymbol構(gòu)建為例演示如何創(chuàng)建一個(gè)點(diǎn)符號(hào):/創(chuàng)建SimpleMarkerSymbolClass對(duì)象ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();/創(chuàng)建RgbColorClass對(duì)象為pSimpleMarkerSymbol設(shè)置顏色I(xiàn)RgbColor pRgbColor = new
21、RgbColorClass();pRgbColor.Red = 255;pSimpleMarkerSymbol.Color = pRgbColor as IColor;有必要嗎?/設(shè)置pSimpleMarkerSymbol對(duì)象的符號(hào)類(lèi)型,選擇鉆石pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;/設(shè)置pSimpleMarkerSymbol對(duì)象大小,設(shè)置為pSimpleMarkerSymbol.Size = 5;/顯示外框線pSimpleMarkerSymbol.Outline = true;/為外框線設(shè)置顏色I(xiàn)Rg
22、bColor pLineRgbColor = new RgbColorClass();pLineRgbColor.Green = 255;pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor;/設(shè)置外框線的寬度pSimpleMarkerSymbol.OutlineSize = 1; 如何使用這個(gè)符號(hào),在接下來(lái)介紹Renderer對(duì)象的時(shí)候?qū)榇蠹已菔救绾斡脛?chuàng)建的點(diǎn)符號(hào)去符號(hào)化一個(gè)圖層。x is the X coordinate, in pixels, where the mouse button was pressed refer
23、enced against the origin (0, 0) of the MapControl (the top left hand corner). y is the Y coordinate, in pixels, where the mouse button was pressed referenced against the origin (0, 0) of the MapControl (the top left hand corner).mapX is the X coordinate, in map units, where the mouse button was
24、 pressed referenced against the origin (bottom left hand corner) of the IMapControl2:Map. The values returned are in IMapControl2:MapUnits.mapY is the Y coordinate, in map units, where the mouse button was pressed referenced against the origin (bottom left hand corner) of the IMapControl2:
25、Map. The values returned are in IMapControl2:MapUnitsLineSymbol對(duì)象是用于修飾線型幾何對(duì)象的符號(hào),它擁有八個(gè)子類(lèi)如表所示,其中不同的子類(lèi)可以產(chǎn)生不同類(lèi)型的線符號(hào),所有的LineSymbol類(lèi)都實(shí)現(xiàn)了ILineSymbol接口, ILineSymbol定義了兩個(gè)公共屬性:Color和Width。表三線符號(hào)類(lèi)型描述CartographicLineSymbol實(shí)心或者虛線線符號(hào)HashLineSymbol離散線符號(hào)MarkerLineSymbol點(diǎn)線符號(hào)MultiLayerLineSymbol多符號(hào)疊加產(chǎn)生新線符號(hào)PictureLineS
26、ymbol圖片線符號(hào)SimpleLine3DSymbol 3D 線符號(hào)SimpleLineSymbol預(yù)定義風(fēng)格的線符號(hào)TextureLineSymbol (3DAnalyst)紋理貼圖線符號(hào)常用的LineSymbol如下圖所示:
27、60; 圖6如何創(chuàng)建LineSymbol?接下來(lái)以MarkerLineSymbol構(gòu)建為例演示如何創(chuàng)建一個(gè)線符號(hào):IArrowMarkerSymbol pArrowMarker = new ArrowMarkerSymbolClass();IRgbColor pRgbColor = new RgbColorClass();pRgbColor.Red = 255;pArrowMarker.Color = pRgbColoras IColor; pArrowMarker.Length = 10;pArrowMarker.Width = 8;pArrowMarker.Style = e
28、sriArrowMarkerStyle.esriAMSPlain;IMarkerLineSymbol pMarkerLine = new MarkerLineSymbolClass();pMarkerLine.MarkerSymbol = arrowMarker;IRgbColor pLineColor = new RgbColorClass();pLineColor.Blue = 255;pMarkerLine.Color = pLineColor as IColor;FillSymbol是用來(lái)修飾如多邊形等具有面積的幾何形體的符號(hào)對(duì)象,它擁有十一個(gè)子類(lèi)如表4所示它實(shí)現(xiàn)了IFillSymbo
29、l,這個(gè)接口定義了兩個(gè)屬性Color和OutLine,以滿足所有類(lèi)型的FillSymbol對(duì)象的公共屬性設(shè)置。表四填充符號(hào)類(lèi)型描述ColorRampSymbol (Carto)用于渲染Raster數(shù)據(jù)的顏色帶ColorSymbol (Carto)用于渲染Raster數(shù)據(jù)的顏色符號(hào)DotDensityFillSymbol點(diǎn)密度填充符號(hào)GradientFillSymbol漸變填充符號(hào)LineFillSymbol包含線符號(hào)的填充符號(hào)MarkerFillSymbol包含點(diǎn)符號(hào)的填充符號(hào)MultiLayerFillSymbol多符號(hào)疊加產(chǎn)生新填充符號(hào)PictureFillSymbol圖片填充符號(hào)Rast
30、erRGBSymbol用于渲染Raster數(shù)據(jù)RGBSymbolSimpleFillSymbol簡(jiǎn)單填充符號(hào)TextureFillSymbol紋理貼圖填充符號(hào)常用的FillSymbol如下圖所示: 圖如何創(chuàng)建FillSymbol?接下來(lái)以MarkerLineSymbol構(gòu)建為例演示如何創(chuàng)建一個(gè)線符號(hào):/為填充符號(hào)創(chuàng)
31、建外框線符號(hào)IColor pLineColor = new RgbColorClass();ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass();pCartoLineSymbol.Width = 2;pCartoLineSymbol.Color = pLineColor;/創(chuàng)建一個(gè)填充符號(hào)ISimpleFillSymbol pSmplFillSymbol = new SimpleFillSymbol();/設(shè)置填充符號(hào)的屬性IColor pRgbClr = new RgbColorClass()
32、;IFillSymbol pFillSymbol = pSmplFillSymbol;pFillSymbol.Color = pRgbClr;pFillSymbol.Outline = pCartoLineSymbol;如果沒(méi)有ArcGIS Desktop使用經(jīng)驗(yàn)的開(kāi)發(fā)看了以上代碼片段會(huì)一頭霧水,不明白填充符號(hào)的創(chuàng)建為什么還要?jiǎng)?chuàng)建線符號(hào)等等,如果有ArcGIS Desktop使用經(jīng)驗(yàn)就會(huì)非常容易理解這些符號(hào)的創(chuàng)建的機(jī)制,如圖8是SimpleFillSymbol設(shè)置信息。所以熟悉ArcGIS Desktop的使用對(duì)開(kāi)發(fā)人員進(jìn)行ArcGIS Engine開(kāi)發(fā)非常有用。圖8TextSymbol對(duì)象是
33、用于修飾文字元素的,文字元素在要素標(biāo)注等方面很有用處。TextSymbol符號(hào)最重要的設(shè)置對(duì)象是它的字符,它實(shí)現(xiàn)了三個(gè)主要的接口來(lái)設(shè)置字符:ITextSymbol 、 ISimpleTextSymbol 和 IFormattedTextSymbol 。ITextSymbol接口是定義文本字符樣式的主要接口,它定義的ITextSymbol:Font屬性是產(chǎn)生一個(gè)TextSymbol符號(hào)的關(guān)鍵??梢允褂肐FontDisp接口來(lái)設(shè)置字體的大小和是否是粗體、傾斜等屬性。使用ITextSymbol接口還可以定義TextSymbol對(duì)象的顏色、角度、水平排列方式、垂直排列方式和文本等內(nèi)容。 以下是一個(gè)構(gòu)建
34、TextSymbol的函數(shù):/<summary>/生成文本符號(hào)/</summary>/<param name="pTxtSymbol">文本符號(hào)</param>/<param name="sFontName">字體名稱(chēng)</param>/<param name="iFont">字體大小</param>/<param name="iColor">字體顏色</param>public static vo
35、id MakeTextSymbol(ref ITextSymbol pTxtSymbol, string sFontName, int iFont, int iColor)try Font后無(wú)Name屬性?decimal)iFont;IRgbColor pRGBColor = new RgbColorClass();pRGBColor.RGB = iColor;pTxtSymbol.Color = (IColor)pRGBColor;pTxtSymbol.Angle = 0;pTxtSymbol.RightToLeft = false;pTxtSymbol.HorizontalAlignmen
36、t = esriTextHorizontalAlignment.esriTHACenter;pTxtSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;catch (Exception Err)MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);3DChartSymbol是一個(gè)抽象類(lèi),它擁有三個(gè)子類(lèi):BarChart、PieChart和StackedChart。如圖9所示:
37、圖9BarChartSymbol是最常用的三維著色符號(hào),它使用不同類(lèi)型的柱子來(lái)代表一個(gè)要素類(lèi)中不同的屬性,而柱子的高度取決于屬性值的大小。PieChartSymbol符號(hào)進(jìn)行著色的方法是使用一個(gè)餅圖來(lái)顯示不同要素類(lèi)中的不同屬性,不同的屬性按照它們的數(shù)值大小占有一個(gè)餅圖中的不同比例的扇形區(qū)域。PieChartSymbol符號(hào)進(jìn)行著色的方法是使用一個(gè)餅圖來(lái)顯示不同要素類(lèi)中的不同屬性,不同的屬性按照它們的數(shù)值大小占有一個(gè)餅圖中的不同比例的扇形區(qū)域。至于如何創(chuàng)建這些3DChartSymbol符號(hào)這里不再提供代碼片段演示,讀者可以根據(jù)前邊學(xué)習(xí)的知識(shí),自己操作ArcGIS Desktop使用3DChart
38、Symbol制作專(zhuān)題圖,然后根據(jù)ArcGIS Engine的幫助文檔開(kāi)發(fā)創(chuàng)建3DChartSymbol。4.5使用ServerStyle如果熟悉ArcGIS Desktop的使用,就會(huì)對(duì)Style符號(hào)庫(kù)文件有所了解,相對(duì)應(yīng)的在ArcGIS Engine開(kāi)發(fā)中對(duì)應(yīng)的是ServerStyle符號(hào)庫(kù),它的結(jié)構(gòu)體系如圖10所示??梢酝ㄟ^(guò)專(zhuān)門(mén)的轉(zhuǎn)換程序把ArcGIS Desktop Style符號(hào)庫(kù)轉(zhuǎn)換為ArcGIS Engine所能夠使用的ServerStyle符號(hào)庫(kù)。用于獲取ServerStyle符號(hào)庫(kù)中的符號(hào)主要涉及到以下接口如表所示:表接口名稱(chēng)功能描述IStyleGallery用于管理Style
39、 GalleryIStyleGalleryStorage管理Style Gallery中的符號(hào)庫(kù)文件IStyleGalleryClass控制符號(hào)庫(kù)中Style Gallery ClassIEnumStyleGalleryItem枚舉一組Style Gallery itemsIStyleGalleryItem定義Style Galle ry itme如何獲取到一個(gè)符號(hào)庫(kù)中符號(hào)?接下來(lái)以獲取ESRI符號(hào)庫(kù)中名稱(chēng)為Rose的符號(hào)的流程:1.首先構(gòu)建一個(gè)ServerStyleGallery對(duì)象2.其次使用IStyleGalleryStorage接口的AddFile方法加載ServerStyle文件3.
40、遍歷ServerGallery中的Class,如果是FillSymbol使用IStyleGallery的GetItems方法返回一個(gè)可枚舉的包含一系列StyleGalleryItem的EnumStyleGalleryItem對(duì)象。4.遍歷EnumServerStyleGalleryItme枚舉對(duì)象中的StylegalleryItme如果名稱(chēng)是Rose即可獲取ESRI符號(hào)庫(kù)中名稱(chēng)為Rose的StylegalleryItme,然后通過(guò)IStyleGalleryItem的Item屬性即可轉(zhuǎn)換為ISymbol。整個(gè)流程圖如圖11所示: &
41、#160; 圖114.6SymbologyControl控件SymbologyControl用來(lái)顯示ServerStyle符號(hào)庫(kù)中的符號(hào)樣式,可以選擇在該控件上選擇一個(gè)符號(hào)用來(lái)符號(hào)化一個(gè)圖層或者作為一個(gè)Element的符號(hào)。使用SymbologyControl可以再設(shè)計(jì)的模式下在其屬性頁(yè)中加載ServerStyle符
42、號(hào)庫(kù)文件,同樣也可以使用的LoadStyleFile和RemoveFile方法加載和移除Serverstyle符號(hào)庫(kù)文件。運(yùn)行效果如圖12所示: 圖124.7符號(hào)化之Renderer( 渲染)體系表四要素符號(hào)化類(lèi)型描述SimpleRender簡(jiǎn)單符號(hào)化UniqueValueRender唯一值符號(hào)化BiUniqueValueRender雙變量唯一值符號(hào)化ChartRender圖表符號(hào)化Cla
43、ssBreaksRenderer分類(lèi)等級(jí)符號(hào)化DotDensityRenderer點(diǎn)密度符號(hào)化ProportionalSymbolRenderer根據(jù)屬性值設(shè)置符號(hào)大小進(jìn)行符號(hào)化ScaleDependentRenderer依比例尺符號(hào)化RepresentationRenderer制圖表達(dá)符號(hào)化CoTrackSymbologyRenderer(TrackingAnalyst)軌跡符號(hào)化(應(yīng)用于TrackingAnaylyst擴(kuò)展模塊)EnhancedInfoRenderder(TrackingAnalyst)增強(qiáng)信息符號(hào)化(應(yīng)用于TrackingAnaylyst擴(kuò)展模塊)UniqueValueT
44、extRenderer(TrackingAnalyst)唯一值文本符號(hào)化(應(yīng)用于TrackingAnaylyst擴(kuò)展模塊)NAStopRenderer(NetworkAnalyst)停止符號(hào)化(應(yīng)用于網(wǎng)絡(luò)分析擴(kuò)展模塊)FeatureVertexRenderer(SurveyExt)要素定點(diǎn)符號(hào)化(應(yīng)用于測(cè)量分析擴(kuò)展模塊)SharedEdgeRenderer(EditorExt)用于繪制拓?fù)湓爻S玫囊胤?hào)化類(lèi)型主要有以下6種類(lèi)型,如圖13所示:圖13要素符號(hào)化類(lèi)型描述RasterRGBRenderer柵格RGB符號(hào)化RasterUniqueValueRenderer唯一值符號(hào)化RasterC
45、olormapRenderer雙變量唯一值符號(hào)化RasterClassifyColorRampRenderer圖表符號(hào)化RasterStretchColorRampRenderer分類(lèi)等級(jí)符號(hào)化RasterDiscreteColorRenderer點(diǎn)密度符號(hào)化 柵格符號(hào)化類(lèi)型結(jié)構(gòu)圖如圖14所示:圖14以下代碼片段是對(duì)一個(gè)RasterLayer進(jìn)行RasterStretchColorRampRenderer符號(hào)化操作:/<summary>/ StretchColorRamp符號(hào)化RasterLayer/</summary>/<param na
46、me="pRasterLayer">RasterLayer</param>public void SetStretchColorRampRenderer(IRasterLayer pRasterLayer)try/創(chuàng)建RasterStretchColorRampRendererClass對(duì)象IRasterStretchColorRampRenderer pRStretchRender= new RasterStretchColorRampRendererClass();/QI到IRasterRendererIRasterRenderer pRasterRe
47、nder=pRStretchRender as IRasterRenderer;pRasterRender.Raster = pRasterLayeras IRaster; 強(qiáng)制轉(zhuǎn)換不成功?pRasterRender.Update();/創(chuàng)建兩個(gè)起始顏色I(xiàn)RgbColor pFromRgbColor = new RgbColorClass();pFromRgbColor.Red = 255;IRgbColor pToRgbColor = new RgbColorClass();pToRgbColor.Blue = 255;/創(chuàng)建起止顏色帶IAlgorithmicColorRamp pAlgor
48、ithmicColorRamp = new AlgorithmicColorRampClass();pAlgorithmicColorRamp.Size = 255;pAlgorithmicColorRamp.FromColor = pFromRgbColor as IColor;pAlgorithmicColorRamp.ToColor = pToRgbColor as IColor;bool btrue= true;pAlgorithmicColorRamp.CreateRamp(out btrue);/選擇拉伸顏色帶符號(hào)化的波段pRStretchRender.BandIndex = 0;
49、/設(shè)置拉伸顏色帶符號(hào)化所采用的顏色帶pRStretchRender.ColorRamp = pAlgorithmicColorRamp as IColorRamp;pRasterRender.Update();/符號(hào)化RasterLayerpRasterLayer.Renderer = pRasterRender;catch(Exception Err)MessageBox.Show(Err.Message,"提示",MessageBoxButtons.OK,MessageBoxIcon.Information);4.8利用ESRI自帶的符號(hào)庫(kù)進(jìn)行唯一值符號(hào)化一圖層開(kāi)發(fā)實(shí)例
50、圖1 5圖 16圖17/<summary>/獲取符號(hào)庫(kù)中符號(hào)/</summary>/<param name="sServerStylePath">符號(hào)庫(kù)全路徑名稱(chēng)</param>/<param name="sGalleryClassName">GalleryClass名稱(chēng)</param>/<param name="symbolName">符號(hào)名稱(chēng)</param>/<returns>符號(hào)</returns>privat
51、e ISymbol GetSymbol(string sServerStylePath, string sGalleryClassName, string symbolName)try/ServerStyleGallery對(duì)象IStyleGallery pStyleGaller = new ServerStyleGalleryClass();IStyleGalleryStorage pStyleGalleryStorage = pStyleGaller as IStyleGalleryStorage;IEnumStyleGalleryItem pEnumSyleGalleryItem=null
52、;IStyleGalleryItem pStyleGallerItem = null;IStyleGalleryClass pStyleGalleryClass = null;/使用IStyleGalleryStorage接口的AddFile方法加載ServerStyle文件-*pStyleGalleryStorage.AddFile(sServerStylePath);/遍歷ServerGallery中的Classfor (int i = 0; i < pStyleGaller.ClassCount; i+)pStyleGalleryClass = pStyleGaller.get_C
53、lass(i);if (pStyleGalleryClass.Name != sGalleryClassName) continue;/獲取EnumStyleGalleryItem對(duì)象pEnumSyleGalleryItem = pStyleGaller.get_Items(sGalleryClassName, sServerStylePath, "");pEnumSyleGalleryItem.Reset();/遍歷pEnumSyleGalleryItempStyleGallerItem = pEnumSyleGalleryItem.Next()
54、;while (pStyleGallerItem != null)if (pStyleGallerItem.Name = symbolName)/獲取符號(hào)ISymbol pSymbol = pStyleGallerItem.Item as ISymbol;Marshal.ReleaseComObject(pEnumSyleGalleryItem);Marshal.ReleaseComObject(pStyleGalleryClass);return pSymbol;pStyleGallerItem = pEnumSyleGalleryItem.Next();Marshal.ReleaseCom
55、Object(pEnumSyleGalleryItem);Marshal.ReleaseComObject(pStyleGalleryClass); return null;catch (Exception Err)MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);return null;/<summary>/設(shè)置要素圖層唯一值符號(hào)化/</summary>/<param name="pFeatureLayer"></param>private void UniqueValueRenderFlyr(IFeatureLayer pFeatureLayer)try/創(chuàng)建UniqueValueRendererClass對(duì)象IUniqueValueRenderer pUV
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年藝術(shù)生聯(lián)考專(zhuān)項(xiàng)考試試卷及答案重點(diǎn)
- 2025年心理學(xué)入門(mén)知識(shí)測(cè)試題及答案
- 2025年甘肅省中考語(yǔ)文試卷真題(含標(biāo)準(zhǔn)答案)
- 2025年舞蹈藝術(shù)與表演技巧期末考試試題及答案
- 2025年無(wú)人機(jī)技術(shù)應(yīng)用與管理考試試卷及答案
- 2025年數(shù)字媒體藝術(shù)專(zhuān)業(yè)考試試卷及答案
- 2025年農(nóng)村經(jīng)濟(jì)與管理考試試卷及答案
- 2025年編程語(yǔ)言與軟件開(kāi)發(fā)能力評(píng)估試題及答案
- 2025年電氣工程及其自動(dòng)化專(zhuān)業(yè)考試試卷及答案
- 2025年甘肅省武威市民勤縣收成鎮(zhèn)選聘專(zhuān)業(yè)化管理村文書(shū)筆試參考題庫(kù)及答案詳解一套
- 山東電動(dòng)伸縮雨棚施工方案
- 新媒體營(yíng)銷(xiāo)技術(shù)與應(yīng)用PPT完整全套教學(xué)課件
- 第5章紅外教學(xué)課件
- 卡氏肺孢子蟲(chóng)肺炎
- 大足縣某水庫(kù)除險(xiǎn)加固工程施工組織設(shè)計(jì)
- 基于單片機(jī)數(shù)字電壓表電路設(shè)計(jì)外文文獻(xiàn)原稿和譯文
- JJG 1149-2022電動(dòng)汽車(chē)非車(chē)載充電機(jī)(試行)
- 2023版浙江評(píng)審衛(wèi)生高級(jí)專(zhuān)業(yè)技術(shù)資格醫(yī)學(xué)衛(wèi)生刊物名錄
- GB/T 1689-1998硫化橡膠耐磨性能的測(cè)定(用阿克隆磨耗機(jī))
- GB/T 16823.3-2010緊固件扭矩-夾緊力試驗(yàn)
- 江蘇省金陵中學(xué)2023學(xué)年物理高一下期末調(diào)研試題(含答案解析)
評(píng)論
0/150
提交評(píng)論