public Operation GetOperation(string href, WmtsOperationType operationType) { RequestMethodType restRequest = GetRestRequestMethodType(href); RequestMethodType kvpRequest = GetKvpRequestMethodType($"{href}?"); RequestMethodType[] requestMethodTypes = new RequestMethodType[] { restRequest, kvpRequest }; ItemsChoiceType1[] itemsChoiceType1s = new ItemsChoiceType1[] { ItemsChoiceType1.Get, ItemsChoiceType1.Get }; HTTP http = new HTTP() { Items = requestMethodTypes, ItemsElementName = itemsChoiceType1s }; DCP DCP = new DCP() { Item = http }; DCP[] DCPs = new DCP[] { DCP }; Operation operation = new Operation() { name = operationType.ToString(), DCP = DCPs }; return(operation); }
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); }