Exemplo n.º 1
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string mapFld   = cmbMap.Text;
            string refFld   = cmbRef.Text;
            string wght     = cmbWeight.Text;
            string rstNm    = cmbRst.Text;
            bool   edSas    = chbEditSas.Checked;
            bool   exact    = chbExact.Checked;
            double alpha    = System.Convert.ToDouble(nudAlpha.Value);

            if (wght != null && wght != "")
            {
                WEIGHT = wght;
            }
            if (smpFtrNm == null || smpFtrNm == "")
            {
                MessageBox.Show("You must select a feature Class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (mapFld == null || mapFld == "")
            {
                MessageBox.Show("You must select a map field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (refFld == null || refFld == "")
            {
                MessageBox.Show("You must select a Reference field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Visible = false;
            IFeatureClass      ftrCls = ftrDic[smpFtrNm];
            accuracyAssessment aa     = new accuracyAssessment();

            aa.SampleLocations = ftrCls;
            aa.MapField        = mapFld;
            aa.ReferenceField  = refFld;
            aa.WeightField     = WEIGHT;
            aa.Alpha           = alpha;
            aa.Exact           = exact;
            if (rstNm != null && rstNm != "")
            {
                //can be either a raster or feature class looking for the ITABLE
                object mapObj = rstDic[rstNm];
                ITable mapTbl = null;
                if (mapObj is IRaster)
                {
                    IRaster  rs  = (IRaster)mapObj;
                    IRaster2 rs2 = (IRaster2)rs;
                    mapTbl = rs2.AttributeTable;
                }
                else
                {
                    IFeatureClass mFtrCls = (IFeatureClass)mapObj;
                    mapTbl = (ITable)mFtrCls;
                }
                aa.InTable = mapTbl;
            }
            aa.runSasProcedure();
            aa.showModelOutput();
            if (edSas)
            {
                aa.editSasFile();
            }
            this.Close();
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string mapFld = cmbMap.Text;
            string refFld = cmbRef.Text;
            string wght = cmbWeight.Text;
            string rstNm = cmbRst.Text;
            bool edSas = chbEditSas.Checked;
            bool exact = chbExact.Checked;
            double alpha = System.Convert.ToDouble(nudAlpha.Value);
            if (wght != null && wght != "")
            {
                WEIGHT = wght;
            }
            if (smpFtrNm == null || smpFtrNm == "")
            {
                MessageBox.Show("You must select a feature Class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (mapFld == null || mapFld == "")
            {
                MessageBox.Show("You must select a map field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (refFld == null || refFld == "")
            {
                MessageBox.Show("You must select a Reference field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Visible = false;
            IFeatureClass ftrCls = ftrDic[smpFtrNm];
            accuracyAssessment aa = new accuracyAssessment();
            aa.SampleLocations = ftrCls;
            aa.MapField = mapFld;
            aa.ReferenceField = refFld;
            aa.WeightField = WEIGHT;
            aa.Alpha = alpha;
            aa.Exact = exact;
            if(rstNm!=null&&rstNm!="")
            {
                //can be either a raster or feature class looking for the ITABLE
                object mapObj = rstDic[rstNm];
                ITable mapTbl = null;
                if (mapObj is IRaster)
                {
                    IRaster rs = (IRaster)mapObj;
                    IRaster2 rs2 = (IRaster2)rs;
                    mapTbl = rs2.AttributeTable;

                }
                else
                {
                    IFeatureClass mFtrCls = (IFeatureClass)mapObj;
                    mapTbl = (ITable)mFtrCls;
                }
                aa.InTable = mapTbl;
            }
            aa.runSasProcedure();
            aa.showModelOutput();
            if (edSas)
            {
                aa.editSasFile();
            }
            this.Close();
        }