Пример #1
0
        public string buildBufferCommand(BufferOperationParam json, string scriptFolder, string scriptName, string inputLayerFile)
        {
            ICommandBuilder builder = createNewCommandBuilder();

            builder.AddProgramName(scriptFolder + @"\" + scriptName);
            builder.SignleParameter(inputLayerFile);
            builder.SignleParameter(json.Distance.ToString());
            return(builder.GetResult());
        }
        public void Test_Validate_method(bool geoJSONValid, bool distanceValid, int expectedResultCount)
        {
            mockValidationFunctions.Setup(x => x.IsValidGeoJson(It.IsAny <string>())).Returns(geoJSONValid);
            mockValidationFunctions.Setup(x => x.isDistanceValid(It.IsAny <string>())).Returns(distanceValid);

            bufferOperationParam = new BufferOperationParam()
            {
                InputLayer = "inputLayerTypeGeoJSON" + random.Next(), Distance = "distance" + random.Next()
            };

            IList <ValidationResult> result = checkPropertyValidation.myValidation(bufferOperationParam, mockValidationFunctions);

            Assert.AreEqual(expectedResultCount, result.Count());
        }
        [Consumes("application/json")] // supports only json
        public IActionResult Post(BufferOperationParam myJson)
        {
            var          pathToScriptFolder = Configuration["pathToAnalysisScriptFolder"];
            var          scriptName         = Configuration["AnalysisScriptNames:bufferScript"];
            var          qgisPython         = Configuration["ScriptRunners:qgisCmdPath"];
            ResultObject output;

            using (var tempFiles = new TempFileCollection())
            {
                string inputLayerFile = tempFiles.AddExtension("geojson");
                System.IO.File.WriteAllText(inputLayerFile, myJson.InputLayer.ToString());
                string args = _creator.buildBufferCommand(myJson, pathToScriptFolder, scriptName, inputLayerFile);
                output = _python.RunCMD(args, qgisPython);
            }
            return(_outputHandler.HandleQgisOutput(output));
        }