Chương 5. CarbonTools
98
5.2.2.3. Lp CarbonTools.Core.WFS.HandlerWFS
Các thuc tính
STT Tên thuc tính Kiu d liu Ý nghĩa
1 Data CarbonTools.Core.Features.
DataFeatures
D liu ly được t
server sau khi thc
hin request
2 Source CarbonTools.Core.WFS.Source
WFS
Thông tin request
cn gi lên server
3 Synchronous boolean Cho biết request này
được thc hin theo
kiu đồng b hay
không đồng b
4 OperationDone EventHandler Đây là 1 delegate. có
tác dng thông báo
khi mà quá trình
nhn d liu không
đồng b được thc
hin xong.
5 ProgressChang
ed
EventHandler Đây là 1 delegate, có
tác dng thông báo
v tình trng ca tiến
trình nhn d liu
không đồng b.
Bng 5.6. Các thuc tính ca CarbonTools.Core.WFS.HandlerWFS
Phương thc GetFeature(): Gi request lên server vi các thông tin cha
trong Source và ly kết qu v, lưu trong Data.
Chương 5. CarbonTools
99
Ví d thc hin GetFeature request
//Thiết lp 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”));
//Thc hin gi request bng 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();
//Ly kết qu tr v
LayerItemCollection collection = handlerWFS.Data.Features;
//Duyt qua danh sách các Feature
foreach (Item item in items)
{
string sName = item.Name;
if (item is ItemElement)
{
//Nếu đây là thuc 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à thuc tính địa lý (tc là các kiu
//Point, LineString…)
else if (item is ItemGeometry)
{
Chương 5. CarbonTools
100
//Nếu như thuc 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 thuc tính này là 1 LineString
else if (((ItemGeometry)(item)).GeometryObject
is
CarbonTools.Core.Geometries.LineString)
{
}
//Nếu thuc 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 thuc 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 thuc 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 gi GetMap request
Để thc hin gi 1 GetMap request ta cn s dng các lp quan trng sau:
HandlerWMS, DataRaster, SourceWMS
5.3.1. Lp CarbonTools.Core.WMS.SourceWMS
Lp này cha các thông tin cn thiết để thc hin 1 GetMap request.
Các thuc tính ca lp