Example #1
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();
 }
        /// <summary>
        /// This method returns the query string for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperties"></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, List <string> labelProperties,
                                           BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                ? string.Empty
                : featureTypeInfo.Prefix + ":";

            var paramBuilder = new StringBuilder();

            paramBuilder.Append("?SERVICE=WFS&Version=1.1.0&REQUEST=GetFeature&TYPENAME=");
            paramBuilder.Append(HttpUtility.UrlEncode(qualification + featureTypeInfo.Name));
            paramBuilder.Append("&srsName=");
            paramBuilder.Append(HttpUtility.UrlEncode(ProjectionHelper.EpsgPrefix + featureTypeInfo.SRID));

            if (filter != null || boundingBox != null)
            {
                paramBuilder.Append("&FILTER=");

                using var sWriter = new StringWriter();
                using var xWriter = new XmlTextWriter(sWriter);
                {
                    AppendGml3Filter(xWriter, featureTypeInfo, boundingBox, filter, qualification);
                }
                paramBuilder.Append(HttpUtility.UrlEncode(sWriter.ToString()));
            }

            if (!string.IsNullOrEmpty(featureTypeInfo.Prefix))
            {
                paramBuilder.Append("&NAMESPACE=xmlns(" + HttpUtility.UrlEncode(featureTypeInfo.Prefix) + "=" +
                                    HttpUtility.UrlEncode(featureTypeInfo.FeatureTypeNamespace) + ")");
            }

            return(paramBuilder.ToString());
        }
        /// <summary>
        /// This method returns the query string for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperty"></param>
        /// <param name="boundingBox">The bounding box of the query</param>
        /// <param name="filter">An instance implementing <see cref="IFilter"/></param>
        public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty, BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";
            string filterString = string.Empty;

            if (filter != null)
            {
                filterString = filter.Encode();
                filterString = filterString.Replace("<", "%3C");
                filterString = filterString.Replace(">", "%3E");
                filterString = filterString.Replace(" ", "");
                filterString = filterString.Replace("*", "%2a");
                filterString = filterString.Replace("#", "%23");
                filterString = filterString.Replace("!", "%21");
            }

            var filterBuilder = new StringBuilder();
            filterBuilder.Append("&filter=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML +
                                 "%22%3E%3CBBOX%3E%3CPropertyName%3E");
            filterBuilder.Append(qualification).Append(featureTypeInfo.Geometry.GeometryName);
            filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName=%22" + featureTypeInfo.SRID + "%22%3E");
            filterBuilder.Append("%3Cgml:coordinates%3E");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Left) + ",");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Bottom) + "%20");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Right) + ",");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Top));
            filterBuilder.Append("%3C/gml:coordinates%3E%3C/gml:Box%3E%3C/BBOX%3E");
            filterBuilder.Append(filterString);
            filterBuilder.Append("%3C/Filter%3E");

            return "?SERVICE=WFS&Version=1.0.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
                   "&SRS =" + featureTypeInfo.SRID + filterBuilder;
        }
        /// <summary>
        /// This method returns the query string for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperties">A list of properties 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 string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, List <string>?labelProperties,
                                           MRect boundingBox, IFilter?filter)
        {
            var qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";

            var paramBuilder = new StringBuilder();

            paramBuilder.Append("?SERVICE=WFS&Version=1.0.0&REQUEST=GetFeature&TYPENAME=");
            paramBuilder.Append(HttpUtility.UrlEncode(qualification + featureTypeInfo.Name));
            paramBuilder.Append("&srsName=");
            paramBuilder.Append(HttpUtility.UrlEncode(CrsHelper.EpsgPrefix + featureTypeInfo.SRID));

            if (filter != null || boundingBox != null)
            {
                paramBuilder.Append("&FILTER=");

                using var sWriter = new StringWriter();
                using var xWriter = new XmlTextWriter(sWriter);
                {
                    AppendGml2Filter(xWriter, featureTypeInfo, boundingBox, filter, qualification);
                }
                paramBuilder.Append(HttpUtility.UrlEncode(sWriter.ToString()));
            }

            return(paramBuilder.ToString());
        }
