[DEVEXPRESS/WINFORM] ShapefileDataAdapter 클래스 : 벡터 데카르트(Vector Cartesian) 맵 생성하기
DevExpress/WinForm 2020. 6. 15. 22:36728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.IO;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraMap;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : XtraForm
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
#region 데카르트 맵 좌표계를 설정한다.
CartesianMapCoordinateSystem cartesianMapCoordinateSystem = new CartesianMapCoordinateSystem();
#endregion
#region 맵 컨트롤을 설정한다.
MapControl mapControl = new MapControl();
mapControl.Name = "mapControl";
mapControl.Parent = this;
mapControl.Dock = DockStyle.Fill;
mapControl.CoordinateSystem = cartesianMapCoordinateSystem;
mapControl.NavigationPanelOptions.ShowCoordinates = false;
mapControl.NavigationPanelOptions.ShowKilometersScale = false;
mapControl.NavigationPanelOptions.ShowMilesScale = false;
mapControl.MaxZoomLevel = 5d;
mapControl.CenterPoint = new CartesianPoint(0d, 0d);
#endregion
#region 어트리뷰트 항목 키 공급자를 설정한다.
AttributeItemKeyProvider attributeItemKeyProvider = new AttributeItemKeyProvider();
attributeItemKeyProvider.AttributeName = "CATEGORY";
#endregion
#region 키 색상 색상화기를 설정한다.
KeyColorColorizer keyColorColorizer = new KeyColorColorizer();
keyColorColorizer.PredefinedColorSchema = PredefinedColorSchema.Palette;
keyColorColorizer.ItemKeyProvider = attributeItemKeyProvider;
#endregion
#region 색상화기 키 항목 1을 설정한다.
ColorizerKeyItem colorizerKeyItem1 = new ColorizerKeyItem();
colorizerKeyItem1.Key = 1;
colorizerKeyItem1.Name = "Restaurant";
keyColorColorizer.Keys.Add(colorizerKeyItem1);
#endregion
#region 색상화기 키 항목 2를 설정한다.
ColorizerKeyItem colorizerKeyItem2 = new ColorizerKeyItem();
colorizerKeyItem2.Key = 2;
colorizerKeyItem2.Name = "Business room";
keyColorColorizer.Keys.Add(colorizerKeyItem2);
#endregion
#region 색상화기 키 항목 3을 설정한다.
ColorizerKeyItem colorizerKeyItem3 = new ColorizerKeyItem();
colorizerKeyItem3.Key = 3;
colorizerKeyItem3.Name = "Bathroom";
keyColorColorizer.Keys.Add(colorizerKeyItem3);
#endregion
#region 색상화기 키 항목 4를 설정한다.
ColorizerKeyItem colorizerKeyItem4 = new ColorizerKeyItem();
colorizerKeyItem4.Key = 4;
colorizerKeyItem4.Name = "Living room";
keyColorColorizer.Keys.Add(colorizerKeyItem4);
#endregion
#region 색상화기 키 항목 5를 설정한다.
ColorizerKeyItem colorizerKeyItem5 = new ColorizerKeyItem();
colorizerKeyItem5.Key = 5;
colorizerKeyItem5.Name = "Other";
keyColorColorizer.Keys.Add(colorizerKeyItem5);
#endregion
#region 색상화기 키 항목 6을 설정한다.
ColorizerKeyItem colorizerKeyItem6 = new ColorizerKeyItem();
colorizerKeyItem6.Key = 6;
colorizerKeyItem6.Name = "Service room";
keyColorColorizer.Keys.Add(colorizerKeyItem6);
#endregion
#region 색상화기 키 항목 7을 설정한다.
ColorizerKeyItem colorizerKeyItem7 = new ColorizerKeyItem();
colorizerKeyItem7.Key = 7;
colorizerKeyItem7.Name = "Pool";
keyColorColorizer.Keys.Add(colorizerKeyItem7);
#endregion
#region 색상화기 키 항목 8을 설정한다.
ColorizerKeyItem colorizerKeyItem8 = new ColorizerKeyItem();
colorizerKeyItem8.Key = 8;
colorizerKeyItem8.Name = "Gym";
keyColorColorizer.Keys.Add(colorizerKeyItem8);
#endregion
#region 데카르트 소스 좌표계를 설정한다.
CartesianSourceCoordinateSystem cartesianSourceCoordinateSystem = new CartesianSourceCoordinateSystem();
#endregion
#region 도형 파일 데이터 어댑터를 설정한다.
string path = Path.Combine(Application.StartupPath, "DATA\\hotel1.shp");
ShapefileDataAdapter shapefileDataAdapter = new ShapefileDataAdapter();
shapefileDataAdapter.FileUri = new Uri(path, UriKind.Absolute);
shapefileDataAdapter.SourceCoordinateSystem = cartesianSourceCoordinateSystem;
#endregion
#region 벡터 항목 레이어를 설정한다.
VectorItemsLayer vectorItemsLayer = new VectorItemsLayer();
vectorItemsLayer.Colorizer = keyColorColorizer;
vectorItemsLayer.Data = shapefileDataAdapter;
mapControl.Layers.Add(vectorItemsLayer);
#endregion
#region 색상 리스트 레전드를 설정한다.
ColorListLegend colorListLegend = new ColorListLegend();
colorListLegend.Header = "Room Type";
colorListLegend.Layer = vectorItemsLayer;
mapControl.Legends.Add(colorListLegend);
#endregion
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요