Pitney Bowes MapXtreme User Manual

Page 404

Advertising
background image

Chapter 22: Web Feature Service

Creating a Map Layer from a WFS Response

MapXtreme v7.1

411

Developer Guide

// register URL with a specific WFS reader
WfsReaderFactory.RegisterHandler(URL, typeof(WfsReader));

// Get the WFS capabilities of the WFS server using the HTTP GET

method.

try
{

// Get the WFS capabilities of the WFS server using the HTTP

GET method.

WfsCapabilities Capabilities =

WfsClient.GetCapabilities(RequestMethod.GET, URL);

}
catch
{

MessageBox.Show("Please check if " + URL + " is a valid WFS

URL");

return;

}

// Do something with the the WfsCapabilities here...

// Get the schema for the USA feature type
string[] TypeNames = new string[] { "miwfs:USA" };

// Do something with the schema here...
XmlSchema usaSchema = WfsClient.DescribeFeatureType(URL,

TypeNames);

// Get all features from the USA feature type
MultiFeatureCollection usa = WfsClient.GetFeature(URL, TypeNames,

null, null, -1, null);

IFeatureCollection fc = usa[0];

// iterate over the Usa MultiFeatureCollection and add each
// IFeatureCollection to a MemTable, etc...
TableInfoMemTable memTableInfo = new

TableInfoMemTable("myMemTable");

foreach (Column c in fc.Columns) {

memTableInfo.Columns.Add(c);

}
Table memTable =

Session.Current.Catalog.CreateTable(memTableInfo);

memTable.InsertFeatures(fc);

// create a layer from the MemTable
FeatureLayer featureLayer = new FeatureLayer(memTable);

// create the map and add the layer
Map map = Session.Current.MapFactory.CreateEmptyMap(new Size(500,

500));

map.Layers.Add(featureLayer);

Advertising