private static void AssertEquivalentNormalization(normalization actual, normalization expected)
 {
     Assert.That(actual, Is.Not.Null);
     Assert.That(actual.name, Is.EqualTo(expected.name));
     Assert.That(actual.@default, Is.Null);
     Assert.That(actual.localized, Is.Null);
 }
        public void DigitsLettersCaseInsensitiveNormalization()
        {
            var normalization = new normalization {
                name = "Keep digits and letters, case insensitive"
            };
            var options = _container.Resolve <ConfigurationOptions>();
            var actual  = options.Normalization(Normalization.DigitsLettersCaseInsensitive);

            AssertEquivalentNormalization(actual, normalization);
        }
        public void DigitsLettersNormalization()
        {
            var normalization = new normalization {
                name = "Keep digits and letters (e.g. Text123)"
            };
            var options = _container.Resolve <ConfigurationOptions>();
            var actual  = options.Normalization(Normalization.DigitsLetters);

            AssertEquivalentNormalization(actual, normalization);
        }
        public void DigitsNormalization()
        {
            var normalization = new normalization {
                name = "Keep digits only (e.g. 1234)"
            };
            var options = _container.Resolve <ConfigurationOptions>();
            var actual  = options.Normalization(Normalization.Digits);

            AssertEquivalentNormalization(actual, normalization);
        }
        public void CaseInsensitiveNormalization()
        {
            var normalization = new normalization {
                name = "Case insensitive"
            };
            var options = _container.Resolve <ConfigurationOptions>();
            var actual  = options.Normalization(Normalization.CaseInsensitive);

            AssertEquivalentNormalization(actual, normalization);
        }
        public void NoNormalization()
        {
            var normalization = new normalization {
                name = "(no refinement)"
            };
            var options = _container.Resolve <ConfigurationOptions>();
            var actual  = options.Normalization(Normalization.None);

            AssertEquivalentNormalization(actual, normalization);
        }
Example #7
0
        private static Normalization MapNormalization(normalization normalization)
        {
            switch (normalization.name)
            {
            case "(no refinement)":
                return(Import.Configuration.Normalization.None);

            case "Case insensitive":
                return(Import.Configuration.Normalization.CaseInsensitive);

            case "Keep digits only (e.g. 1234)":
                return(Import.Configuration.Normalization.Digits);

            case "Keep digits and letters (e.g. Text123)":
                return(Import.Configuration.Normalization.DigitsLetters);

            case "Keep digits and letters, case insensitive":
                return(Import.Configuration.Normalization.DigitsLettersCaseInsensitive);
            }
            throw new ArgumentOutOfRangeException("normalization", normalization.name, "Unexpected normalization.");
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string inRst1Nm = cmbInRaster1.Text;
     string inRst2Nm = cmbInRaster2.Text;
     string outNmRst = txtOutName.Text;
     int pChange = trbPercent.Value;
     if (inRst1Nm == "" || inRst1Nm == null)
     {
         MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (inRst2Nm == "" || inRst2Nm == null)
     {
         MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (outNmRst == "" || outNmRst == null)
     {
         MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     IRaster rs1 = rstDic[inRst1Nm];
     IRaster rs2 = rstDic[inRst2Nm];
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Creating Raster. This may take a while...");
     rp.addMessage("Calculating Statistics...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     rp.Refresh();
     normalization nm = new normalization(rsUtil.createIdentityRaster(rs1), rsUtil.createIdentityRaster(rs2), pChange, rsUtil);
     try
     {
         double[][] coef = nm.Coefficients;
         outraster = rsUtil.createRaster(nm.OutRaster);
         outrastername = outNmRst;
         int bCnt = ((IRasterBandCollection)outraster).Count;
         for (int i = 0; i < bCnt; i++)
         {
             double[] intSlp  = coef[i];
             double intercept = intSlp[0];
             double slope = intSlp[1];
             double r2 = intSlp[2];
             rp.addMessage("R2, Intercept, Slope (" + (i+1).ToString() + ") = " + r2.ToString() + ", " + intercept.ToString() + ", " + slope.ToString());
         }
         if (mp != null && aM)
         {
             //rsUtil.calcStatsAndHist(((IRaster2)outRs).RasterDataset);
             IRasterLayer rsLyr = new RasterLayerClass();
             rsLyr.CreateFromRaster(outraster);
             rsLyr.Name = outrastername;
             rsLyr.Visible = false;
             mp.AddLayer((ILayer)rsLyr);
         }
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Normalizing Image" + t);
         rp.enableClose();
         this.Close();
     }
 }
Example #9
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbInRaster1.Text;
            string inRst2Nm = cmbInRaster2.Text;
            string outNmRst = txtOutName.Text;
            int    pChange  = trbPercent.Value;

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inRst2Nm == "" || inRst2Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRaster rs1 = rstDic[inRst1Nm];
            IRaster rs2 = rstDic[inRst2Nm];

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.addMessage("Calculating Statistics...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            rp.Refresh();
            normalization nm = new normalization(rsUtil.createIdentityRaster(rs1), rsUtil.createIdentityRaster(rs2), pChange, rsUtil);

            try
            {
                double[][] coef = nm.Coefficients;
                outraster     = rsUtil.createRaster(nm.OutRaster);
                outrastername = outNmRst;
                int bCnt = ((IRasterBandCollection)outraster).Count;
                for (int i = 0; i < bCnt; i++)
                {
                    double[] intSlp    = coef[i];
                    double   intercept = intSlp[0];
                    double   slope     = intSlp[1];
                    double   r2        = intSlp[2];
                    rp.addMessage("R2, Intercept, Slope (" + (i + 1).ToString() + ") = " + r2.ToString() + ", " + intercept.ToString() + ", " + slope.ToString());
                }
                if (!(txtModelPath.Text == "" || txtModelPath.Text == null))
                {
                    nm.writeModel(txtModelPath.Text);
                }
                if (mp != null && aM)
                {
                    //rsUtil.calcStatsAndHist(((IRaster2)outRs).RasterDataset);
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = outrastername;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Normalizing Image" + t);
                rp.enableClose();
                this.Close();
            }
        }