Example #1
0
        public void TestGETFilter1_1_0()
        {
            var featureTypeInfo = new WfsFeatureTypeInfo("http://localhost/", "nsPrefix", "featureTypeNamespace", "featureType", "geometryName", GeometryTypeEnum.PointPropertyType);

            WFS_1_1_0_TextResources wfs = new WFS_1_1_0_TextResources();
            string querystring          = wfs.GetFeatureGETRequest(featureTypeInfo, new GeoAPI.Geometries.Envelope(1, 2, 3, 4), null, true);

            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())
            {
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnspecifiedGeometryFactoryWfs100Gml2"/> 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 UnspecifiedGeometryFactoryWfs100Gml2(HttpClientUtil httpClientUtil,
                                               WfsFeatureTypeInfo featureTypeInfo, bool multiGeometries,
                                               bool quickGeometries)
     : base(httpClientUtil, featureTypeInfo)
 {
     _httpClientUtil  = httpClientUtil;
     _multiGeometries = multiGeometries;
     _quickGeometries = quickGeometries;
 }
Example #3
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 #4
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="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="geometryType">
        /// Specifying the geometry type helps to accelerate the rendering process.
        /// </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;
        }
Example #5
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, BoundingBox 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);
            }
Example #6
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, List <string> labelProperties, BoundingBox boundingBox,
                                                           IFilter filter, bool get)
            {
                httpClientUtil.Reset();
                httpClientUtil.Url = featureTypeInfo.ServiceUri;

                if (get)
                {
                    /* HTTP-GET */
                    httpClientUtil.Url += _wfsTextResources.GetFeatureGETRequest(
                        featureTypeInfo, labelProperties, boundingBox, filter);
                }
                else
                {
                    /* HTTP-POST */
                    httpClientUtil.PostData = _wfsTextResources.GetFeaturePOSTRequest(
                        featureTypeInfo, labelProperties, boundingBox, filter);
                    httpClientUtil.AddHeader(HttpRequestHeader.ContentType.ToString(), "text/xml");
                }
            }
Example #7
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, true);

            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())
            {
            }
        }
Example #8
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 #9
0
        public static Map InitializeMap()
        {
            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";

                var map = new Map();
                map.BackColor = Color.White;

                var layer1 = new Layer("States");
                var layer2 = new Layer("SelectedStatesAndHousholds");
                var layer3 = new Layer("New Jersey");
                var layer4 = new Layer("Roads");
                var layer5 = new Layer("Landmarks");
                var layer6 = new Layer("Poi");

                // Demo data from Geoserver 1.5.3 and Geoserver 1.6.0

                var prov1 = new WFS(getCapabilitiesUri, "topp", "states", WFS.WFSVersionEnum.WFS1_0_0);

                // Bypass 'GetCapabilities' and 'DescribeFeatureType', if you know all necessary metadata.
                var featureTypeInfo = new WfsFeatureTypeInfo(serviceUri, "topp", null, "states",
                                                             "the_geom");
                // 'WFS.WFSVersionEnum.WFS1_1_0' supported by Geoserver 1.6.x
                var 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.
                var prov3 = new WFS(serviceUri, "topp", "http://www.openplans.org/topp", "states", "the_geom",
                                    GeometryTypeEnum.MultiSurfacePropertyType, WFS.WFSVersionEnum.WFS1_1_0);

                // 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!!!
                var prov4 = new WFS(prov1.GetCapabilitiesCache, "tiger", "tiger_roads", WFS.WFSVersionEnum.WFS1_0_0);
                var prov5 = new WFS(prov1.GetCapabilitiesCache, "tiger", "poly_landmarks", WFS.WFSVersionEnum.WFS1_0_0);
                var 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
                var filterCollection1 = new OGCFilterCollection();
                filterCollection1.AddFilter(filter1);
                filterCollection1.AddFilter(filter2);
                var 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.Styles.Add(new VectorStyle {
                    Fill = new Brush {
                        Color = Color.Red
                    }
                });
                layer2.Styles.Add(new VectorStyle {
                    Fill = new Brush {
                        Color = Color.Green
                    }
                });                                                                              // SelectedStatesAndHousholds
                layer3.Styles.Add(new VectorStyle {
                    Fill = new Brush {
                        Color = Color.Yellow
                    }
                });                                                                               // e.g. New York, New Jersey,...
                layer5.Styles.Add(new VectorStyle {
                    Fill = new Brush {
                        Color = Color.Blue
                    }
                });

                // Labels
                // Labels are collected when parsing the geometry. So there's just one 'GetFeature' 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;

                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);
                }
                throw;
            }
        }
Example #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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)
 {
 }