private static RequestMethodType GetRequestMethodType(string href, WmtsRequestType value)
        {
            object[] allowedValues = new Ows1_1.ValueType[]
            {
                new Ows1_1.ValueType()
                {
                    Value = value.ToString()
                }
            };
            DomainType constraint = new DomainType()
            {
                name          = "GetEncoding",
                AllowedValues = allowedValues
            };

            DomainType[] constraints = new DomainType[]
            {
                constraint
            };
            RequestMethodType restRequest = new RequestMethodType()
            {
                href       = href,
                Constraint = constraints
            };

            return(restRequest);
        }
Beispiel #2
0
        public static string GetHref(this Capabilities capabilities, WmtsOperationType operationType = WmtsOperationType.GetTile, WmtsRequestType requestMethod = WmtsRequestType.REST)
        {
            string    href      = null;
            Operation operation = capabilities.OperationsMetadata.Operation.FirstOrDefault(x => x.name == operationType.ToString());

            if (operation != null)
            {
                RequestMethodType[] requestMethodTypes = operation.DCP?.FirstOrDefault().Item.Items;
                if (requestMethodTypes != null)
                {
                    foreach (var requestMethodType in requestMethodTypes)
                    {
                        DomainType[] constraints = requestMethodType.Constraint;
                        if (constraints != null)
                        {
                            foreach (var constraint in constraints)
                            {
                                if (constraint.name == "GetEncoding")
                                {
                                    object[] allowedValues = constraint.AllowedValues;
                                    if (allowedValues != null)
                                    {
                                        bool ret = allowedValues.Any(item => item is Ows1_1.ValueType allowedValue && allowedValue.Value == requestMethod.ToString());
                                        if (ret)
                                        {
                                            href = requestMethodType.href;
                                            return(href);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(href);
        }