예제 #1
0
        /// <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();
        }
예제 #2
0
        /// <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());
        }
예제 #3
0
 /// <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
0
        /// <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();
        }
예제 #5
0
        /// <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;
                    _LabelNode = new PathNode(_FeatureTypeInfo.FeatureTypeNamespace, _LabelInfo.Columns[0].ColumnName,
                                              (NameTable)_XmlReader.NameTable);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while initializing the label path node!");
                throw ex;
            }

            initializePathNodes();
            initializeSeparators();
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
        /// <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();
        }
예제 #8
0
 /// <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();
 }
예제 #9
0
        /// <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();
        }
예제 #10
0
        /// <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;
        }
        /// <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>
        /// <param name="loadAllElements">True to get all feature elements, false to get only geometry element</param>
        public byte[] GetFeaturePOSTRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty,
                                            Envelope boundingBox, IFilter filter, bool loadAllElements)
        {
            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);
                    if (!loadAllElements)
                    {
                        xWriter.WriteElementString("PropertyName",
                                                   qualification + featureTypeInfo.Geometry._GeometryName);
                        if (!string.IsNullOrEmpty(labelProperty))
                        {
                            xWriter.WriteElementString("PropertyName", qualification + labelProperty);
                        }
                    }
                    xWriter.WriteStartElement("Filter", NSOGC);
                    xWriter.WriteStartElement("BBOX");
                    if (!loadAllElements)
                    {
                        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.MinX) + "," +
                                               XmlConvert.ToString(boundingBox.MinY) + " " +
                                               XmlConvert.ToString(boundingBox.MaxX) + "," +
                                               XmlConvert.ToString(boundingBox.MaxY));
                    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()));
                }
            }
        }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnspecifiedGeometryFactory_WFS1_0_0_GML2"/> 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="multiGeometries">A boolean value specifying whether multi-geometries should be created</param>
 /// <param name="quickGeometries">A boolean value specifying whether the factory should create geometries quickly, but without validation</param>
 /// <param name="labelInfo">A FeatureDataTable for labels</param>
 internal UnspecifiedGeometryFactory_WFS1_0_0_GML2(HttpClientUtil httpClientUtil,
                                                   WfsFeatureTypeInfo featureTypeInfo, bool multiGeometries,
                                                   bool quickGeometries, FeatureDataTable labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
     _HttpClientUtil  = httpClientUtil;
     _MultiGeometries = multiGeometries;
     _QuickGeometries = quickGeometries;
 }
        /// <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" + Uri.EscapeDataString(NSOGC) + "%22%20xmlns:gml=%22" + Uri.EscapeDataString(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);
        }
예제 #14
0
        /// <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;
        }
예제 #15
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()) { }
        }
예제 #16
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()) { }
        }
예제 #17
0
 /// <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();
 }
예제 #18
0
            /// <summary>
            /// Configures for WFS 'GetFeature' request using an instance implementing <see cref="SharpMap.Utilities.Wfs.IWFS_TextResources"/>.
            /// The <see cref="SharpMap.Utilities.Wfs.HttpClientUtil"/> instance is returned for immediate usage. 
            /// </summary>
            internal HttpClientUtil configureForWfsGetFeatureRequest(HttpClientUtil httpClientUtil,
                                                                     WfsFeatureTypeInfo featureTypeInfo,
                                                                     string labelProperty, Envelope boundingBox,
                                                                     IFilter filter, bool GET)
            {
                httpClientUtil.Reset();
                httpClientUtil.Url = featureTypeInfo.ServiceURI;

                if (GET)
                {
                    /* HTTP-GET */
                    httpClientUtil.Url += _WfsTextResources.GetFeatureGETRequest(featureTypeInfo, boundingBox, filter);
                    return httpClientUtil;
                }

                /* HTTP-POST */
                httpClientUtil.PostData = _WfsTextResources.GetFeaturePOSTRequest(featureTypeInfo, labelProperty,
                                                                                  boundingBox, filter);
                httpClientUtil.AddHeader(HttpRequestHeader.ContentType.ToString(), "text/xml");
                return httpClientUtil;
            }
