
Chương 5. CarbonTools
98
5.2.2.3. Lớp CarbonTools.Core.WFS.HandlerWFS
Các thuộc tính
STT Tên thuộc tính Kiểu dữ liệu Ý nghĩa
1 Data CarbonTools.Core.Features.
DataFeatures
Dữ liệu lấy được từ
server sau khi thực
hiện request
2 Source CarbonTools.Core.WFS.Source
WFS
Thông tin request
cần gởi lên server
3 Synchronous boolean Cho biết request này
được thực hiện theo
kiểu đồng bộ hay
không đồng bộ
4 OperationDone EventHandler Đây là 1 delegate. có
tác dụng thông báo
khi mà quá trình
nhận dữ liệu không
đồng bộ được thực
hiện xong.
5 ProgressChang
ed
EventHandler Đây là 1 delegate, có
tác dụng thông báo
về tình trạng của tiến
trình nhận dữ liệu
không đồng bộ.
Bảng 5.6. Các thuộc tính của CarbonTools.Core.WFS.HandlerWFS
Phương thức GetFeature(): Gởi request lên server với các thông tin chứa
trong Source và lấy kết quả về, lưu trong Data.

Chương 5. CarbonTools
99
Ví dụ thực hiện GetFeature request
//Thiết lập các thông tin cho request
SourceWFS source = new SourceWFS();
source.Address =
“http://localhost/OpenGISServer/VNesOpenGISServer.aspx”;
source.Layers.Add(new WFSLayerType(“quan”));
source.Layers.Add(new WFSLayerType(“duong”));
//Thực hiện gởi request bằng phương pháp không đồng //bộ.
HandlerWFS handlerWFS = new HandlerWFS( source);
handlerWFS.ProgressChanged += new
EventHandler(handler_ProgressChanged);
handlerWFS.OperationDone += new
EventHandler(handlerWFS_OperationDone);
handlerWFS.Synchronous = false;
handlerWFS.GetFeature();
//Lấy kết quả trả về
LayerItemCollection collection = handlerWFS.Data.Features;
//Duyệt qua danh sách các Feature
foreach (Item item in items)
{
string sName = item.Name;
if (item is ItemElement)
{
//Nếu đây là thuộc tính bình thường
if (((ItemElement)item).Value != null)
string sValue =((ItemElement)item).Value;
else if (item is ItemMember)
{}
//Nếu đây là thuộc tính địa lý (tức là các kiểu
//Point, LineString…)
else if (item is ItemGeometry)
{

Chương 5. CarbonTools
100
//Nếu như thuộc tính này là 1 Point
if (((ItemGeometry)(item)).GeometryObject is
CarbonTools.Core.Geometries.Point)
{
CarbonTools.Core.Geometries.Point point =
(CarbonTools.Core.Geometries.Point)
((ItemGeometry)
(Item)).GeometryObject;
string sX = point.X;
if (point.Y != Double.MaxValue)
string sY = point.Y;
if (point.Z != Double.MaxValue)
string sZ = point.Z;
}
//Nếu thuộc tính này là 1 LineString
else if (((ItemGeometry)(item)).GeometryObject
is
CarbonTools.Core.Geometries.LineString)
{
}
//Nếu thuộc tính này là 1 Polygon
else if (((ItemGeometry)(item)).GeometryObject
is
CarbonTools.Core.Geometries.Polygon)
{
System.Collections.CollectionBase coll =
((CarbonTools.Core.Geometries.Polygon)
((ItemGeometry)(item)).GeometryObject).
Interior as
System.Collections.CollectionBase;
if (coll.Count > 0)

Chương 5. CarbonTools
101
}
//Nếu thuộc tính này là 1 Collection
else if (((ItemGeometry)(item)).GeometryObject
is
System.Collections.CollectionBase)
{
System.Collections.CollectionBase coll =
(System.Collections.CollectionBase)
((ItemGeometry)(item)).GeometryObject;
//Nếu nó là 1 PointCollection
if(((ItemGeometry)item)).GeometryObject is
CarbonTools.Core.Geometries.PointCollection)
{}
//Nếu nó là 1 LineStringCollection
else if
(((ItemGeometry)(item)).GeometryObject is
CarbonTools.Core.Geometries.
LineStringCollection)
{
}
//Nếu thuộc tính này là PolygonCollection
elseif
(((ItemGeometry)(item)).GeometryObject is
CarbonTools.Core.Geometries.PolygonCollection)
}
else if (((ItemGeometry)(item)).GeometryObject is
CarbonTools.Core.Geometries.Envelope)

Chương 5. CarbonTools
102
{
}
if (item.Attributes.Count > 0)
{
IEnumerator enumerator =
item.Attributes.GetEnumerator();
while (enumerator.MoveNext())
{
ItemElement elem = enumerator.Current as
ItemElement;
string sName = elem.Name;
string sValue = elem.Value;
}
}
}
}
5.3. Dùng CarbonTools gởi GetMap request
Để thực hiện gởi 1 GetMap request ta cần sử dụng các lớp quan trọng sau:
HandlerWMS, DataRaster, SourceWMS
5.3.1. Lớp CarbonTools.Core.WMS.SourceWMS
Lớp này chứa các thông tin cần thiết để thực hiện 1 GetMap request.
Các thuộc tính của lớp