Ethan,
Somehow missed your reply, so a slightly delayed thanks.
I am, unfortunately, still getting some problems with setting up to use the WFS.
The code I used to set it up looks like:
using System;
using System.Net;
using System.Windows;
using ThinkGeo.MapSuite;
using ThinkGeo.MapSuite.Drawing;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Wpf;
namespace WmtsLayer
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// Basic MAP and Overlay settings
map.MapUnit = GeographyUnit.Meter;
map.CurrentExtent = new RectangleShape(299575, 188357, 299952, 188022);
LayerOverlay layerOverlay = new LayerOverlay();
map.Overlays.Add(layerOverlay);
// OS need TLS 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// WFS Settings
var wfsLayer = ConfigureWFS();
// Add WMS or EFS to overlay
wfsLayer.Open();
layerOverlay.Layers.Add(wfsLayer);
var area = ThinkGeo.MapSuite.Styles.AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.DarkBlue);
var line = ThinkGeo.MapSuite.Styles.LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.BrightBlue, 3, true);
var point = ThinkGeo.MapSuite.Styles.PointStyles.CreateSimplePointStyle(ThinkGeo.MapSuite.Styles.PointSymbolType.Circle, GeoColor.SimpleColors.BrightRed, 10);
wfsLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = area;
wfsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = line;
wfsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = point;
wfsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
}
private WfsFeatureLayer ConfigureWFS()
{
WfsFeatureLayer wfsLayer = new WfsFeatureLayer("https://osdatahubapi.os.uk/omse/wfs", "osme:TopographicArea");
wfsLayer.SendingWebRequest += Layer_SendingWebRequest;
return wfsLayer;
}
private void Layer_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
{
e.WebRequest = System.Net.HttpWebRequest.Create(e.WebRequest.RequestUri.AbsoluteUri + "&key=XXXXXXXX");
}
}
}
The generated request looks like:
https://osdatahubapi.os.uk/omse/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=osme:TopographicArea&BBOX=-36175.1191613734,120367.523233153,181516.992918394,338059.635312921&propertyname=SHAPE&key=XXXXXXXX
This does return some data, as confirmed by entering in a browser (copy uploaded)
wfs.xml (107.0 KB)
but also generates the following exception:
System.Xml.XmlException
HResult=0x80131940
Message=ReadElementContentAs() methods cannot be called on an element that has child elements. Line 10, position 8.
Source=ThinkGeo.MapSuite.Wpf
StackTrace:
at ThinkGeo.MapSuite.Wpf.Tile.DrawException(GeoCanvas geoCanvas, Exception exception)
at ThinkGeo.MapSuite.Wpf.Tile.Draw(GeoCanvas geoCanvas)
at ThinkGeo.MapSuite.Wpf.Tile.Q1Y=(Object status)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
All the best,
Jonathan