예제 #19
0
        /// <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>
        /// <param name="loadAllElements">True to get all feature elements, false to get only geometry element</param>
        public byte[] GetFeaturePOSTRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty,
                                            Envelope boundingBox, IFilter filter, bool loadAllElements)
        {
            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);
                    if (!loadAllElements)
                    {
                        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 (!loadAllElements)
                    {
                        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.MinX) + " " +
                                               XmlConvert.ToString(boundingBox.MinY));
                    xWriter.WriteElementString("upperCorner", NSGML,
                                               XmlConvert.ToString(boundingBox.MaxX) + " " +
                                               XmlConvert.ToString(boundingBox.MaxY));
                    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());
                }
            }
        }
예제 #20
0
        /// <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());
                }
            }
        }
예제 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPolygonFactory"/> 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>
 internal MultiPolygonFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo,
                              IFeatureCollection labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #22
0
        /// <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()));
                }
            }
        }
예제 #23
0
        /// <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();

            filterBuilder.Append("&FILTER=%3CFilter%20xmlns=%22" + Uri.EscapeDataString(NSOGC) + "%22%20xmlns:gml=%22" + Uri.EscapeDataString(NSGML) + "%22");
            if (!string.IsNullOrEmpty(featureTypeInfo.Prefix))
            {
                filterBuilder.Append("%20xmlns:" + featureTypeInfo.Prefix + "=%22" +
                                     Uri.EscapeDataString(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");

            if (!loadAllElements)
            {
                filterBuilder.Append("%3CPropertyName%3E");
                filterBuilder.Append(qualification);
                filterBuilder.Append(featureTypeInfo.Geometry._GeometryName);
                filterBuilder.Append("%3C/PropertyName%3E");
            }
            filterBuilder.Append("%3Cgml:Envelope%20srsName='EPSG:" + featureTypeInfo.SRID + "'%3E");
            filterBuilder.Append("%3Cgml:lowerCorner%3E");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.MinX) + "%20");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.MinY));
            filterBuilder.Append("%3C/gml:lowerCorner%3E");
            filterBuilder.Append("%3Cgml:upperCorner%3E");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.MaxX) + "%20");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.MaxY));
            filterBuilder.Append("%3C/gml:upperCorner%3E");
            filterBuilder.Append("%3C/gml:Envelope%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 + "=" +
                                     Uri.EscapeDataString(featureTypeInfo.FeatureTypeNamespace) + ")");
            }

            return("?SERVICE=WFS&Version=1.1.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
                   (loadAllElements ? "" : "&PROPERTYNAME=" + qualification + featureTypeInfo.Geometry._GeometryName) +
                   "&SRSNAME=EPSG:" + featureTypeInfo.SRID + filterBuilder);
        }
예제 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineStringFactory"/> 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>
 internal LineStringFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo, FeatureDataTable labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPolygonFactory"/> 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 MultiPolygonFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
     : base(xmlReader, featureTypeInfo)
 {
 }
예제 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineStringFactory"/> 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>
 internal LineStringFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo,
                            IFeatureCollection labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #27
0
 /// <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)
 {
 }
예제 #28
0
 /// <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;
 }
