コード例 #1
0
ファイル: Program.cs プロジェクト: malirezai/slalom
        private static string CreateImage(string jsonPath, double clOffset, double rope,
                                          CourseCoordinates coords)
        {
            CoursePass        pass;
            CoursePassFactory factory = new CoursePassFactory();

            factory.CenterLineDegreeOffset = clOffset;
            factory.RopeLengthOff          = rope;
            factory.Course55Coordinates    = coords;

            if (jsonPath.StartsWith("http"))
            {
                pass = factory.FromUrl(jsonPath);
            }
            else
            {
                pass = factory.FromFile(jsonPath);
            }

            if (pass == null)
            {
                throw new ApplicationException($"Unable to create a pass for {jsonPath}");
            }

            string          imagePath = GetImagePath(jsonPath);
            CoursePassImage image     = new CoursePassImage(pass);
            Bitmap          bitmap    = image.Draw();

            bitmap.Save(imagePath, ImageFormat.Png);

            Logger.Log(string.Format("Gate precision == {0} for {1}", pass.GetGatePrecision(), jsonPath));
            Logger.Log("Wrote image to: " + imagePath);

            return(imagePath);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: malirezai/slalom
        private static void CreateImage(string[] args)
        {
            if (args.Length >= 4)
            {
                // eg. ski -i GOPR0194.json 0 22
                string jsonPath = args[1];
                double clOffset = args.Length > 2 ? double.Parse(args[2]) : 0;
                double rope     = args.Length > 3 ? double.Parse(args[3]) : 22;

                // Grab geo coordinates if passed.
                CourseCoordinates coords = CourseCoordinates.Default;
                if (args.Length >= 8)
                {
                    coords = new CourseCoordinates()
                    {
                        EntryLat = double.Parse(args[4]),
                        EntryLon = double.Parse(args[5]),
                        ExitLat  = double.Parse(args[6]),
                        ExitLon  = double.Parse(args[7])
                    };
                }

                string imagePath = CreateImage(jsonPath, clOffset, rope, coords);
            }
            else if (args.Length == 2)
            {
                // eg. ski -i https://jjdelormeski.blob.core.windows.net/videos/GOPR0194.MP4
                // does it all
                string imagePath = DownloadAndCreateImage(args[1]);
            }
        }