Exemplo n.º 1
0
        public void Run()
        {
            try
            {
                IMGAlgoritm mgAlgoritm = new CLMGAlgoritm(SettingGen);
                DbMap       outDbMap;
                string      message;

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Reset();
                stopwatch.Start();
                bool isSuccess = mgAlgoritm.Execute(Scale, DbMap, out outDbMap, out message);
                stopwatch.Stop();

                TestResult testResult = new TestResult
                {
                    IdTestCase = Id,
                    Time       = stopwatch.ElapsedMilliseconds,
                    IsSuccess  = isSuccess
                };

                string dirResultTests = $"{ResourceModel.DIR_TESTS}\\Test_{Id}";
                if (!Directory.Exists(dirResultTests))
                {
                    Directory.CreateDirectory(dirResultTests);
                }
                // Отрисовываем исходную карту.
                Methods.DeleteAllElementsOnDirectry(dirResultTests);
                DbMap.DrawToBMP($"{dirResultTests}\\{ResourceModel.FILENAME_BEFORE_BMP}");

                // Отрисовываем результирующую карту.
                DbMap.DrawToBMP(mgAlgoritm.Clusters, $"{dirResultTests}\\{ResourceModel.FILENAME_AFTER_BMP}");

                // Сохраняем в файл результаты теста с настройкой.
                string distScaleInfo = $"Масштаб теста: 1:{Scale}";
                string testInfo      = $"{DbMap}\n{distScaleInfo}\n{SettingGen}\n{testResult}";
                File.WriteAllText($"{dirResultTests}\\{ResourceModel.FILENAME_TESTINFO}", testInfo);

                TestFinished?.Invoke(testResult);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Загрузка карты по его id.
        /// </summary>
        /// <param name="idMap">Id загружаемой карты.</param>
        /// <param name="message">Сообщение с ошибкой.</param>
        /// <returns>Успешно ли прошло загрука.</returns>
        public bool LoadDbMap(int idMap, out string message)
        {
            message = string.Empty;
            Map map;

            Point[] cloudPoints;

            // Загрузка карты.
            if (!_databaseWorker.GetMap(idMap, out map, out message))
            {
                return(false);
            }
            // Загрузка облака точек.
            if (!_databaseWorker.GetPoints(idMap, out cloudPoints, out message))
            {
                return(false);
            }

            try
            {
                // Сохраняем карту.
                SourceSeaMap = new DbMap(map.Name, map.Width, map.Length, map.Scale, map.Latitude, map.Longitude, cloudPoints);

                // Отрисовываем в файл.
                Methods.DeleteAllElementsOnDirectry(ResourceModel.DIR_RUNTIME);
                SourceSeaMap.DrawToBMP($"{ResourceModel.DIR_RUNTIME}Before.bmp");

                // Выставляем, что необходимо отрисовывать исходную карту.
                _isUseSourceMap = true;
            }
            catch (Exception ex)
            {
                message = Methods.CalcMessageException(ex);
                return(false);
            }
            return(true);
        }