예제 #29
0
        /// <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)
                        bbox._MaxLat =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMAXY))) !=
                                null
                                    ? bboxVal.Substring(bboxVal.IndexOf(' ') + 1)
                                    : "0.0", formatInfo);

                    if (_wfsVersion == WFSVersionEnum.WFS1_0_0)
                        bbox._MinLong =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMINX))) !=
                                null
                                    ? bboxVal
                                    : "0.0", formatInfo);
                    else if (_wfsVersion == WFSVersionEnum.WFS1_1_0)
                        bbox._MinLong =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMINX))) !=
                                null
                                    ? bboxVal.Substring(0, bboxVal.IndexOf(' ') + 1)
                                    : "0.0", formatInfo);

                    if (_wfsVersion == WFSVersionEnum.WFS1_0_0)
                        bbox._MaxLong =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMAXX))) !=
                                null
                                    ? bboxVal
                                    : "0.0", formatInfo);
                    else if (_wfsVersion == WFSVersionEnum.WFS1_1_0)
                        bbox._MaxLong =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMAXX))) !=
                                null
                                    ? bboxVal.Substring(0, bboxVal.IndexOf(' ') + 1)
                                    : "0.0", formatInfo);

                    _featureTypeInfo.BBox = bbox;
                }

                //Continue with a clone in order to preserve the 'GetCapabilities' response
                IXPathQueryManager describeFeatureTypeQueryManager = _featureTypeInfoQueryManager.Clone();

                /******************************/
                /* DescribeFeatureType request /
                /******************************/

                /* Initialize IXPathQueryManager with configured HttpClientUtil */
                describeFeatureTypeQueryManager.ResetNamespaces();
                describeFeatureTypeQueryManager.SetDocumentToParse(config.configureForWfsDescribeFeatureTypeRequest
                                                                       (_httpClientUtil, describeFeatureTypeUri,
                                                                        featureQueryName));

                /* Namespaces for XPath queries */
                describeFeatureTypeQueryManager.AddNamespace(_textResources.NSSCHEMAPREFIX, _textResources.NSSCHEMA);
                describeFeatureTypeQueryManager.AddNamespace(_textResources.NSGMLPREFIX, _textResources.NSGML);

                /* Get target namespace */
                string targetNs = describeFeatureTypeQueryManager.GetValueFromNode(
                    describeFeatureTypeQueryManager.Compile(_textResources.XPATH_TARGETNS));
                if (targetNs != null)
                    _featureTypeInfo.FeatureTypeNamespace = targetNs;

                /* Get geometry */
                string geomType = _geometryType == GeometryTypeEnum.Unknown ? null : _geometryType.ToString();
                string geomName = null;
                string geomComplexTypeName = null;

                /* The easiest way to get geometry info, just ask for the 'gml'-prefixed type-attribute...
                   Simple, but effective in 90% of all cases...this is the standard GeoServer creates.*/
                /* example: <xs:element nillable = "false" name = "the_geom" maxOccurs = "1" type = "gml:MultiPolygonPropertyType" minOccurs = "0" /> */
                /* Try to get context of the geometry element by asking for a 'gml:*' type-attribute */
                IXPathQueryManager geomQuery = describeFeatureTypeQueryManager.GetXPathQueryManagerInContext(
                    describeFeatureTypeQueryManager.Compile(_textResources.XPATH_GEOMETRYELEMENT_BYTYPEATTRIBUTEQUERY));
                if (geomQuery != null)
                {
                    geomName = geomQuery.GetValueFromNode(geomQuery.Compile(_textResources.XPATH_NAMEATTRIBUTEQUERY));

                    /* Just, if not set manually... */
                    if (geomType == null)
                        geomType = geomQuery.GetValueFromNode(geomQuery.Compile(_textResources.XPATH_TYPEATTRIBUTEQUERY));
                }
                else
                {
                    /* Try to get context of a complexType with element ref ='gml:*' - use the global context */
                    /* example:
                    <xs:complexType name="geomType">
                        <xs:sequence>
                            <xs:element ref="gml:polygonProperty" minOccurs="0"/>
                        </xs:sequence>
                    </xs:complexType> */
                    geomQuery = describeFeatureTypeQueryManager.GetXPathQueryManagerInContext(
                        describeFeatureTypeQueryManager.Compile(
                            _textResources.XPATH_GEOMETRYELEMENTCOMPLEXTYPE_BYELEMREFQUERY));
                    if (geomQuery != null)
                    {
                        /* Ask for the name of the complextype - use the local context*/
                        geomComplexTypeName =
                            geomQuery.GetValueFromNode(geomQuery.Compile(_textResources.XPATH_NAMEATTRIBUTEQUERY));

                        if (geomComplexTypeName != null)
                        {
                            /* Ask for the name of an element with a complextype of 'geomComplexType' - use the global context */
                            geomName =
                                describeFeatureTypeQueryManager.GetValueFromNode(
                                    describeFeatureTypeQueryManager.Compile(
                                        _textResources.XPATH_GEOMETRY_ELEMREF_GEOMNAMEQUERY), new[]
                                                                                                  {
                                                                                                      new DictionaryEntry
                                                                                                          ("_param1",
                                                                                                           _featureTypeInfo
                                                                                                               .
                                                                                                               FeatureTypeNamespace)
                                                                                                      ,
                                                                                                      new DictionaryEntry
                                                                                                          ("_param2",
                                                                                                           geomComplexTypeName)
                                                                                                  });
                        }
                        else
                        {
                            /* The geometry element must be an ancestor, if we found an anonymous complextype */
                            /* Ask for the element hosting the anonymous complextype - use the global context */
                            /* example:
                            <xs:element name ="SHAPE">
                                <xs:complexType>
                                    <xs:sequence>
                              		    <xs:element ref="gml:lineStringProperty" minOccurs="0"/>
                                  </xs:sequence>
                                </xs:complexType>
                            </xs:element> */
                            geomName =
                                describeFeatureTypeQueryManager.GetValueFromNode(
                                    describeFeatureTypeQueryManager.Compile(
                                        _textResources.XPATH_GEOMETRY_ELEMREF_GEOMNAMEQUERY_ANONYMOUSTYPE));
                        }
                        /* Just, if not set manually... */
                        if (geomType == null)
                        {
                            /* Ask for the 'ref'-attribute - use the local context */
                            if (
                                (geomType =
                                 geomQuery.GetValueFromNode(
                                     geomQuery.Compile(_textResources.XPATH_GEOMETRY_ELEMREF_GMLELEMENTQUERY))) != null)
                            {
                                switch (geomType)
                                {
                                    case "gml:pointProperty":
                                        geomType = "PointPropertyType";
                                        break;
                                    case "gml:lineStringProperty":
                                        geomType = "LineStringPropertyType";
                                        break;
                                    case "gml:curveProperty":
                                        geomType = "CurvePropertyType";
                                        break;
                                    case "gml:polygonProperty":
                                        geomType = "PolygonPropertyType";
                                        break;
                                    case "gml:surfaceProperty":
                                        geomType = "SurfacePropertyType";
                                        break;
                                    case "gml:multiPointProperty":
                                        geomType = "MultiPointPropertyType";
                                        break;
                                    case "gml:multiLineStringProperty":
                                        geomType = "MultiLineStringPropertyType";
                                        break;
                                    case "gml:multiCurveProperty":
                                        geomType = "MultiCurvePropertyType";
                                        break;
                                    case "gml:multiPolygonProperty":
                                        geomType = "MultiPolygonPropertyType";
                                        break;
                                    case "gml:multiSurfaceProperty":
                                        geomType = "MultiSurfacePropertyType";
                                        break;
                                        // e.g. 'gml:_geometryProperty'
                                    default:
                                        break;
                                }
                            }
                        }
                    }
                }

                if (geomName == null)
                    /* Default value for geometry column = geom */
                    geomName = "geom";

                if (geomType == null)
                    /* Set geomType to an empty string in order to avoid exceptions.
                    The geometry type is not necessary by all means - it can be detected in 'GetFeature' response too.. */
                    geomType = string.Empty;

                /* Remove prefix */
                if (geomType.Contains(":"))
                    geomType = geomType.Substring(geomType.IndexOf(":") + 1);

                WfsFeatureTypeInfo.GeometryInfo geomInfo = new WfsFeatureTypeInfo.GeometryInfo();
                geomInfo._GeometryName = geomName;
                geomInfo._GeometryType = geomType;
                _featureTypeInfo.Geometry = geomInfo;
            }
            finally
            {
                _httpClientUtil.Close();
            }
        }
