Ejemplo n.º 1
0
        private void frmAdvSWM_Load(object sender, EventArgs e)
        {
            try
            {
                //New Spatial Weight matrix function 083117 HK
                clsSnippet.SpatialWeightMatrixType pSWMType = new clsSnippet.SpatialWeightMatrixType();
                if (m_pMapLayer is MapPolygonLayer) //Apply Different Spatial weight matrix according to geometry type 05/24/18 HK
                {
                    //txtSWM.Text = pSWMType.strPolySWM;
                    txtSWM.DataSource = pSWMType.strPolyDefs;

                    lblClip.Visible     = false; btnSubset.Visible = false; btnSubset.Enabled = false;
                    chkCumulate.Visible = true; chkCumulate.Text = "Cumulate neighbors:";
                    lblAdvanced.Text    = "Contiguity Order:";
                    nudAdvanced.Value   = 1; nudAdvanced.Increment = 1; nudAdvanced.DecimalPlaces = 0;

                    if (blnCorrelogram)
                    {
                        chkCumulate.Visible = false; nudAdvanced.Visible = false;
                        lblAdvanced.Visible = false;
                    }
                }
                else if (m_pMapLayer is MapPointLayer)
                {
                    //txtSWM.Text = pSWMType.strPointSWM;
                    txtSWM.DataSource   = pSWMType.strPointDef;
                    lblClip.Visible     = true; btnSubset.Visible = true; btnSubset.Enabled = true;
                    chkCumulate.Visible = false;
                    lblAdvanced.Text    = "Threshold distance:";
                    nudAdvanced.Value   = 100; nudAdvanced.Increment = 10; nudAdvanced.DecimalPlaces = 2;
                }
                else if (m_pMapLayer is MapLineLayer)
                {
                    MessageBox.Show("Spatial weight matrix for polyline is not supported.");
                    btnSubset.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Please check the type of the shapefile.");
                    btnSubset.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 2
0
        private void txtSWM_TextChanged(object sender, EventArgs e)
        {
            try
            {
                clsSnippet.SpatialWeightMatrixType pSWMType = new clsSnippet.SpatialWeightMatrixType();

                if (txtSWM.Text == pSWMType.strPointDef[0])
                {
                    lblClip.Visible     = true; lblClip.Enabled = true;
                    btnSubset.Visible   = true; btnSubset.Enabled = true;
                    chkCumulate.Visible = false;
                    lblAdvanced.Text    = "Threshold distance:";
                    lblAdvanced.Enabled = false;
                    nudAdvanced.Value   = 100; nudAdvanced.Increment = 10; nudAdvanced.DecimalPlaces = 2;
                    nudAdvanced.Enabled = false;
                }
                else if (txtSWM.Text == pSWMType.strPointDef[1])
                {
                    lblClip.Visible     = true; btnSubset.Visible = true; btnSubset.Enabled = true;
                    chkCumulate.Visible = false;
                    lblAdvanced.Text    = "Threshold distance:";
                    lblAdvanced.Enabled = true;
                    nudAdvanced.Value   = 100; nudAdvanced.Increment = 10; nudAdvanced.DecimalPlaces = 2;
                    nudAdvanced.Enabled = true;
                    btnSubset.Enabled   = false; btnSubset.Visible = false;
                    lblClip.Enabled     = false; lblClip.Visible = false;
                    //if (m_dblDefaultDistThres != null)
                    //    nudAdvanced.Value = Convert.ToDecimal(m_dblDefaultDistThres);
                }
                else if (txtSWM.Text == pSWMType.strPointDef[2])
                {
                    lblClip.Visible     = true; btnSubset.Visible = true; btnSubset.Enabled = true;
                    chkCumulate.Visible = false;
                    lblAdvanced.Text    = "Number of neighbors:";
                    lblAdvanced.Enabled = true;
                    nudAdvanced.Value   = 4; nudAdvanced.Increment = 1; nudAdvanced.DecimalPlaces = 0;
                    nudAdvanced.Enabled = true;
                    btnSubset.Enabled   = false; btnSubset.Visible = false;
                    lblClip.Enabled     = false; lblClip.Visible = false;
                }
                else
                {
                    lblClip.Visible     = false; btnSubset.Visible = false; btnSubset.Enabled = false;
                    chkCumulate.Enabled = false; chkCumulate.Visible = true;
                    lblAdvanced.Enabled = true; lblAdvanced.Text = "Contiguity Order:";
                    nudAdvanced.Enabled = true; nudAdvanced.Value = 1; nudAdvanced.Increment = 1; nudAdvanced.DecimalPlaces = 0;

                    int intT = pSWMType.strPolyDefs.Length;
                    for (int i = 0; i < intT; i++)
                    {
                        if (txtSWM.Text == pSWMType.strPolyDefs[i])
                        {
                            return;
                        }
                    }
                    btnSubset.Enabled   = false;
                    chkCumulate.Enabled = false;
                    lblAdvanced.Enabled = false;
                    nudAdvanced.Enabled = false;
                    lblClip.Enabled     = false;
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 3
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cboTargetLayer.Text != "" && cboFamily.Text != "")
                {
                    string strLayerName = cboTargetLayer.Text;
                    m_pMaplayer = null;
                    for (int i = 0; i < m_pForm.map1.Layers.Count; i++)
                    {
                        if (strLayerName == m_pForm.map1.Layers[i].DataSet.Name)
                        {
                            m_pMaplayer = m_pForm.map1.Layers[i];
                        }
                    }


                    groupBox1.Enabled = true;

                    clsSnippet.SpatialWeightMatrixType pSWMType = new clsSnippet.SpatialWeightMatrixType();
                    if (m_pMaplayer is MapPointLayer)
                    {
                        MapPointLayer pMapPointLyr = default(MapPointLayer);
                        pMapPointLyr = (MapPointLayer)m_pMaplayer;
                        m_dt         = pMapPointLyr.DataSet.DataTable;
                        txtSWM.Text  = pSWMType.strPointSWM;
                    }
                    else if (m_pMaplayer is MapPolygonLayer)
                    {
                        MapPolygonLayer pMapPolyLyr = default(MapPolygonLayer);
                        pMapPolyLyr = (MapPolygonLayer)m_pMaplayer;
                        m_dt        = pMapPolyLyr.DataSet.DataTable;
                        txtSWM.Text = pSWMType.strPolySWM;
                    }
                    else if (m_pMaplayer is MapLineLayer)
                    {
                        MessageBox.Show("Spatial weight matrix for polyline is not supported.");
                        groupBox1.Enabled   = false;
                        chkResiAuto.Checked = false;
                    }


                    cboFieldName.Text = "";
                    lstFields.Items.Clear();
                    lstIndeVar.Items.Clear();
                    cboNormalization.Text = "";

                    if (cboFamily.Text == "Poisson")
                    {
                        for (int i = 0; i < m_dt.Columns.Count; i++)
                        {
                            if (FindNumberFieldType(m_dt.Columns[i]))
                            {
                                lstFields.Items.Add(m_dt.Columns[i].ColumnName);
                                cboNormalization.Items.Add(m_dt.Columns[i].ColumnName);
                                if (m_dt.Columns[i].DataType == Type.GetType("System.Int32"))
                                {
                                    cboFieldName.Items.Add(m_dt.Columns[i].ColumnName);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < m_dt.Columns.Count; i++)
                        {
                            if (FindNumberFieldType(m_dt.Columns[i]))
                            {
                                lstFields.Items.Add(m_dt.Columns[i].ColumnName);
                                cboNormalization.Items.Add(m_dt.Columns[i].ColumnName);
                                cboFieldName.Items.Add(m_dt.Columns[i].ColumnName);
                            }
                        }
                    }

                    if (chkSave.Checked)
                    {
                        UpdateListview(lstSave, m_dt);
                    }
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }