コード例 #1
0
ファイル: Converter.cs プロジェクト: TarasenkoAlex/MapGen
        /// <summary>
        /// Конвертация регулярной матрицы в карту для отрисовки.
        /// </summary>
        /// <param name="regMatrix">Регулярная матрица Model.</param>
        /// <param name="longitude">Долгота.</param>
        /// <param name="scale">Масштаб карты (1 : scale).</param>
        /// <param name="name">Имя карты.</param>
        /// <param name="latitude">Широта.</param>
        /// <returns>Карта для отрисовки.</returns>
        public static GraphicMap ToGraphicMap(RegMatrix regMatrix, string name, string latitude, string longitude, long scale)
        {
            GraphicMap graphicMap = new GraphicMap
            {
                Name           = name,
                Latitude       = latitude,
                Longitude      = longitude,
                Scale          = scale,
                Width          = regMatrix.Width,
                Length         = regMatrix.Length,
                MaxDepth       = regMatrix.MaxDepth,
                Points         = new Point3DColor[regMatrix.Points.Length],
                WidthEdgeOfMap = regMatrix.Step / 4,
                WidthEndOfLine = regMatrix.Step / 8,
                PointSize      = 8.0f
            };

            DrawingObjects.DepthScale depthScale = new DrawingObjects.DepthScale(graphicMap.MaxDepth);

            int countSourcePoints = 0;

            for (int i = 0; i < regMatrix.Length; ++i)
            {
                for (int j = 0; j < regMatrix.Width; ++j)
                {
                    var point = regMatrix.Points[i * regMatrix.Width + j];
                    graphicMap.Points[i * regMatrix.Width + j] = new Point3DColor
                    {
                        IsSource = point.IsSource,
                        X        = regMatrix.Step * j,
                        Y        = regMatrix.Step * i,
                        Depth    = point.Depth,
                        Color    = depthScale.GetColorDepth(point.Depth)
                    };
                    countSourcePoints = point.IsSource ? countSourcePoints + 1 : countSourcePoints;
                }
            }

            graphicMap.CountSourcePoints = countSourcePoints;

            return(graphicMap);
        }
コード例 #2
0
        public override void ConvertResolution(IResulotionConverter converter)
        {
            List <GraphicMap> graphics = new List <GraphicMap>();
            var resolutions            = Enum.GetValues(typeof(Resolution)).Cast <Resolution>().ToList();

            Parallel.For(0, resolutions.Count, j =>
            {
                var newGraphicPath = converter.ConvertGraphicSource(_graphicAsset.SourceFilePath, resolutions[j]);
                if (!string.IsNullOrEmpty(newGraphicPath))
                {
                    GraphicMap newGrapicMap = new GraphicMap()
                    {
                        Resolution = resolutions[j], GraphicPath = newGraphicPath
                    };
                    graphics.Add(newGrapicMap);
                }
            });

            _graphicAsset.Graphics = graphics;
        }