예제 #30
0
        /// <summary>
        /// Use this constructor for initializing this dataprovider with a 
        /// <see cref="WfsFeatureTypeInfo"/> object, 
        /// so that 'GetCapabilities' and 'DescribeFeatureType' can be bypassed.
        /// </summary>
        public WFS(WfsFeatureTypeInfo featureTypeInfo, WFSVersionEnum wfsVersion)
        {
            _featureTypeInfo = featureTypeInfo;

            if (wfsVersion == WFSVersionEnum.WFS1_0_0)
                _textResources = new WFS_1_0_0_TextResources();
            else _textResources = new WFS_1_1_0_TextResources();

            _wfsVersion = wfsVersion;
        }
예제 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPolygonFactory"/> 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>
 internal MultiPolygonFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo, FeatureDataTable labelInfo) 
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #32
0
        /// <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;
        }
예제 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineStringFactory"/> 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>
 internal LineStringFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo, FeatureDataTable labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #34
0
        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...
                prov1.MultiGeometries = false;

                // Quick geometries
                // We need this option for prov2 since we have not passed a featuretype namespace
                prov2.QuickGeometries = true;
                prov4.QuickGeometries = true;
                prov5.QuickGeometries = true;
                prov6.QuickGeometries = true;

                layer1.DataSource = prov1;
                layer2.DataSource = prov2;
                layer3.DataSource = prov3;
                layer4.DataSource = prov4;
                layer5.DataSource = prov5;
                layer6.DataSource = prov6;

                map.Layers.Add(layer1);
                map.Layers.Add(layer2);
                map.Layers.Add(layer3);
                map.Layers.Add(layer4);
                map.Layers.Add(layer5);
                map.Layers.Add(layer6);
                map.Layers.Add(layLabel);

                map.Center = new Point(-74.0, 40.7);
                map.Zoom = 10;
                // Alternatively zoom closer
                // demoMap.Zoom = 0.2;

                Matrix mat = new Matrix();
                mat.RotateAt(angle, map.WorldToImage(map.Center));
                map.MapTransform = mat;

                return map;
            }
            catch (WebException ex)
            {
                if ((ex.Message.Contains("(502) Bad Gateway")) ||
                    (ex.Message.Contains("Unable to connect to the remote server")))
                {
                    throw new Exception(
                        "The Wfs sample threw an exception. You probably need to install the GeoServer WFS to your local machine. You can get it from here: http://docs.codehaus.org/display/GEOS/Download. The exception message was: " +
                        ex.Message);
                }
                else throw;
            }
        }