Example #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>
        protected GeometryFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo)
        {
            FeatureTypeInfo = featureTypeInfo;
            _httpClientUtil = httpClientUtil;
            CreateReader(httpClientUtil);

            try
            {
                if (featureTypeInfo.LabelFields != null)
                {
                    var pathNodes = new IPathNode[featureTypeInfo.LabelFields.Count];
                    for (var i = 0; i < pathNodes.Length; i++)
                    {
                        pathNodes[i] = new PathNode(FeatureTypeInfo.FeatureTypeNamespace, featureTypeInfo.LabelFields[i], (NameTable)XmlReader.NameTable);
                    }
                    LabelNode = new AlternativePathNodesCollection(pathNodes);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while initializing the label path node! " + ex.Message);
                throw;
            }

            InitializePathNodes();
            InitializeSeparators();
        }
Example #6
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();
 }
        /// <summary>
        /// This method returns the POST request for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperties">A list of properties 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, List <string>?labelProperties,
                                            MRect boundingBox, IFilter?filter)
        {
            var qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";

            using (var sWriter = new StringWriter())
            {
                using (var xWriter = new XmlTextWriter(sWriter))
                {
                    xWriter.Namespaces = true;
                    xWriter.WriteStartElement("GetFeature", NSWFS);
                    xWriter.WriteAttributeString("service", "WFS");
                    xWriter.WriteAttributeString("version", "1.0.0");
                    xWriter.WriteStartElement("Query", NSWFS);
                    xWriter.WriteAttributeString("typeName", qualification + featureTypeInfo.Name);
                    xWriter.WriteAttributeString("srsName", CrsHelper.EpsgPrefix + featureTypeInfo.SRID);
                    xWriter.WriteElementString("PropertyName", qualification + featureTypeInfo.Geometry.GeometryName);
                    if (labelProperties != null && !labelProperties.All(string.IsNullOrWhiteSpace))
                    {
                        xWriter.WriteElementString("PropertyName", string.Join(",",
                                                                               labelProperties.Where(x => !string.IsNullOrWhiteSpace(x)).Select(lbl => qualification + lbl)));
                    }

                    AppendGml2Filter(xWriter, featureTypeInfo, boundingBox, filter, qualification);

                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.Flush();
                    return(Encoding.UTF8.GetBytes(sWriter.ToString()));
                }
            }
        }
Example #8
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>
 internal UnspecifiedGeometryFactory_WFS1_0_0_GML2(HttpClientUtil httpClientUtil,
                                                   WfsFeatureTypeInfo featureTypeInfo, bool multiGeometries,
                                                   bool quickGeometries)
     : base(httpClientUtil, featureTypeInfo)
 {
     _httpClientUtil  = httpClientUtil;
     _multiGeometries = multiGeometries;
     _quickGeometries = quickGeometries;
 }
Example #9
0
        /// <summary>
        /// This method returns the POST request for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperty">A property necessary for label rendering</param>
        /// <param name="boundingBox">The bounding box of the query</param>
        /// <param name="filter">An instance implementing <see cref="IFilter"/></param>
        public byte[] GetFeaturePOSTRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty,
                                            BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";

            using (var sWriter = new StringWriter())
            {
                using (var xWriter = new XmlTextWriter(sWriter))
                {
                    xWriter.Namespaces = true;
                    xWriter.WriteStartElement("GetFeature", NSWFS);
                    xWriter.WriteAttributeString("service", "WFS");
                    xWriter.WriteAttributeString("version", "1.0.0");
                    xWriter.WriteStartElement("Query", NSWFS);
                    xWriter.WriteAttributeString("typeName", qualification + featureTypeInfo.Name);
                    xWriter.WriteElementString("PropertyName", qualification + featureTypeInfo.Geometry.GeometryName);
                    if (!string.IsNullOrEmpty(labelProperty))
                    {
                        xWriter.WriteElementString("PropertyName", qualification + labelProperty);
                    }
                    xWriter.WriteStartElement("Filter", NSOGC);
                    xWriter.WriteStartElement("BBOX");
                    xWriter.WriteElementString("PropertyName", featureTypeInfo.Geometry.GeometryName);
                    xWriter.WriteStartElement("gml", "Box", NSGML);
                    xWriter.WriteAttributeString("srsName",
                                                 "http://www.opengis.net/gml/srs/epsg.xml#" + featureTypeInfo.SRID);
                    xWriter.WriteElementString("coordinates", NSGML,
                                               XmlConvert.ToString(boundingBox.Left) + "," +
                                               XmlConvert.ToString(boundingBox.Bottom) + " " +
                                               XmlConvert.ToString(boundingBox.Right) + "," +
                                               XmlConvert.ToString(boundingBox.Top));
                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    if (filter != null)
                    {
                        xWriter.WriteRaw(filter.Encode());
                    }
                    if (filter != null)
                    {
                        xWriter.WriteEndElement();
                    }
                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.Flush();
                    return(Encoding.UTF8.GetBytes(sWriter.ToString()));
                }
            }
        }
