本文整理汇总了C#中IFilter.Encode方法的典型用法代码示例。如果您正苦于以下问题:C# IFilter.Encode方法的具体用法?C# IFilter.Encode怎么用?C# IFilter.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFilter
的用法示例。
在下文中一共展示了IFilter.Encode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFeatureGETRequest
/// <summary>
/// This method returns the query string for 'GetFeature'.
/// </summary>
/// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
/// <param name="labelProperty"></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, string labelProperty, 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");
}
var filterBuilder = new StringBuilder();
filterBuilder.Append("&filter=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML +
"%22%3E%3CBBOX%3E%3CPropertyName%3E");
filterBuilder.Append(qualification).Append(featureTypeInfo.Geometry.GeometryName);
filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName=%22" + featureTypeInfo.SRID + "%22%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);
filterBuilder.Append("%3C/Filter%3E");
return "?SERVICE=WFS&Version=1.0.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
"&SRS =" + featureTypeInfo.SRID + filterBuilder;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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.1.0");
if (!string.IsNullOrEmpty(featureTypeInfo.Prefix) &&
!string.IsNullOrEmpty(featureTypeInfo.FeatureTypeNamespace))
xWriter.WriteAttributeString("xmlns:" + featureTypeInfo.Prefix,
featureTypeInfo.FeatureTypeNamespace);
//added by PDD to get it to work for deegree default sample
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);
if (filter != null) xWriter.WriteStartElement("And");
xWriter.WriteStartElement("BBOX");
if (!string.IsNullOrEmpty(featureTypeInfo.Prefix) &&
!string.IsNullOrEmpty(featureTypeInfo.FeatureTypeNamespace))
xWriter.WriteElementString("PropertyName",
qualification + featureTypeInfo.Geometry._GeometryName);
//added qualification to get it to work for deegree default sample
else
xWriter.WriteElementString("PropertyName", featureTypeInfo.Geometry._GeometryName);
xWriter.WriteStartElement("gml", "Envelope", NSGML);
xWriter.WriteAttributeString("srsName",
"http://www.opengis.net/gml/srs/epsg.xml#" + featureTypeInfo.SRID);
xWriter.WriteElementString("lowerCorner", NSGML,
XmlConvert.ToString(boundingBox.Left) + " " +
XmlConvert.ToString(boundingBox.Bottom));
xWriter.WriteElementString("upperCorner", NSGML,
XmlConvert.ToString(boundingBox.Right) + " " +
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 Encoding.UTF8.GetBytes(sWriter.ToString());
}
}
}
示例5: GetFeaturePOSTRequest
/// <summary>
/// This method returns the POST request for 'GetFeature'.
/// </summary>
/// <param name="featureTypeInfo">A <see cref="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 (var sWriter = new StringWriter())
{
using (var 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,
XmlConvert.ToString(boundingBox.Left) + "," +
XmlConvert.ToString(boundingBox.Bottom) + " " +
XmlConvert.ToString(boundingBox.Right) + "," +
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 Encoding.UTF8.GetBytes(sWriter.ToString());
}
}
}