public void Apply(string BBW, string BBN, string mapLayerName, string output_path, string output_filename)
        {
            try
            {
                MapServerParameters.BBOXW = BBW;
                MapServerParameters.BBOXN = BBN;
                MapServerParameters.layer = mapLayerName;
                MapServerParameters.URLBuilder();

                if (MapServerParameters.WMTS)
                {
                    GetMapFromWMTS wmtsWorker = new GetMapFromWMTS(MapServerParameters.targetURL, MapServerParameters.Username,
                                                                   MapServerParameters.Password, MapServerParameters.WidthMeterScale, MapServerParameters.HeightMeterScale, MapServerParameters.ZoomLevel);
                    Log.WriteLine("Connecting WMTS...");
                    Tile tile = wmtsWorker.Apply(output_path, output_filename);
                    MapServerParameters.BBOXW = tile.westCorner.ToString();
                    MapServerParameters.BBOXN = tile.northCorner.ToString();
                    Log.WriteLine("WMTSWorker finished");
                }
                else
                {
                    GetMapFromWMS wmsWorker = new GetMapFromWMS();
                    Log.WriteLine("Connecting WMS...");
                    wmsWorker.Apply(output_path);
                    Log.WriteLine("WMSWorker finished");
                }
                if (MapServerParameters.Resize > 1)
                {
                    ImageUtils.ImageResize(output_path, output_filename);
                }
            }
            catch (Exception e)
            {
                Log.WriteLine("GetMapFromServiceWorker:" + e.Message);
                Log.WriteLine(e.Source);
                Log.WriteLine(e.StackTrace);
                throw;
            }
        }
        public void Apply(InputArgs inputArgs, bool processLocalFiles, double top, double left, double bottom, double right)
        {
            ExtractTextLayerFromMapWorker _textLayerExtractionWorker = new ExtractTextLayerFromMapWorker();
            TextDetectionWorker           _textDetectionWorker       = new TextDetectionWorker();
            TextRecognitionWorker         _textRecognitionWorker     = new TextRecognitionWorker();
            ColorSegmentationWorker       _colorSegmentationWorker   = new ColorSegmentationWorker();

            //set log folders
            Log.SetLogDir(inputArgs.intermediatePath);
            Log.SetOutputDir(inputArgs.intermediatePath);
            Log.WriteLine("************Strabo Starts************");
            Log.WriteLine("CommandLineWorker in progress...");


            Log.SetStartTime();
            //read settings
            try
            {
                StraboParameters.readConfigFile(inputArgs.mapLayerName);
            }
            catch (Exception e)
            {
                Log.WriteLine("Error reading app.config: " + e.Message);
                throw;
            }

            Log.WriteLine("Strabo release version:" + StraboParameters.straboReleaseVersion);
            Log.WriteLine("Process map: " + inputArgs.mapLayerName);
            //set and clear folders
            SetFolder(inputArgs.intermediatePath);
            SetFolder(inputArgs.outputPath);

            if (!inputArgs.intermediatePath.EndsWith("\\"))
            {
                inputArgs.intermediatePath = inputArgs.intermediatePath + "\\";
            }
            if (!inputArgs.outputPath.EndsWith("\\"))
            {
                inputArgs.outputPath = inputArgs.outputPath + "\\";
            }
            Log.WriteLine("Initialization finished. Folders checked and cleaned.");

            try
            {
                MapServerParameters.BBOXW = inputArgs.bbx.BBW;
                MapServerParameters.BBOXN = inputArgs.bbx.BBN;
                MapServerParameters.layer = inputArgs.mapLayerName;
                MapServerParameters.URLBuilder();

                if (!processLocalFiles)
                {
                    GetMapFromServiceWorker gmfsWoker = new GetMapFromServiceWorker();
                    gmfsWoker.Apply(inputArgs);
                }
                else
                {
                    File.Copy(inputArgs.outputPath + StraboParameters.sourceMapFileName, inputArgs.intermediatePath + StraboParameters.sourceMapFileName, true);
                }
                File.Copy(inputArgs.intermediatePath + StraboParameters.sourceMapFileName, inputArgs.outputPath + StraboParameters.sourceMapFileName, true);
            }
            catch (Exception e)
            {
                Log.WriteLine("ApplyWMSWorker/ApplyWMTSWorker: " + e.Message);
                throw;
            }

            string color_segmentation_result_fn;

            if (StraboParameters.numberOfSegmentationColor > 0)
            {
                try
                {
                    Log.WriteLine("ColorSegmentationWorker in progress...");
                    color_segmentation_result_fn = _colorSegmentationWorker.Apply(inputArgs.intermediatePath, inputArgs.threadNumber);
                    Log.WriteLine("ColorSegmentationWorker finished");
                }
                catch (Exception e)
                {
                    Log.WriteLine("ColorSegmentationWorker: " + e.Message);
                    throw;
                }
            }
            else
            {
                color_segmentation_result_fn = inputArgs.intermediatePath + StraboParameters.sourceMapFileName;
            }

            try
            {
                Log.WriteLine("TextExtractionWorker in progress...");
                _textLayerExtractionWorker.Apply(color_segmentation_result_fn, inputArgs.intermediatePath, inputArgs.threadNumber);
                Log.WriteLine("ApplyTextExtarionWorker finished");
            }
            catch (Exception e)
            {
                Log.WriteLine("ApplyTextExtractionWorker: " + e.Message);
                throw;
            }
            try
            {
                Log.WriteLine("TextDetectionWorker in progress...");
                _textDetectionWorker.Apply(inputArgs.intermediatePath, 2.5, false, inputArgs.threadNumber);
                Log.WriteLine("ApllyTextDetection finished");
            }
            catch (Exception e)
            {
                Log.WriteLine("ApplyTextDetectionWorker: " + e.Message);
                throw;
            }
            try
            {
                Log.WriteLine("TextRecognition in progress...");
                _textRecognitionWorker.Apply(inputArgs.intermediatePath, inputArgs.outputPath, inputArgs.outputFileName, top, left, bottom, right);
                Log.WriteLine("TextRecognitionWorker finished");
            }
            catch (Exception e)
            {
                Log.WriteLine("ApplyTextRecognition: " + e.Message);
                throw;
            }

            Log.WriteLine("Execution time: " + Log.GetDurationInSeconds().ToString());
        }