本文整理匯總了C#中SharpMap.Utilities.Wfs.WfsFeatureTypeInfo類的典型用法代碼示例。如果您正苦於以下問題:C# WfsFeatureTypeInfo類的具體用法?C# WfsFeatureTypeInfo怎麽用?C# WfsFeatureTypeInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WfsFeatureTypeInfo類屬於SharpMap.Utilities.Wfs命名空間,在下文中一共展示了WfsFeatureTypeInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetFeatureGETRequest
/// <summary>
/// This method returns the query string for 'GetFeature'.
/// </summary>
/// <param name="featureTypeInfo">A <see cref="WFS.WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="boundingBox">The bounding box of the query</param>
/// <param name="filter">An instance implementing <see cref="IFilter"/></param>
public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, BoundingBox boundingBox, IFilter filter)
{
string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix) ? string.Empty : featureTypeInfo.Prefix + ":";
string filterString = string.Empty;
if (filter != null)
{
filterString = filter.Encode();
filterString = filterString.Replace("<", "%3C");
filterString = filterString.Replace(">", "%3E");
filterString = filterString.Replace(" ", "");
filterString = filterString.Replace("*", "%2a");
filterString = filterString.Replace("#", "%23");
filterString = filterString.Replace("!", "%21");
}
StringBuilder filterBuilder = new StringBuilder();
filterBuilder.Append("&filter=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML + "%22%3E%3CBBOX%3E%3CPropertyName%3E");
filterBuilder.Append(qualification);
filterBuilder.Append(featureTypeInfo.Geometry._GeometryName);
filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName=%22EPSG:" + featureTypeInfo.SRID + "%22%3E");
filterBuilder.Append("%3Cgml:coordinates%3E");
filterBuilder.Append(System.Xml.XmlConvert.ToString(boundingBox.Left) + ",");
filterBuilder.Append(System.Xml.XmlConvert.ToString(boundingBox.Bottom) + "%20");
filterBuilder.Append(System.Xml.XmlConvert.ToString(boundingBox.Right) + ",");
filterBuilder.Append(System.Xml.XmlConvert.ToString(boundingBox.Top));
filterBuilder.Append("%3C/gml:coordinates%3E%3C/gml:Box%3E%3C/BBOX%3E");
filterBuilder.Append(filterString);
filterBuilder.Append("%3C/Filter%3E");
return "?SERVICE=WFS&Version=1.0.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
"&PROPERTYNAME=" + qualification + featureTypeInfo.Geometry._GeometryName +
"&SRS =" + featureTypeInfo.SRID + filterBuilder.ToString();
}
示例2: GeometryFactory
/// <summary>
/// Protected constructor for the abstract class.
/// </summary>
/// <param name="httpClientUtil">A configured <see cref="HttpClientUtil"/> instance for performing web requests</param>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="labelInfo">A FeatureDataTable for labels</param>
protected GeometryFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo,
FeatureDataTable labelInfo)
{
_FeatureTypeInfo = featureTypeInfo;
Factory = featureTypeInfo.Factory;
_httpClientUtil = httpClientUtil;
createReader(httpClientUtil);
try
{
if (labelInfo != null)
{
_LabelInfo = labelInfo;
var pathNodes = new IPathNode[labelInfo.Columns.Count];
for (var i = 0; i < pathNodes.Length; i++)
{
pathNodes[i] = new PathNode(_FeatureTypeInfo.FeatureTypeNamespace, _LabelInfo.Columns[i].ColumnName, (NameTable)_XmlReader.NameTable);
}
_LabelNode = new AlternativePathNodesCollection(pathNodes);
}
}
catch (Exception ex)
{
Trace.TraceError("An exception occured while initializing the label path node!");
throw ex;
}
initializePathNodes();
initializeSeparators();
}
示例3: GeometryFactory
/// <summary>
/// Protected constructor for the abstract class.
/// </summary>
/// <param name="xmlReader">An XmlReader instance</param>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
protected GeometryFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
{
_FeatureTypeInfo = featureTypeInfo;
_XmlReader = xmlReader;
initializePathNodes();
initializeSeparators();
}
示例4: GeometryFactory
/// <summary>
/// Protected constructor for the abstract class.
/// </summary>
/// <param name="httpClientUtil">A configured <see cref="HttpClientUtil"/> instance for performing web requests</param>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="labelInfo">A FeatureDataTable for labels</param>
protected GeometryFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo,
IFeatureCollection labelInfo)
{
_FeatureTypeInfo = featureTypeInfo;
Factory = featureTypeInfo.Factory;
_HttpClientUtil = httpClientUtil;
createReader(httpClientUtil);
try
{
if (labelInfo != null)
{
_LabelInfo = labelInfo;
_LabelNode = new PathNode(_FeatureTypeInfo.FeatureTypeNamespace, _LabelInfo.AttributesDefinition[0].AttributeName,
(NameTable) _XmlReader.NameTable);
}
}
catch (Exception ex)
{
Trace.TraceError("An exception occured while initializing the label path node!");
throw ex;
}
initializePathNodes();
initializeSeparators();
}
示例5: GetFeatureGETRequest
/// <summary>
/// This method returns the query string for 'GetFeature'.
/// </summary>
/// <param name="featureTypeInfo">A <see cref="Wfs.WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="boundingBox">The bounding box of the query</param>
/// <param name="filter">An instance implementing <see cref="IFilter"/></param>
public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, BoundingBox boundingBox, IFilter filter)
{
string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
? string.Empty
: featureTypeInfo.Prefix + ":";
string filterString = string.Empty;
if (filter != null)
{
filterString = filter.Encode();
filterString = filterString.Replace("<", "%3C");
filterString = filterString.Replace(">", "%3E");
filterString = filterString.Replace(" ", "");
filterString = filterString.Replace("*", "%2a");
filterString = filterString.Replace("#", "%23");
filterString = filterString.Replace("!", "%21");
}
StringBuilder filterBuilder = new StringBuilder();
filterBuilder.Append("&FILTER=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML + "%22");
if (!string.IsNullOrEmpty(featureTypeInfo.Prefix))
{
filterBuilder.Append("%20xmlns:" + featureTypeInfo.Prefix + "=%22" +
featureTypeInfo.FeatureTypeNamespace + "%22");
//added by PDD to get it to work for deegree default sample
}
filterBuilder.Append("%3E");
if (filter != null)
{
filterBuilder.Append("%3CAnd%3E");
}
filterBuilder.Append("%3CBBOX%3E%3CPropertyName%3E");
filterBuilder.Append(qualification);
filterBuilder.Append(featureTypeInfo.Geometry._GeometryName);
filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName='EPSG:" + featureTypeInfo.SRID + "'%3E");
filterBuilder.Append("%3Cgml:coordinates%3E");
filterBuilder.Append(XmlConvert.ToString(boundingBox.Left) + ",");
filterBuilder.Append(XmlConvert.ToString(boundingBox.Bottom) + "%20");
filterBuilder.Append(XmlConvert.ToString(boundingBox.Right) + ",");
filterBuilder.Append(XmlConvert.ToString(boundingBox.Top));
filterBuilder.Append("%3C/gml:coordinates%3E%3C/gml:Box%3E%3C/BBOX%3E");
filterBuilder.Append(filterString);
if (filter != null)
{
filterBuilder.Append("%3C/And%3E");
}
filterBuilder.Append("%3C/Filter%3E");
if (!string.IsNullOrEmpty(featureTypeInfo.Prefix))
{
//TODO: reorganize: this is not a part of the filter and should be somewhere else. PDD.
filterBuilder.Append("&NAMESPACE=xmlns(" + featureTypeInfo.Prefix + "=" +
featureTypeInfo.FeatureTypeNamespace + ")");
}
return "?SERVICE=WFS&Version=1.1.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
"&PROPERTYNAME=" + qualification + featureTypeInfo.Geometry._GeometryName +
"&SRS=" + featureTypeInfo.SRID + filterBuilder;
}
示例6: GetFeatureGETRequest
/// <summary>
/// This method returns the query string for 'GetFeature'.
/// </summary>
/// <param name="featureTypeInfo">A <see cref="Wfs.WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="boundingBox">The bounding box of the query</param>
/// <param name="filter">An instance implementing <see cref="IFilter"/></param>
/// <param name="loadAllElements">True to get all feature elements, false to get only geometry element</param>
public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, Envelope boundingBox, IFilter filter, bool loadAllElements)
{
string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
? string.Empty
: featureTypeInfo.Prefix + ":";
string filterString = string.Empty;
if (filter != null)
{
filterString = filter.Encode();
filterString = filterString.Replace("<", "%3C");
filterString = filterString.Replace(">", "%3E");
filterString = filterString.Replace(" ", "");
filterString = filterString.Replace("*", "%2a");
filterString = filterString.Replace("#", "%23");
filterString = filterString.Replace("!", "%21");
}
StringBuilder filterBuilder = new StringBuilder();
// &filter=<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
filterBuilder.Append("&filter=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML +
"%22%3E");
// <BBOX>
filterBuilder.Append("%3CBBOX%3E");
if (!loadAllElements)
{
// <PropertyName>
filterBuilder.Append("%3CPropertyName%3E");
filterBuilder.Append(qualification);
filterBuilder.Append(featureTypeInfo.Geometry._GeometryName);
// </PropertyName>
filterBuilder.Append("%3C/PropertyName%3E");
}
// <gml:Box srsName="EPSG:....">
filterBuilder.Append("%3Cgml:Box%20srsName=%22EPSG:" + featureTypeInfo.SRID + "%22%3E");
// <gml:coordinates>
filterBuilder.Append("%3Cgml:coordinates%3E");
filterBuilder.Append(XmlConvert.ToString(boundingBox.MinX) + ",");
filterBuilder.Append(XmlConvert.ToString(boundingBox.MinY) + "%20");
filterBuilder.Append(XmlConvert.ToString(boundingBox.MaxX) + ",");
filterBuilder.Append(XmlConvert.ToString(boundingBox.MaxY));
// </gml:coordinates></gml:Box></BBOX>
filterBuilder.Append("%3C/gml:coordinates%3E%3C/gml:Box%3E%3C/BBOX%3E");
filterBuilder.Append(filterString);
filterBuilder.Append("%3C/Filter%3E");
return "?SERVICE=WFS&Version=1.0.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
(loadAllElements ? "" : "&PROPERTYNAME=" + qualification + featureTypeInfo.Geometry._GeometryName) +
"&SRS=" + featureTypeInfo.SRID + filterBuilder;
}
示例7: TestPOSTFilter1_1_0
public void TestPOSTFilter1_1_0()
{
var featureTypeInfo = new WfsFeatureTypeInfo("http://localhost/", "nsPrefix", "featureTypeNamespace", "featureType", "geometryName", GeometryTypeEnum.PointPropertyType);
WFS_1_1_0_TextResources wfs = new WFS_1_1_0_TextResources();
byte[] request = wfs.GetFeaturePOSTRequest(featureTypeInfo, "", new GeoAPI.Geometries.Envelope(1, 2, 3, 4), null);
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.Schemas.Add("http://www.opengis.net/wfs", "http://schemas.opengis.net/wfs/1.1.0/wfs.xsd");
readerSettings.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);
MemoryStream ms = new MemoryStream(request);
XmlTextReader xmlReader = new XmlTextReader(ms);
XmlReader objXmlReader = XmlReader.Create(xmlReader, readerSettings);
while (objXmlReader.Read()) { }
}
示例8: TestGETFilter1_1_0
public void TestGETFilter1_1_0()
{
var featureTypeInfo = new WfsFeatureTypeInfo("http://localhost/", "nsPrefix", "featureTypeNamespace", "featureType", "geometryName", GeometryTypeEnum.PointPropertyType);
WFS_1_1_0_TextResources wfs = new WFS_1_1_0_TextResources();
string querystring = wfs.GetFeatureGETRequest(featureTypeInfo, new GeoAPI.Geometries.Envelope(1, 2, 3, 4), null);
NameValueCollection qscoll = ParseQueryString(querystring);
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.Schemas.Add("http://www.opengis.net/ogc", "http://schemas.opengis.net/filter/1.1.0/filter.xsd");
readerSettings.Schemas.Add("http://www.opengis.net/ogc", "http://schemas.opengis.net/filter/1.1.0/expr.xsd");
readerSettings.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);
MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(qscoll["FILTER"]));
XmlTextReader xmlReader = new XmlTextReader(ms);
XmlReader objXmlReader = XmlReader.Create(xmlReader, readerSettings);
while (objXmlReader.Read()) { }
}
示例9: GeometryFactory
/// <summary>
/// Protected constructor for the abstract class.
/// </summary>
/// <param name="httpClientUtil">A configured <see cref="HttpClientUtil"/> instance for performing web requests</param>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="labelInfo">A FeatureDataTable for labels</param>
protected GeometryFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo, FeatureDataTable labelInfo)
{
_FeatureTypeInfo = featureTypeInfo;
_HttpClientUtil = httpClientUtil;
createReader(httpClientUtil);
try
{
if (labelInfo != null)
{
_LabelInfo = labelInfo;
_LabelNode = new PathNode(_FeatureTypeInfo.FeatureTypeNamespace, _LabelInfo.Columns[0].ColumnName, (NameTable)_XmlReader.NameTable);
}
}
catch(Exception ex)
{
System.Diagnostics.Trace.TraceError("An exception occured while initializing the label path node!");
throw ex;
}
initializePathNodes();
initializeSeparators();
}
示例10: GetFeaturePOSTRequest
/// <summary>
/// This method returns the POST request for 'GetFeature'.
/// </summary>
/// <param name="featureTypeInfo">A <see cref="WFS.WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="labelProperty">A property necessary for label rendering</param>
/// <param name="boundingBox">The bounding box of the query</param>
/// <param name="filter">An instance implementing <see cref="IFilter"/></param>
public byte[] GetFeaturePOSTRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty, BoundingBox boundingBox, IFilter filter)
{
string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix) ? string.Empty : featureTypeInfo.Prefix + ":";
using (StringWriter sWriter = new StringWriter())
{
using (XmlTextWriter xWriter = new XmlTextWriter(sWriter))
{
xWriter.Namespaces = true;
xWriter.WriteStartElement("GetFeature", NSWFS);
xWriter.WriteAttributeString("service", "WFS");
xWriter.WriteAttributeString("version", "1.0.0");
xWriter.WriteStartElement("Query", NSWFS);
xWriter.WriteAttributeString("typeName", qualification + featureTypeInfo.Name);
xWriter.WriteElementString("PropertyName", qualification + featureTypeInfo.Geometry._GeometryName);
if(!string.IsNullOrEmpty(labelProperty))
xWriter.WriteElementString("PropertyName", qualification + labelProperty);
xWriter.WriteStartElement("Filter", NSOGC);
xWriter.WriteStartElement("BBOX");
xWriter.WriteElementString("PropertyName", featureTypeInfo.Geometry._GeometryName);
xWriter.WriteStartElement("gml", "Box", NSGML);
xWriter.WriteAttributeString("srsName", "http://www.opengis.net/gml/srs/epsg.xml#" + featureTypeInfo.SRID);
xWriter.WriteElementString("coordinates", NSGML,
System.Xml.XmlConvert.ToString(boundingBox.Left) + "," +
System.Xml.XmlConvert.ToString(boundingBox.Bottom) + " " +
System.Xml.XmlConvert.ToString(boundingBox.Right) + "," +
System.Xml.XmlConvert.ToString(boundingBox.Top));
xWriter.WriteEndElement();
xWriter.WriteEndElement();
if (filter != null) xWriter.WriteRaw(filter.Encode());
if (filter != null) xWriter.WriteEndElement();
xWriter.WriteEndElement();
xWriter.WriteEndElement();
xWriter.WriteEndElement();
xWriter.Flush();
return System.Text.Encoding.UTF8.GetBytes(sWriter.ToString());
}
}
}
示例11: MultiLineStringFactory
/// <summary>
/// Initializes a new instance of the <see cref="MultiLineStringFactory"/> class.
/// </summary>
/// <param name="xmlReader">An XmlReader instance</param>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
internal MultiLineStringFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
: base(xmlReader, featureTypeInfo)
{
}
示例12: LineStringFactory
/// <summary>
/// Initializes a new instance of the <see cref="LineStringFactory"/> class.
/// This constructor shall just be called from the MultiLineString factory. The feature node therefore is deactivated.
/// </summary>
/// <param name="xmlReader">An XmlReader instance</param>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
internal LineStringFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
: base(xmlReader, featureTypeInfo)
{
_FeatureNode.IsActive = false;
}
示例13: InitializeMap
public static Map InitializeMap(float angle)
{
try
{
// WARNING
// This sample needs the GeoServer WFS running on your local machine.
// It uses the GeoServer default sample data. Installing and starting it is all you need to do
// http://docs.codehaus.org/display/GEOS/Download
// Sample by Peter Robineau
const string getCapabilitiesURI = "http://localhost:8080/geoserver/wfs";
const string serviceURI = "http://localhost:8080/geoserver/wfs";
Map map = new Map(new Size(600, 600));
map.MinimumZoom = 0.005;
map.BackColor = Color.White;
VectorLayer layer1 = new VectorLayer("States");
VectorLayer layer2 = new VectorLayer("SelectedStatesAndHousholds");
VectorLayer layer3 = new VectorLayer("New Jersey");
VectorLayer layer4 = new VectorLayer("Roads");
VectorLayer layer5 = new VectorLayer("Landmarks");
VectorLayer layer6 = new VectorLayer("Poi");
// Demo data from Geoserver 1.5.3 and Geoserver 1.6.0
WFS prov1 = new WFS(getCapabilitiesURI, "topp", "states", WFS.WFSVersionEnum.WFS1_0_0);
// Bypass 'GetCapabilities' and 'DescribeFeatureType', if you know all necessary metadata.
WfsFeatureTypeInfo featureTypeInfo = new WfsFeatureTypeInfo(serviceURI, "topp", null, "states",
"the_geom");
// 'WFS.WFSVersionEnum.WFS1_1_0' supported by Geoserver 1.6.x
WFS prov2 = new WFS(featureTypeInfo, WFS.WFSVersionEnum.WFS1_1_0);
// Bypass 'GetCapabilities' and 'DescribeFeatureType' again...
// It's possible to specify the geometry type, if 'DescribeFeatureType' does not...(.e.g 'GeometryAssociationType')
// This helps to accelerate the initialization process in case of unprecise geometry information.
WFS prov3 = new WFS(serviceURI, "topp", "http://www.openplans.org/topp", "states", "the_geom",
GeometryTypeEnum.MultiSurfacePropertyType, WFS.WFSVersionEnum.WFS1_1_0);
// Get data-filled FeatureTypeInfo after initialization of dataprovider (useful in Web Applications for caching metadata.
WfsFeatureTypeInfo info = prov1.FeatureTypeInfo;
// Use cached 'GetCapabilities' response of prov1 (featuretype hosted by same service).
// Compiled XPath expressions are re-used automatically!
// If you use a cached 'GetCapabilities' response make sure the data provider uses the same version of WFS as the one providing the cache!!!
WFS prov4 = new WFS(prov1.GetCapabilitiesCache, "tiger", "tiger_roads", WFS.WFSVersionEnum.WFS1_0_0);
WFS prov5 = new WFS(prov1.GetCapabilitiesCache, "tiger", "poly_landmarks", WFS.WFSVersionEnum.WFS1_0_0);
WFS prov6 = new WFS(prov1.GetCapabilitiesCache, "tiger", "poi", WFS.WFSVersionEnum.WFS1_0_0);
// Clear cache of prov1 - data providers do not have any cache, if they use the one of another data provider
prov1.GetCapabilitiesCache = null;
//Filters
IFilter filter1 = new PropertyIsEqualToFilter_FE1_1_0("STATE_NAME", "California");
IFilter filter2 = new PropertyIsEqualToFilter_FE1_1_0("STATE_NAME", "Vermont");
IFilter filter3 = new PropertyIsBetweenFilter_FE1_1_0("HOUSHOLD", "600000", "4000000");
IFilter filter4 = new PropertyIsLikeFilter_FE1_1_0("STATE_NAME", "New*");
// SelectedStatesAndHousholds: Green
OGCFilterCollection filterCollection1 = new OGCFilterCollection();
filterCollection1.AddFilter(filter1);
filterCollection1.AddFilter(filter2);
OGCFilterCollection filterCollection2 = new OGCFilterCollection();
filterCollection2.AddFilter(filter3);
filterCollection1.AddFilterCollection(filterCollection2);
filterCollection1.Junctor = OGCFilterCollection.JunctorEnum.Or;
prov2.OGCFilter = filterCollection1;
// Like-Filter('New*'): Bisque
prov3.OGCFilter = filter4;
// Layer Style
layer1.Style.Fill = new SolidBrush(Color.IndianRed); // States
layer2.Style.Fill = new SolidBrush(Color.Green); // SelectedStatesAndHousholds
layer3.Style.Fill = new SolidBrush(Color.Bisque); // e.g. New York, New Jersey,...
layer5.Style.Fill = new SolidBrush(Color.LightBlue);
// Labels
// Labels are collected when parsing the geometry. So there's just one 'GetFeatureByOid' call necessary.
// Otherwise (when calling twice for retrieving labels) there may be an inconsistent read...
// If a label property is set, the quick geometry option is automatically set to 'false'.
prov3.Label = "STATE_NAME";
LabelLayer layLabel = new LabelLayer("labels");
layLabel.DataSource = prov3;
layLabel.Enabled = true;
layLabel.LabelColumn = prov3.Label;
layLabel.Style = new LabelStyle();
layLabel.Style.CollisionDetection = false;
layLabel.Style.CollisionBuffer = new SizeF(5, 5);
layLabel.Style.ForeColor = Color.Black;
layLabel.Style.Font = new Font(FontFamily.GenericSerif, 10);
layLabel.MaxVisible = 90;
layLabel.Style.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center;
// Options
// Defaults: MultiGeometries: true, QuickGeometries: false, GetFeatureGETRequest: false
// Render with validation...
prov1.QuickGeometries = false;
// Important when connecting to an UMN MapServer
prov1.GetFeatureGETRequest = true;
// Ignore multi-geometries...
//.........這裏部分代碼省略.........
示例14: GetFeatureTypeInfo
/// <summary>
/// This method gets metadata about the featuretype to query from 'GetCapabilities' and 'DescribeFeatureType'.
/// </summary>
private void GetFeatureTypeInfo()
{
try
{
_featureTypeInfo = new WfsFeatureTypeInfo();
WFSClientHTTPConfigurator config = new WFSClientHTTPConfigurator(_textResources);
_featureTypeInfo.Prefix = _nsPrefix;
_featureTypeInfo.Name = _featureType;
string featureQueryName = string.IsNullOrEmpty(_nsPrefix)
? _featureType
: _nsPrefix + ":" + _featureType;
/***************************/
/* GetCapabilities request /
/***************************/
if (_featureTypeInfoQueryManager == null)
{
/* Initialize IXPathQueryManager with configured HttpClientUtil */
_featureTypeInfoQueryManager =
new XPathQueryManager_CompiledExpressionsDecorator(new XPathQueryManager());
_featureTypeInfoQueryManager.SetDocumentToParse(
config.configureForWfsGetCapabilitiesRequest(_httpClientUtil, _getCapabilitiesUri));
/* Namespaces for XPath queries */
_featureTypeInfoQueryManager.AddNamespace(_textResources.NSWFSPREFIX, _textResources.NSWFS);
_featureTypeInfoQueryManager.AddNamespace(_textResources.NSOWSPREFIX, _textResources.NSOWS);
_featureTypeInfoQueryManager.AddNamespace(_textResources.NSXLINKPREFIX, _textResources.NSXLINK);
}
/* Service URI (for WFS GetFeature request) */
_featureTypeInfo.ServiceURI = _featureTypeInfoQueryManager.GetValueFromNode
(_featureTypeInfoQueryManager.Compile(_textResources.XPATH_GETFEATURERESOURCE));
/* If no GetFeature URI could be found, try GetCapabilities URI */
if (_featureTypeInfo.ServiceURI == null) _featureTypeInfo.ServiceURI = _getCapabilitiesUri;
else if (_featureTypeInfo.ServiceURI.EndsWith("?", StringComparison.Ordinal))
_featureTypeInfo.ServiceURI =
_featureTypeInfo.ServiceURI.Remove(_featureTypeInfo.ServiceURI.Length - 1);
/* URI for DescribeFeatureType request */
string describeFeatureTypeUri = _featureTypeInfoQueryManager.GetValueFromNode
(_featureTypeInfoQueryManager.Compile(_textResources.XPATH_DESCRIBEFEATURETYPERESOURCE));
/* If no DescribeFeatureType URI could be found, try GetCapabilities URI */
if (describeFeatureTypeUri == null) describeFeatureTypeUri = _getCapabilitiesUri;
else if (describeFeatureTypeUri.EndsWith("?", StringComparison.Ordinal))
describeFeatureTypeUri =
describeFeatureTypeUri.Remove(describeFeatureTypeUri.Length - 1);
/* Spatial reference ID */
_featureTypeInfo.SRID = _featureTypeInfoQueryManager.GetValueFromNode(
_featureTypeInfoQueryManager.Compile(_textResources.XPATH_SRS),
new[] {new DictionaryEntry("_param1", featureQueryName)});
/* If no SRID could be found, try '4326' by default */
if (_featureTypeInfo.SRID == null) _featureTypeInfo.SRID = "4326";
else
/* Extract number */
_featureTypeInfo.SRID = _featureTypeInfo.SRID.Substring(_featureTypeInfo.SRID.LastIndexOf(":") + 1);
/* Bounding Box */
IXPathQueryManager bboxQuery = _featureTypeInfoQueryManager.GetXPathQueryManagerInContext(
_featureTypeInfoQueryManager.Compile(_textResources.XPATH_BBOX),
new[] {new DictionaryEntry("_param1", featureQueryName)});
if (bboxQuery != null)
{
WfsFeatureTypeInfo.BoundingBox bbox = new WfsFeatureTypeInfo.BoundingBox();
NumberFormatInfo formatInfo = new NumberFormatInfo();
formatInfo.NumberDecimalSeparator = ".";
string bboxVal = null;
if (_wfsVersion == WFSVersionEnum.WFS1_0_0)
bbox._MinLat =
Convert.ToDouble(
(bboxVal =
bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMINY))) !=
null
? bboxVal
: "0.0", formatInfo);
else if (_wfsVersion == WFSVersionEnum.WFS1_1_0)
bbox._MinLat =
Convert.ToDouble(
(bboxVal =
bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMINY))) !=
null
? bboxVal.Substring(bboxVal.IndexOf(' ') + 1)
: "0.0", formatInfo);
if (_wfsVersion == WFSVersionEnum.WFS1_0_0)
bbox._MaxLat =
Convert.ToDouble(
(bboxVal =
bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMAXY))) !=
null
? bboxVal
: "0.0", formatInfo);
else if (_wfsVersion == WFSVersionEnum.WFS1_1_0)
//.........這裏部分代碼省略.........
示例15: WFS
/// <summary>
/// Use this constructor for initializing this dataprovider with all mandatory
/// metadata for retrieving a featuretype, so that 'GetCapabilities' and 'DescribeFeatureType' can be bypassed.
/// </summary>
/// <param name="serviceURI">The service URL</param>
/// <param name="nsPrefix">
/// Use an empty string or 'null', if there is no prefix for the featuretype.
/// </param>
/// <param name="featureTypeNamespace">
/// Use an empty string or 'null', if there is no namespace for the featuretype.
/// You don't need to know the namespace of the feature type, if you use the quick geometries option.
/// </param>
/// <param name="geometryName">
/// The name of the geometry.
/// </param>
/// <param name="geometryType">
/// Specifying the geometry type helps to accelerate the rendering process.
/// </param>
/// <param name="featureType">The name of the feature type</param>
/// <param name="wfsVersion">The desired WFS Server version.</param>
public WFS(string serviceURI, string nsPrefix, string featureTypeNamespace, string featureType,
string geometryName, GeometryTypeEnum geometryType, WFSVersionEnum wfsVersion)
{
_featureTypeInfo = new WfsFeatureTypeInfo(serviceURI, nsPrefix, featureTypeNamespace, featureType,
geometryName, geometryType);
if (wfsVersion == WFSVersionEnum.WFS1_0_0)
_textResources = new WFS_1_0_0_TextResources();
else _textResources = new WFS_1_1_0_TextResources();
_wfsVersion = wfsVersion;
}