コード例 #1
0
        public async Task <IActionResult> ProcessRequestAsync(
            string?service = null,
            string?request = null,
            string version = Identifiers.Version100,
            string?layer   = null,
#pragma warning disable IDE0060
            string style = "default", // Not used
#pragma warning restore IDE0060
            string format = MediaTypeNames.Image.Png,
            ////string tileMatrixSet = null,
            string?tileMatrix = null,
            int tileRow       = 0,
            int tileCol       = 0)
        {
            // TODO: check requirements of standard
            if ((String.Compare(service, Identifiers.WMTS, StringComparison.Ordinal) != 0) &&
                (String.Compare(service, Identifiers.WMS, StringComparison.Ordinal) != 0)) // QGIS compatibility
            {
                return(ResponseWithBadRequestError(Identifiers.MissingParameterValue, "SERVICE parameter is not defined"));
            }

            if (String.Compare(version, Identifiers.Version100, StringComparison.Ordinal) != 0)
            {
                return(ResponseWithBadRequestError(Identifiers.InvalidParameterValue, $"Invalid VERSION parameter value (must be {Identifiers.Version100})"));
            }

            if (String.Compare(request, Identifiers.GetCapabilities, StringComparison.Ordinal) == 0)
            {
                return(this.ProcessGetCapabilitiesRequest());
            }
            else if (String.Compare(request, Identifiers.GetTile, StringComparison.Ordinal) == 0)
            {
                if (String.IsNullOrEmpty(tileMatrix))
                {
                    return(ResponseWithBadRequestError(Identifiers.MissingParameter, "TILEMATRIX parameter is not defined"));
                }

                if (String.IsNullOrEmpty(layer))
                {
                    return(ResponseWithBadRequestError(Identifiers.MissingParameter, "LAYER parameter is not defined"));
                }

                if (!this.tileSourceFabric.Contains(layer))
                {
                    return(ResponseWithNotFoundError(Identifiers.NotFound, $"Specified layer '{layer}' was not found"));
                }

                if (String.IsNullOrEmpty(format))
                {
                    return(ResponseWithBadRequestError(Identifiers.MissingParameter, "FORMAT parameter is not defined"));
                }

                return(await GetTileAsync(layer, tileCol, tileRow, Int32.Parse(tileMatrix), EntitiesConverter.TileFormatToContentType(format)));
            }
            else
            {
                return(ResponseWithBadRequestError(Identifiers.MissingParameter, "Invaid request")); // TODO: more detailed
            }
        }
コード例 #2
0
        public async Task <IActionResult> ProcessGetTileRestfulRequestAsync(
            string?tileMatrixSet,
            string?tileMatrix,
            int tileRow,
            int tileCol,
            string version = Identifiers.Version100,
            string?layer   = null,
#pragma warning disable IDE0060
            string style = "default", // Not used
#pragma warning restore IDE0060
            string format = "png")
        {
            if (String.Compare(version, Identifiers.Version100, StringComparison.Ordinal) != 0)
            {
                return(ResponseWithBadRequestError(Identifiers.InvalidParameterValue, "Invalid VERSION parameter value (1.0.0 available only)"));
            }

            if (String.IsNullOrEmpty(tileMatrixSet))
            {
                return(ResponseWithBadRequestError(Identifiers.MissingParameter, "TILEMATRIXSET parameter is not defined"));
            }

            if (String.IsNullOrEmpty(tileMatrix))
            {
                return(ResponseWithBadRequestError(Identifiers.MissingParameter, "TILEMATRIX parameter is not defined"));
            }

            if (String.IsNullOrEmpty(layer))
            {
                return(ResponseWithBadRequestError(Identifiers.MissingParameter, "LAYER parameter is not defined"));
            }

            if (!this.tileSourceFabric.Contains(layer))
            {
                return(ResponseWithNotFoundError(Identifiers.NotFound, $"Specified layer '{layer}' was not found"));
            }

            if (String.IsNullOrEmpty(format))
            {
                return(ResponseWithBadRequestError(Identifiers.MissingParameter, "FORMAT parameter is not defined"));
            }

            return(await GetTileAsync(layer, tileCol, tileRow, Int32.Parse(tileMatrix), EntitiesConverter.TileFormatToContentType(format)));
        }