Beispiel #1
0
        /// <summary>
        /// Auswertung der Optionen
        /// </summary>
        /// <param name="args"></param>
        public void Evaluate(string[] args)
        {
            if (args == null)
            {
                return;
            }
            List <string> InputArray_Tmp = new List <string>();

            try {
                cmd.Parse(args);

                foreach (MyOptions opt in Enum.GetValues(typeof(MyOptions)))  // jede denkbare Option testen
                {
                    int optcount = cmd.OptionAssignment((int)opt);            // Wie oft wurde diese Option verwendet?
                    if (optcount > 0)
                    {
                        switch (opt)
                        {
                        case MyOptions.HgtPath:
                            for (int i = 0; i < optcount; i++)
                            {
                                string tmp = cmd.StringValue((int)opt, i).Trim();
                                if (tmp.Length > 0)
                                {
                                    HgtPath.Add(tmp);
                                }
                            }
                            break;

                        case MyOptions.RasterFilename:
                            RasterFilename = cmd.StringValue((int)opt).Trim();
                            break;

                        case MyOptions.DstPath:
                            DestinationPath = cmd.StringValue((int)opt).Trim();
                            break;

                        case MyOptions.VrtFilename:
                            WithVRT = cmd.BooleanValue((int)opt);
                            break;

                        case MyOptions.Compression:
                            Compress = cmd.BooleanValue((int)opt);
                            break;

                        case MyOptions.OutputOverwrite:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                OutputOverwrite = cmd.BooleanValue((int)opt);
                            }
                            else
                            {
                                OutputOverwrite = true;
                            }
                            break;

                        case MyOptions.Info:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                Info = cmd.BooleanValue((int)opt);
                            }
                            else
                            {
                                Info = true;
                            }
                            break;

                        case MyOptions.NoDataValue:
                            int iTmp = cmd.IntegerValue((int)opt);
                            if ((int)(iTmp & 0xFFFF0000) != 0)
                            {
                                throw new Exception("valid values are " + short.MinValue.ToString() + " .. " + short.MaxValue.ToString());
                            }
                            NoDataValue = (short)(iTmp & 0xFFFF);

                            break;

                        case MyOptions.Help:
                            ShowHelp();
                            break;
                        }
                    }
                }

                //TestParameter = new string[cmd.Parameters.Count];
                //cmd.Parameters.CopyTo(TestParameter);

                if (HgtPath.Count == 0 && RasterFilename == "")
                {
                    throw new Exception("don't know, what to do (use at least '" + cmd.OptionName((int)MyOptions.HgtPath) + "' or '" + cmd.OptionName((int)MyOptions.RasterFilename) + "')");
                }

                if (cmd.Parameters.Count > 0)
                {
                    throw new Exception("args not permitted");
                }
            } catch (Exception ex) {
                Console.Error.WriteLine(ex.Message);
                ShowHelp();
                throw new Exception("Error on prog-options.");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Auswertung der Optionen
        /// </summary>
        /// <param name="args"></param>
        public void Evaluate(string[] args)
        {
            if (args == null)
            {
                return;
            }
            List <string> InputArray_Tmp = new List <string>();

            try {
                cmd.Parse(args);

                foreach (MyOptions opt in Enum.GetValues(typeof(MyOptions)))  // jede denkbare Option testen
                {
                    int    optcount = cmd.OptionAssignment((int)opt);         // Wie oft wurde diese Option verwendet?
                    string arg;
                    if (optcount > 0)
                    {
                        switch (opt)
                        {
                        case MyOptions.Input:
                            for (int i = 0; i < optcount; i++)
                            {
                                InputArray_Tmp.Add(cmd.StringValue((int)opt, i).Trim());
                            }
                            break;

                        case MyOptions.InputWithSubdirs:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                InputWithSubdirs = cmd.BooleanValue((int)opt);
                            }
                            else
                            {
                                InputWithSubdirs = true;
                            }
                            break;

                        case MyOptions.InputListfile:
                            InputArray_Tmp.AddRange(System.IO.File.ReadAllLines(cmd.StringValue((int)opt)));
                            for (int i = InputArray_Tmp.Count - 1; i >= 0; i--)
                            {
                                InputArray_Tmp[i] = InputArray_Tmp[i].Trim();
                                if (InputArray_Tmp[i].Length == 0)
                                {
                                    InputArray_Tmp.RemoveAt(i);
                                }
                            }
                            break;

                        case MyOptions.Output:
                            Output = cmd.StringValue((int)opt).Trim();
                            break;

                        case MyOptions.OutputOverwrite:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                OutputOverwrite = cmd.BooleanValue((int)opt);
                            }
                            else
                            {
                                OutputOverwrite = true;
                            }
                            break;

                        case MyOptions.Info:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                switch (cmd.UnsignedIntegerValue((int)opt))
                                {
                                case 0: ToDo = ToDoType.Info; break;

                                case 1: ToDo = ToDoType.LongInfo; break;

                                case 2: ToDo = ToDoType.ExtLongInfo; break;

                                default: ToDo = ToDoType.VeryLongInfo; break;
                                }
                            }
                            else
                            {
                                ToDo = ToDoType.Info;
                            }
                            break;

                        case MyOptions.Split:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                arg = cmd.StringValue((int)opt);
                                if (arg == "r")
                                {
                                    ToDo = ToDoType.SplitRecursive;
                                }
                                else if (arg == "j")
                                {
                                    ToDo = ToDoType.SplitJoin;
                                }
                                else if (arg == "rj" || arg == "jr")
                                {
                                    ToDo = ToDoType.SplitRecursiveJoin;
                                }
                            }
                            else
                            {
                                ToDo = ToDoType.Split;
                            }
                            break;

                        case MyOptions.CreateFiles4Mapsource:
                            for (int i = 0; i < optcount; i++)
                            {
                                if (cmd.ArgIsUsed((int)opt, i))
                                {
                                    arg = cmd.StringValue((int)opt, i);
                                    if (!string.IsNullOrEmpty(arg))
                                    {
                                        if (arg.StartsWith("pid:"))
                                        {
                                            PID.Set(InterpretUInt(arg));
                                        }
                                        else if (arg.StartsWith("fid:"))
                                        {
                                            FID.Set(InterpretUInt(arg));
                                        }
                                        else if (arg.StartsWith("cp:"))
                                        {
                                            Codepage.Set(InterpretUInt(arg));
                                            //} else if (arg.StartsWith("ovno:")) {
                                            //   MapsourceOverviewNo.Set(InterpretUInt(arg));
                                        }
                                        else if (arg.StartsWith("ov:"))
                                        {
                                            MapsourceOverviewfile.Set(arg.Substring(3));
                                        }
                                        else if (arg.StartsWith("typ:"))
                                        {
                                            MapsourceTYPfile.Set(arg.Substring(4));
                                        }
                                        else if (arg.StartsWith("tdb:"))
                                        {
                                            MapsourceTDBfile.Set(arg.Substring(4));
                                        }
                                        else if (arg.StartsWith("mdx:"))
                                        {
                                            MapsourceMDXfile.Set(arg.Substring(4));
                                        }
                                        else if (arg.StartsWith("mdr:"))
                                        {
                                            MapsourceMDRfile.Set(arg.Substring(4));
                                        }
                                        else if (arg.StartsWith("tdb:"))
                                        {
                                            MapsourceTDBfile.Set(arg.Substring(4));
                                        }
                                        else if (arg.StartsWith("mindim:"))
                                        {
                                            MapsourceMinDimension.Set(InterpretUInt(arg));
                                        }
                                        else if (arg.StartsWith("points:"))
                                        {
                                            InterpretTypes(arg, MapsourceOVPointtypes);
                                        }
                                        else if (arg.StartsWith("lines:"))
                                        {
                                            InterpretTypes(arg, MapsourceOVLinetypes);
                                        }
                                        else if (arg.StartsWith("areas:"))
                                        {
                                            InterpretTypes(arg, MapsourceOVAreatypes);
                                        }
                                        else if (arg == "noov")
                                        {
                                            MapsourceNoOverviewfile.Set(true);
                                        }
                                        else if (arg == "notyp")
                                        {
                                            MapsourceNoTYPfile.Set(true);
                                        }
                                        else if (arg == "nomdx")
                                        {
                                            MapsourceNoMDXfile.Set(true);
                                        }
                                        else if (arg == "nomdr")
                                        {
                                            MapsourceNoMDRfile.Set(true);
                                        }
                                        else if (arg == "notdb")
                                        {
                                            MapsourceNoTDBfile.Set(true);
                                        }
                                        else if (arg == "noinst")
                                        {
                                            MapsourceNoInstfiles.Set(true);
                                        }
                                        else
                                        {
                                            throw new Exception("unbekanntes Argument: " + arg);
                                        }
                                    }
                                }
                            }
                            ToDo = ToDoType.CreateFiles4Mapsource;
                            break;

                        case MyOptions.Join:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                arg = cmd.StringValue((int)opt);
                                if (arg == "device")
                                {
                                    ToDo = ToDoType.JoinDevice;
                                }
                                else if (arg == "tile")
                                {
                                    ToDo = ToDoType.JoinTile;
                                }
                            }
                            else
                            {
                                ToDo = ToDoType.Join;
                            }
                            break;

                        case MyOptions.AnalyzingTypes:
                            switch (cmd.UnsignedIntegerValue((int)opt))
                            {
                            case 1: ToDo = ToDoType.AnalyzingTypesLong; break;

                            default: ToDo = ToDoType.AnalyzingTypes; break;
                            }
                            break;


                        case MyOptions.SetPID:
                            PID.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetFID:
                            FID.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetCodepage:
                            Codepage.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetTDBCopyright:
                            for (int j = 0; j < optcount; j++)
                            {
                                arg = cmd.StringValue((int)opt, j);
                                if (arg.Length < 3)
                                {
                                    throw new Exception("Falscher Aufbau der Copyright-Option '" + arg + "'");
                                }
                                else
                                {
                                    switch (arg[0])
                                    {
                                    case 'S':
                                        TDBCopyrightCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.CopyrightCodes.SourceInformation, true));
                                        break;

                                    case 'C':
                                        TDBCopyrightCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.CopyrightCodes.CopyrightInformation, true));
                                        break;

                                    case '*':
                                        TDBCopyrightCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.CopyrightCodes.Unknown, true));
                                        break;

                                    default:
                                        throw new Exception("Falsche Angabe in der Copyright-Option: '" + arg[0] + "'");
                                    }

                                    switch (arg[1])
                                    {
                                    case 'I':
                                        TDBCopyrightWhereCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.WhereCodes.ProductInformation, true));
                                        break;

                                    case 'P':
                                        TDBCopyrightWhereCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.WhereCodes.Printing, true));
                                        break;

                                    case 'E':
                                        TDBCopyrightWhereCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.WhereCodes.ProductInformationAndPrinting, true));
                                        break;

                                    case '*':
                                        TDBCopyrightWhereCodes.Add(new Property((int)GarminCore.Files.File_TDB.SegmentedCopyright.Segment.WhereCodes.Unknown, true));
                                        break;

                                    default:
                                        throw new Exception("Falsche Angabe in der Copyright-Option: '" + arg[1] + "'");
                                    }

                                    switch (arg[2])
                                    {
                                    case 'N':
                                        string sText = arg.Substring(3).Trim();
                                        if (sText.Length >= 2)
                                        {
                                            if (sText[0] == '"' && sText[sText.Length - 1] == '"')
                                            {
                                                sText = sText.Substring(1, sText.Length - 2);
                                            }
                                        }
                                        TDBCopyrightText.Add(new Property(sText, true));
                                        break;

                                    case 'D':
                                        TDBCopyrightText.Add(new Property(null, false));
                                        break;

                                    case '*':
                                        TDBCopyrightText.Add(new Property(null, true));
                                        break;

                                    default:
                                        throw new Exception("Falsche Angabe in der Copyright-Option: '" + arg[1] + "'");
                                    }
                                }
                            }
                            break;

                        case MyOptions.SetDescription:
                            Description.Set(cmd.StringValue((int)opt));
                            break;

                        case MyOptions.SetTransparent:
                            Transparent.Set(cmd.BooleanValue((int)opt) ? 1 : 0);
                            break;

                        case MyOptions.SetPriority:
                            Priority.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetMapFamilyName:
                            MapFamilyName.Set(cmd.StringValue((int)opt));
                            break;

                        case MyOptions.SetMapSeriesName:
                            MapSeriesName.Set(cmd.StringValue((int)opt));
                            break;

                        case MyOptions.SetVersion:
                            Version.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetRoutable:
                            Routable.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetHighestRoutable:
                            HighestRoutable.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetHasDEM:
                            HasDEM.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetHasProfile:
                            HasProfile.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.SetMaxCoordBits4Overview:
                            MaxCoordBits4Overview.Set((int)cmd.UnsignedIntegerValue((int)opt));
                            break;

                        case MyOptions.RefreshTDB:
                            ToDo = ToDoType.RefreshTDB;
                            break;

                        case MyOptions.NewTypfile:
                            NewTypfile.Set(cmd.StringValue((int)opt));
                            ToDo = ToDoType.SetNewTypfile;
                            break;

                        case MyOptions.Help:
                            ShowHelp();
                            break;
                        }
                    }
                }

                //TestParameter = new string[cmd.Parameters.Count];
                //cmd.Parameters.CopyTo(TestParameter);

                if (cmd.Parameters.Count > 0)
                {
                    throw new Exception("Es sind keine Argumente sondern nur Optionen erlaubt.");
                }

                Input = new string[InputArray_Tmp.Count];
                InputArray_Tmp.CopyTo(Input);
            } catch (Exception ex) {
                Console.Error.WriteLine(ex.Message);
                ShowHelp();
                throw new Exception("Fehler beim Ermitteln oder Anwenden der Programmoptionen.");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Auswertung der Optionen
        /// </summary>
        /// <param name="args"></param>
        public void Evaluate(string[] args)
        {
            if (args == null)
            {
                return;
            }
            List <string> InputArray_Tmp = new List <string>();

            try {
                cmd.Parse(args);

                foreach (MyOptions opt in Enum.GetValues(typeof(MyOptions)))  // jede denkbare Option testen
                {
                    int optcount = cmd.OptionAssignment((int)opt);            // Wie oft wurde diese Option verwendet?
                    if (optcount > 0)
                    {
                        switch (opt)
                        {
                        case MyOptions.Input:
                            Input = cmd.StringValue((int)opt).Trim();
                            break;

                        case MyOptions.OutPath:
                            OutPath = cmd.StringValue((int)opt).Trim();
                            break;

                        case MyOptions.Symbolname:
                            Symbolname = cmd.StringValue((int)opt).Trim();
                            break;

                        case MyOptions.Zoomlevel:
                            for (int i = 0; i < cmd.OptionAssignment((int)opt); i++)
                            {
                                Zoomlevel.Add((int)cmd.UnsignedIntegerValue((int)opt, i));
                            }
                            break;

                        case MyOptions.OutputOverwrite:
                            if (cmd.ArgIsUsed((int)opt))
                            {
                                OutputOverwrite = cmd.BooleanValue((int)opt);
                            }
                            else
                            {
                                OutputOverwrite = true;
                            }
                            break;

                        case MyOptions.Help:
                            ShowHelp();
                            break;
                        }
                    }
                }

                //TestParameter = new string[cmd.Parameters.Count];
                //cmd.Parameters.CopyTo(TestParameter);

                if (string.IsNullOrEmpty(Symbolname))
                {
                    Symbolname = "Waypoint";
                }

                if (string.IsNullOrEmpty(OutPath))
                {
                    OutPath = ".\\gpx";
                }

                if (Zoomlevel.Count == 0)
                {
                    Zoomlevel.Add(0);
                }

                if (cmd.Parameters.Count > 0)
                {
                    throw new Exception("Es sind keine Argumente sondern nur Optionen erlaubt.");
                }
            } catch (Exception ex) {
                Console.Error.WriteLine(ex.Message);
                ShowHelp();
                throw new Exception("Fehler beim Ermitteln oder Anwenden der Programmoptionen.");
            }
        }