Example #10
0
        /// <summary>
        /// This method returns the query string for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperty"></param>
        /// <param name="boundingBox">The bounding box of the query</param>
        /// <param name="filter">An instance implementing <see cref="IFilter"/></param>
        public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty, BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";
            string filterString = string.Empty;

            if (filter != null)
            {
                filterString = filter.Encode();
                filterString = filterString.Replace("<", "%3C");
                filterString = filterString.Replace(">", "%3E");
                filterString = filterString.Replace(" ", "");
                filterString = filterString.Replace("*", "%2a");
                filterString = filterString.Replace("#", "%23");
                filterString = filterString.Replace("!", "%21");
            }

            var filterBuilder = new StringBuilder();

            filterBuilder.Append("&FILTER=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML + "%22");
            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%3CBBOX%3E%3CPropertyName%3E");
            filterBuilder.Append(qualification).Append(featureTypeInfo.Geometry.GeometryName);
            filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName='" + 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);
            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 +
                   "&SRS =" + featureTypeInfo.SRID + filterBuilder);
        }
        /// <summary>
        /// This method returns the query string for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperty"></param>
        /// <param name="boundingBox">The bounding box of the query</param>
        /// <param name="filter">An instance implementing <see cref="IFilter"/></param>
        public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty, BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";
            string filterString = string.Empty;

            if (filter != null)
            {
                filterString = filter.Encode();
                filterString = filterString.Replace("<", "%3C");
                filterString = filterString.Replace(">", "%3E");
                filterString = filterString.Replace(" ", "");
                filterString = filterString.Replace("*", "%2a");
                filterString = filterString.Replace("#", "%23");
                filterString = filterString.Replace("!", "%21");
            }

            var filterBuilder = new StringBuilder();
            filterBuilder.Append("&FILTER=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML + "%22");
            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%3CBBOX%3E%3CPropertyName%3E");
            filterBuilder.Append(qualification).Append(featureTypeInfo.Geometry.GeometryName);
            filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName='" + 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);
            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 +
                   "&SRS =" + featureTypeInfo.SRID + filterBuilder;
        }
        private void AppendGml3Filter(XmlTextWriter xWriter, WfsFeatureTypeInfo featureTypeInfo, BoundingBox boundingBox,
                                      IFilter filter, string qualification)
        {
            xWriter.WriteStartElement("Filter", NSOGC);
            if (filter != null && boundingBox != null)
            {
                xWriter.WriteStartElement("And");
            }
            if (boundingBox != null)
            {
                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 && boundingBox != null)
            {
                xWriter.WriteEndElement();
            }
            xWriter.WriteEndElement();
        }
