Pitney Bowes MapXtreme User Manual

Page 400

Advertising
background image

Chapter 22: Web Feature Service

Using the MapXtreme WFS Client Programmatically

MapXtreme v7.1

407

Developer Guide

Spatial operators: BBox, Equals, Disjoint, Intersects, Within, Contains

Non-spatial comparison operators: Logical operators: AND, OR, and NOT; PropertyIsEqualTo,
PropertyIsGreaterThan, PropertyIsGreaterThanOrEqualTo, PropertyIsLessThan,
PropertyIsLessThanOrEqualTo, PropertyIsNotEqualTo,

Simple arithmetic operators: Add, Div, Mul, Sub

L

The HTTP protocol mandates a URL length for a GetFeature request of no more than 2048
characters. Keep in mind that a filter could easily create a URL much larger than that, which
will cause an exception.

Code Example: Requesting Features Using Filters

The following C# code example illustrates how filters on WFS data can be used to return only the
data you need. In this case, we query the WFS server to learn what features are available, then
request that it return only features that match the population column of WorldCap with a value of
1,000,000 or greater. The output from the GetCapabilities and GetFeatures methods is displayed
after the code example.

private void doWFS()
{
string wfsUrl = @"http://localhost/MXTWFS/GetFeatures.ashx";

/// first we need to get the list of capabilities and list out

/// the tables available

///
MapInfo.Wfs.Client.WfsCapabilities capabilities =
MapInfo.Wfs.Client.WfsClient.GetCapabilities(

MapInfo.Wfs.Client.RequestMethod.GET,

wfsUrl);
MapInfo.Wfs.Client.FeatureTypeList featureTypeList =
capabilities.FeatureTypeList;
IList featureTypes = featureTypeList.FeatureTypes;
foreach (MapInfo.Wfs.Client.FeatureType featureType in
featureTypes)
{
System.Console.WriteLine("FeatureType: " +
featureType.Name);
}

/// Now we can look at a specific table to see its contents
///
string featureTypeName = "miwfs:WorldCap"; // Name taken from

/// the above output

MapInfo.Data.MultiFeatureCollection mfc =
MapInfo.Wfs.Client.WfsClient.GetFeature(wfsUrl,
new string[] { featureTypeName }, null, "GML3", -1, null);
DisplayFeatureCollection(mfc[0]);

/// Now we can apply a filter
///

Advertising