예제 #35
0
 /// <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;
 }
예제 #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiLineStringFactory"/> 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>
 internal MultiLineStringFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo,
     IFeatureCollection labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPolygonFactory"/> 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 MultiPolygonFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
     : base(xmlReader, featureTypeInfo)
 {
 }
예제 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PolygonFactory"/> class.
 /// This constructor shall just be called from the MultiPolygon 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 PolygonFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
     : base(xmlReader, featureTypeInfo)
 {
     _FeatureNode.IsActive = false;
 }
예제 #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PolygonFactory"/> class.
 /// This constructor shall just be called from the MultiPolygon 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 PolygonFactory(XmlReader xmlReader, WfsFeatureTypeInfo featureTypeInfo)
     : base(xmlReader, featureTypeInfo)
 {
     _FeatureNode.IsActive = false;
 }
예제 #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PolygonFactory"/> 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>
 internal PolygonFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo,
     IFeatureCollection labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }
예제 #41
0
 /// <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)
 {
 }
예제 #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnspecifiedGeometryFactory_WFS1_0_0_GML2"/> 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="multiGeometries">A boolean value specifying whether multi-geometries should be created</param>
 /// <param name="quickGeometries">A boolean value specifying whether the factory should create geometries quickly, but without validation</param>
 /// <param name="labelInfo">A FeatureDataTable for labels</param>
 internal UnspecifiedGeometryFactory_WFS1_0_0_GML2(HttpClientUtil httpClientUtil,
     WfsFeatureTypeInfo featureTypeInfo, bool multiGeometries,
     bool quickGeometries, IFeatureCollection labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
     _HttpClientUtil = httpClientUtil;
     _MultiGeometries = multiGeometries;
     _QuickGeometries = quickGeometries;
 }
예제 #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPolygonFactory"/> 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>
 internal MultiPolygonFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo, FeatureDataTable labelInfo)
     : base(httpClientUtil, featureTypeInfo, labelInfo)
 {
 }