Example #13
0
        /// <summary>
        /// This method returns the POST request for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperties">A list of properties 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, List <string>?labelProperties,
                                            MRect boundingBox, IFilter?filter)
        {
            var qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";

            using (var sWriter = new StringWriter())
            {
                using (var xWriter = new XmlTextWriter(sWriter))
                {
                    xWriter.Namespaces = true;
                    xWriter.WriteStartElement("GetFeature", NSWFS);
                    xWriter.WriteAttributeString("service", "WFS");
                    xWriter.WriteAttributeString("version", "1.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 degree default sample
                    xWriter.WriteStartElement("Query", NSWFS);
                    xWriter.WriteAttributeString("typeName", qualification + featureTypeInfo.Name);
                    xWriter.WriteAttributeString("srsName", CrsHelper.EpsgPrefix + featureTypeInfo.SRID);
                    xWriter.WriteElementString("PropertyName", qualification + featureTypeInfo.Geometry.GeometryName);
                    if (labelProperties != null)
                    {
                        foreach (var labelProperty in labelProperties.Where(labelProperty =>
                                                                            !string.IsNullOrWhiteSpace(labelProperty)))
                        {
                            xWriter.WriteElementString("PropertyName", qualification + labelProperty);
                        }
                    }

                    AppendGml3Filter(xWriter, featureTypeInfo, boundingBox, filter, qualification);

                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.Flush();
                    return(Encoding.UTF8.GetBytes(sWriter.ToString()));
                }
            }
        }
Example #14
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>
        protected GeometryFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo)
        {
            FeatureTypeInfo = featureTypeInfo;
            _httpClientUtil = httpClientUtil;
            CreateReader(httpClientUtil);

            try
            {
                if (featureTypeInfo.LableField != null)
                {
                    LabelNode = new PathNode(FeatureTypeInfo.FeatureTypeNamespace, featureTypeInfo.LableField, 
                                              (NameTable) XmlReader.NameTable);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while initializing the label path node! " + ex.Message);
                throw;
            }

            InitializePathNodes();
            InitializeSeparators();
        }
Example #15
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>
        protected GeometryFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo)
        {
            FeatureTypeInfo = featureTypeInfo;
            _httpClientUtil = httpClientUtil;
            CreateReader(httpClientUtil);

            try
            {
                if (featureTypeInfo.LableField != null)
                {
                    LabelNode = new PathNode(FeatureTypeInfo.FeatureTypeNamespace, featureTypeInfo.LableField,
                                             (NameTable)XmlReader.NameTable);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while initializing the label path node! " + ex.Message);
                throw;
            }

            InitializePathNodes();
            InitializeSeparators();
        }
Example #16
0
        /// <summary>
        /// This method returns the query string for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperty"></param>
        /// <param name="boundingBox">The bounding box of the query</param>
        /// <param name="filter">An instance implementing <see cref="IFilter"/></param>
        public string GetFeatureGETRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty, BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";
            string filterString = string.Empty;

            if (filter != null)
            {
                filterString = filter.Encode();
                filterString = filterString.Replace("<", "%3C");
                filterString = filterString.Replace(">", "%3E");
                filterString = filterString.Replace(" ", "");
                filterString = filterString.Replace("*", "%2a");
                filterString = filterString.Replace("#", "%23");
                filterString = filterString.Replace("!", "%21");
            }

            var filterBuilder = new StringBuilder();

            filterBuilder.Append("&filter=%3CFilter%20xmlns=%22" + NSOGC + "%22%20xmlns:gml=%22" + NSGML +
                                 "%22%3E%3CBBOX%3E%3CPropertyName%3E");
            filterBuilder.Append(qualification).Append(featureTypeInfo.Geometry.GeometryName);
            filterBuilder.Append("%3C/PropertyName%3E%3Cgml:Box%20srsName=%22" + featureTypeInfo.SRID + "%22%3E");
            filterBuilder.Append("%3Cgml:coordinates%3E");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Left) + ",");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Bottom) + "%20");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Right) + ",");
            filterBuilder.Append(XmlConvert.ToString(boundingBox.Top));
            filterBuilder.Append("%3C/gml:coordinates%3E%3C/gml:Box%3E%3C/BBOX%3E");
            filterBuilder.Append(filterString);
            filterBuilder.Append("%3C/Filter%3E");

            return("?SERVICE=WFS&Version=1.0.0&REQUEST=GetFeature&TYPENAME=" + qualification + featureTypeInfo.Name +
                   "&SRS =" + featureTypeInfo.SRID + filterBuilder);
        }
Example #17
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;
 }
Example #18
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>
 internal MultiLineStringFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo) 
     : base(httpClientUtil, featureTypeInfo)
 {
 }
Example #19
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)
 {
 }
Example #20
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>
 internal MultiPolygonFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo)
     : base(httpClientUtil, featureTypeInfo)
 {
 }
