Ejemplo n.º 1
0
        private void cbLayers_SelectedIndexChanged(object sender, EventArgs e)
        {
            IFeatureClass fClass = this.GetSelectedFClass();

            if (fClass != null)
            {
                this.run = new ClassLib.Run(fClass, this.angleSpinner.Value, isDissolved: this.cbDisslv.Checked);

                if (this.run.isFeetOrMeters)
                {
                    this.cbFeet.Checked = this.run.isFeet;
                    this.txtOutput.Text = this.run.outputPath;
                    this.rIDField.Items.Clear();
                    this.rIDField.Items.AddRange(this.run.fieldNames.ToArray());

                    if (this.rIDField.Items.Count > 0)
                    {
                        this.rIDField.SelectedIndex       = 0;
                        this.btIdentifyCurveAreas.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("The input feature units must be in either meters or feet", "Invalid Coordinate System");
                    this.rIDField.Items.Clear();
                    this.btIdentifyCurveAreas.Enabled = false;
                }
            }
            else
            {
                this.run                     = null;
                this.txtOutput.Text          = "";
                btIdentifyCurveAreas.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        private void openFileDialogue(object sender, EventArgs e)
        {
            this.btIdentifyCurveAreas.Enabled = false;

            IGxDialog igxDialog = new GxDialog();

            igxDialog.AllowMultiSelect = false;
            igxDialog.ObjectFilter     = new ESRI.ArcGIS.Catalog.GxFilterPolylineFeatureClasses();

            ESRI.ArcGIS.Catalog.IEnumGxObject selection;
            igxDialog.DoModalOpen(this.Handle.ToInt32(), out selection);

            ESRI.ArcGIS.Catalog.IGxObject nextObj = selection.Next();

            this.rIDField.Items.Clear();

            if (nextObj == null)
            {
                this.txtInput.Clear();
                this.txtOutput.Clear();
                this.run = null;
            }
            else
            {
                this.run            = new ClassLib.Run(nextObj.FullName, this.AngleVariation.Value, isDissolved: cbDisslv.Checked);
                this.txtInput.Text  = this.run.inputPath;
                this.txtOutput.Text = this.run.outputPath;

                if (!run.isFeetOrMeters)
                {
                    MessageBox.Show("The input coordinate system must be in meters or feet");

                    return;
                }

                this.btIdentifyCurveAreas.Enabled = true;

                this.cbFeet.Checked = this.run.isFeet;

                this.rIDField.Items.Clear();

                this.rIDField.Items.AddRange(run.fieldNames.ToArray());

                if (this.rIDField.Items.Count > 0)
                {
                    this.rIDField.SelectedIndex = 0;
                }
            }
        }
Ejemplo n.º 3
0
        public void ParseCom()
        {
            IFeatureClass fc;
            string        roadField;
            double        angle;
            bool          isDissolved;
            bool          multi;
            string        relPath;

            string[] args;

            args = new string[] { samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.IsTrue(isDissolved);
            Assert.IsNull(roadField);
            Assert.AreEqual(1.0, angle);
            Assert.IsFalse(multi);

            args = new string[] { "-u", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.IsFalse(isDissolved);

            args = new string[] { "--undissolved", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.IsFalse(isDissolved);

            args = new string[] { "-m", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.IsTrue(multi);

            args = new string[] { "--multi", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.IsTrue(multi);

            args = new string[] { "-a", "2.01", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.AreEqual(2.0, angle);

            args = new string[] { "--angle", "2.01", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.AreEqual(2.0, angle);

            args = new string[] { "--angle", "2", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.AreEqual(2.0, angle);

            args = new string[] { "-f", "FULLNAME", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.AreEqual("FULLNAME".ToLower(), roadField.ToLower());

            args = new string[] { "--field", "fullname", samplePaths.shpBuffaloFeet };
            ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            Assert.AreEqual("FULLNAME".ToLower(), roadField.ToLower());

            bool raised = false;

            try
            {
                raised = false;
                args   = new string[] { "--field", "fullnam", samplePaths.shpBuffaloFeet };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            }
            catch (ArgumentException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);

            try
            {
                raised = false;
                args   = new string[] { "-a", "-10.0", samplePaths.shpBuffaloFeet };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            }
            catch (ArgumentOutOfRangeException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);

            try
            {
                raised = false;
                args   = new string[] { "-a", "100.0", samplePaths.shpBuffaloFeet };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            }
            catch (ArgumentOutOfRangeException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);

            try
            {
                raised = false;
                args   = new string[] { "-a", "adfadf", samplePaths.shpBuffaloFeet };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            }
            catch (ArgumentException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);

            try
            {
                raised = false;
                args   = new string[] { samplePaths.shpNone };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            }
            catch (System.IO.FileNotFoundException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);

            try
            {
                raised = false;
                args   = new string[] { samplePaths.gdbBadWorkspace };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);
            }
            catch (System.IO.FileNotFoundException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);



            try
            {
                raised = false;
                args   = new string[] { "-a", "2.2", "-f", "fullname", @"C:\samples1\BuffaloRoads_feet.shp" };
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out relPath);

                ClassLib.Run run = new ClassLib.Run(fc, angle, roadField, isDissolved);
                run.go();
            }
            catch (System.IO.IOException)
            {
                raised = true;
            }
            Assert.IsTrue(raised);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {

            if (args.Length == 0 || ClassLib.ParseCommandLine.isHelp(args))
            {
                Console.WriteLine(ClassLib.ParseCommandLine.helpMessage);
                Environment.Exit(0);
            }

            ClassLib.LicenseInit.InitializeLicence();

            IFeatureClass fc;
            string roadField;
            double angle;
            bool isDissolved;
            bool multi;
            string outWksp;

            try
            {
                ClassLib.ParseCommandLine.parseCommand(args, out fc, out roadField, out angle, out isDissolved, out multi, out outWksp);

                if (multi)
                {
                    for (double a = 0.5; a <= 1.6; a += 0.1)
                    {
                        Console.WriteLine("Running angle {0}", a);
                        ClassLib.Run run = new ClassLib.Run(fc, a, roadField, isDissolved, outWksp);
                        run.go();
                        Console.WriteLine("Output to: {0}", run.outputPath);
                    }
                }
                else
                {
                    ClassLib.Run run = new ClassLib.Run(fc, angle, roadField, isDissolved, outWksp);
                    run.go();
                    Console.WriteLine("Output to: {0}", run.outputPath);
                }
                Console.WriteLine("Finished Sucessfully");
            }
            catch (IndexOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (System.IO.FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (System.IO.IOException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }