■ ShapefileDataAdapter 클래스를 사용해 도형 파일에서 데이터를 로드하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
using System; using System.Drawing; using System.Reflection; using DevExpress.XtraEditors; using DevExpress.XtraMap; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 파일 경로 /// </summary> private string filePath = "DATA/Countries.shp"; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Uri baseURI = new Uri(Assembly.GetEntryAssembly().Location); #region 도형 파일 데이터 어댑터를 설정한다. ShapefileDataAdapter shapefileDataAdapter = new ShapefileDataAdapter(); shapefileDataAdapter.FileUri = new Uri(baseURI, filePath); this.vectorItemsLayer.Data = shapefileDataAdapter; #endregion #region 도형 어트리뷰트 값 제공자를 설정한다. ShapeAttributeValueProvider shapeAttributeValueProvider = new ShapeAttributeValueProvider(); shapeAttributeValueProvider.AttributeName = "GDP_MD_EST"; #endregion #region CHOROPLETH 색상화기를 설정한다. ChoroplethColorizer choroplethColorizer = new ChoroplethColorizer(); choroplethColorizer.ColorItems.AddRange ( new ColorizerColorItem[] { new ColorizerColorItem(Color.FromArgb(0x5f, 0x8b, 0x95)), new ColorizerColorItem(Color.FromArgb(0x79, 0x96, 0x89)), new ColorizerColorItem(Color.FromArgb(0xa2, 0xa8, 0x75)), new ColorizerColorItem(Color.FromArgb(0xce, 0xbb, 0x5f)), new ColorizerColorItem(Color.FromArgb(0xf2, 0xcb, 0x4e)), new ColorizerColorItem(Color.FromArgb(0xf1, 0xc1, 0x49)), new ColorizerColorItem(Color.FromArgb(0xe5, 0xa8, 0x4d)), new ColorizerColorItem(Color.FromArgb(0xd6, 0x86, 0x4e)), new ColorizerColorItem(Color.FromArgb(0xc5, 0x64, 0x50)), new ColorizerColorItem(Color.FromArgb(0xba, 0x4d, 0x51)) } ); choroplethColorizer.RangeStops.AddRange ( new double[] { 0, 3000, 10000, 18000, 28000, 44000, 82000, 185000, 1000000, 2500000, 15000000 } ); choroplethColorizer.ValueProvider = shapeAttributeValueProvider; #endregion this.vectorItemsLayer.Colorizer = choroplethColorizer; #region 색상 스케일 레전드를 설정한다. ColorScaleLegend colorScaleLegend = new ColorScaleLegend(); colorScaleLegend.Header = "GDP by Countries"; colorScaleLegend.Description = "In US dollars"; colorScaleLegend.RangeStopsFormat = "0,B"; colorScaleLegend.Layer = this.vectorItemsLayer; this.mapControl.Legends.Add(colorScaleLegend); #endregion } #endregion } } |