Example #21
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)
 {
 }
Example #22
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)
 {
 }
Example #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PointFactory"/> 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>
 internal PointFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo) 
     : base(httpClientUtil, featureTypeInfo)
 {
 }
Example #24
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;
 }
Example #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PointFactory"/> 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>
 internal PointFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo)
     : base(httpClientUtil, featureTypeInfo)
 {
 }
Example #26
0
            /// <summary>
            /// Configures for WFS 'GetFeature' request using an instance implementing <see cref="IWFS_TextResources"/>.
            /// The <see cref="HttpClientUtil"/> instance is returned for immediate usage. 
            /// </summary>
            internal void ConfigureForWfsGetFeatureRequest(HttpClientUtil httpClientUtil, 
                WfsFeatureTypeInfo featureTypeInfo, string labelProperty, BoundingBox boundingBox,
                IFilter filter, bool get)
            {
                httpClientUtil.Reset();
                httpClientUtil.Url = featureTypeInfo.ServiceUri;

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

                /* HTTP-POST */
                httpClientUtil.PostData = _wfsTextResources.GetFeaturePOSTRequest(
                    featureTypeInfo, labelProperty, boundingBox, filter);
                httpClientUtil.AddHeader(HttpRequestHeader.ContentType.ToString(), "text/xml");
            }
Example #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)
 {
 }
Example #28
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>
        public WFSProvider(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.WFS_1_0_0)
                _textResources = new WFS_1_0_0_TextResources();
            else _textResources = new WFS_1_1_0_TextResources();

            _wfsVersion = wfsVersion;
        }
Example #29
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 WFSProvider(WfsFeatureTypeInfo featureTypeInfo, WFSVersionEnum wfsVersion)
        {
            _featureTypeInfo = featureTypeInfo;

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

            _wfsVersion = wfsVersion;
        }
Example #30
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>
 internal MultiPolygonFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo) 
     : base(httpClientUtil, featureTypeInfo)
 {
 }
Example #31
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;
 }
Example #32
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;
 }
        /// <summary>
        /// This method returns the POST request for 'GetFeature'.
        /// </summary>
        /// <param name="featureTypeInfo">A <see cref="WfsFeatureTypeInfo"/> instance providing metadata of the featuretype to query</param>
        /// <param name="labelProperty">A property necessary for label rendering</param>
        /// <param name="boundingBox">The bounding box of the query</param>
        /// <param name="filter">An instance implementing <see cref="IFilter"/></param>
        public byte[] GetFeaturePOSTRequest(WfsFeatureTypeInfo featureTypeInfo, string labelProperty,
                                            BoundingBox boundingBox, IFilter filter)
        {
            string qualification = string.IsNullOrEmpty(featureTypeInfo.Prefix)
                                       ? string.Empty
                                       : featureTypeInfo.Prefix + ":";

            using (var sWriter = new StringWriter())
            {
                using (var xWriter = new XmlTextWriter(sWriter))
                {
                    xWriter.Namespaces = true;
                    xWriter.WriteStartElement("GetFeature", NSWFS);
                    xWriter.WriteAttributeString("service", "WFS");
                    xWriter.WriteAttributeString("version", "1.0.0");
                    xWriter.WriteStartElement("Query", NSWFS);
                    xWriter.WriteAttributeString("typeName", qualification + featureTypeInfo.Name);
                    xWriter.WriteElementString("PropertyName", qualification + featureTypeInfo.Geometry.GeometryName);
                    if (!string.IsNullOrEmpty(labelProperty))
                        xWriter.WriteElementString("PropertyName", qualification + labelProperty);
                    xWriter.WriteStartElement("Filter", NSOGC);
                    xWriter.WriteStartElement("BBOX");
                    xWriter.WriteElementString("PropertyName", featureTypeInfo.Geometry.GeometryName);
                    xWriter.WriteStartElement("gml", "Box", NSGML);
                    xWriter.WriteAttributeString("srsName",
                                                 "http://www.opengis.net/gml/srs/epsg.xml#" + featureTypeInfo.SRID);
                    xWriter.WriteElementString("coordinates", NSGML,
                                               XmlConvert.ToString(boundingBox.Left) + "," +
                                               XmlConvert.ToString(boundingBox.Bottom) + " " +
                                               XmlConvert.ToString(boundingBox.Right) + "," +
                                               XmlConvert.ToString(boundingBox.Top));
                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    if (filter != null) xWriter.WriteRaw(filter.Encode());
                    if (filter != null) xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.WriteEndElement();
                    xWriter.Flush();
                    return Encoding.UTF8.GetBytes(sWriter.ToString());
                }
            }
        }
Example #34
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>
 internal MultiLineStringFactory(HttpClientUtil httpClientUtil, WfsFeatureTypeInfo featureTypeInfo)
     : base(httpClientUtil, featureTypeInfo)
 {
 }
Example #35
0
        /// <summary>
        /// This method gets metadata about the featuretype to query from 'GetCapabilities' and 'DescribeFeatureType'.
        /// </summary>
        private void GetFeatureTypeInfo()
        {
            try
            {
                _featureTypeInfo = new WfsFeatureTypeInfo();
                var 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 XPathQueryManagerCompiledExpressionsDecorator(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 */
                var srid = _featureTypeInfoQueryManager.GetValueFromNode
                    (_featureTypeInfoQueryManager.Compile(_textResources.XPATH_SRS), new[] {new DictionaryEntry("_param1", featureQueryName)});
                /* If no SRID could be found, try '4326' by default */
                srid = (srid == null) ? "4326" : srid.Substring(srid.LastIndexOf(":", StringComparison.Ordinal) + 1);
                _featureTypeInfo.SRID = srid;

                /* Bounding Box */
                IXPathQueryManager bboxQuery = _featureTypeInfoQueryManager.GetXPathQueryManagerInContext(
                    _featureTypeInfoQueryManager.Compile(_textResources.XPATH_BBOX),
                    new[] {new DictionaryEntry("_param1", featureQueryName)});

                if (bboxQuery != null)
                {
                    var bbox = new WfsFeatureTypeInfo.BoundingBox();
                    var formatInfo = new NumberFormatInfo {NumberDecimalSeparator = "."};
                    string bboxVal ;

                    if (_wfsVersion == WFSVersionEnum.WFS_1_0_0)
                        bbox.MinLat =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMINY))) !=
                                null
                                    ? bboxVal
                                    : "0.0", formatInfo);
                    else if (_wfsVersion == WFSVersionEnum.WFS_1_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.WFS_1_0_0)
                        bbox.MaxLat =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMAXY))) !=
                                null
                                    ? bboxVal
                                    : "0.0", formatInfo);
                    else if (_wfsVersion == WFSVersionEnum.WFS_1_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.WFS_1_0_0)
                        bbox.MinLong =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMINX))) !=
                                null
                                    ? bboxVal
                                    : "0.0", formatInfo);
                    else if (_wfsVersion == WFSVersionEnum.WFS_1_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.WFS_1_0_0)
                        bbox.MaxLong =
                            Convert.ToDouble(
                                (bboxVal =
                                 bboxQuery.GetValueFromNode(bboxQuery.Compile(_textResources.XPATH_BOUNDINGBOXMAXX))) !=
                                null
                                    ? bboxVal
                                    : "0.0", formatInfo);
                    else if (_wfsVersion == WFSVersionEnum.WFS_1_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;

                /* 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*/
                        string 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;
                                }
                            }
                        }
                    }
                }

                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(":", StringComparison.Ordinal) + 1);

                _featureTypeInfo.Geometry = new WfsFeatureTypeInfo.GeometryInfo
                    {
                        GeometryName = geomName,
                        GeometryType = geomType
                    };
            }
            finally
            {
                _httpClientUtil.Close();
            }
        }
Example #36
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>
 internal UnspecifiedGeometryFactory_WFS1_0_0_GML2(HttpClientUtil httpClientUtil,
                                                   WfsFeatureTypeInfo featureTypeInfo, bool multiGeometries,
                                                   bool quickGeometries)
     : base(httpClientUtil, featureTypeInfo)
 {
     _httpClientUtil = httpClientUtil;
     _multiGeometries = multiGeometries;
     _quickGeometries = quickGeometries;
 }