private void buttonOK_Click(object sender, EventArgs e) { //有效性验证 m_dataInfo = inputAndOutput.GetDataInfo(); m_bLocal = checkBoxLocal.Checked; string filePath = m_dataInfo.GetOutputFilePath(); string fileName = m_dataInfo.GetOutputFileName(); #region 参数有效性验证 if (m_dataInfo.IsValid() == false) return; if (File.Exists(filePath + "\\" + fileName)) { MessageBox.Show(fileName + "文件已存在,请重新输入!"); return; } #endregion //计算得到聚类结果 m_ASCDTCluster = new ASCDT(m_dataInfo, m_bLocal); m_Clusters = m_ASCDTCluster.GetClusters(); //保存到shp SaveShapefile shapefile = new SaveShapefile(m_dataInfo, m_Clusters); shapefile.CreatePolygonShapefile(); shapefile.CreatePointsShapefile(); IFeatureLayer pointLayer = shapefile.GetPointFeatureLayer(); IFeatureLayer polygonLayer = shapefile.GetPolygonFeatureLayer(); //渲染显示 RenderLayer layerRenderer = new RenderLayer(); layerRenderer.DefinePointUniqueValueRenderer(pointLayer as IGeoFeatureLayer, "index"); layerRenderer.DefinePolygonUniqueValueRenderer(polygonLayer as IGeoFeatureLayer, "index"); m_mapControl.AddLayer(polygonLayer as ILayer); m_mapControl.AddLayer(pointLayer as ILayer); this.m_mapControl.Refresh(); this.Close(); //需要添加如果一类都没有获得的情况 }
private IFeatureLayer m_polygonLayer; //聚类后的凸包图层 #endregion Fields #region Constructors public SaveShapefile(DataInformation dataInfo, Clusters clusters) { m_dataInfo = dataInfo; m_clusters = clusters; }
private void buttonOK_Click(object sender, EventArgs e) { //有效性验证 m_dataInfo = inputAndOutput.GetDataInfo(); string filePath = m_dataInfo.GetOutputFilePath(); string fileName = m_dataInfo.GetOutputFileName(); #region 参数有效性验证 if (m_dataInfo.IsValid() == false) return; if (textBoxEps.Text == "") { MessageBox.Show("区域半径输入错误!"); return; } if (textBoxMinPts.Text == "") { MessageBox.Show("最小点数输入错误!"); return; } if (File.Exists(filePath + "\\" + fileName)) { MessageBox.Show(fileName + "文件已存在,请重新输入!"); return; } #endregion //参数获取 m_dEps = m_dataInfo.UnitsConvertToMeters(float.Parse(textBoxEps.Text), m_mapControl.MapUnits); m_nMinPts = int.Parse(textBoxMinPts.Text); //计算得到聚类结果 m_DBSCANCluster = new DBSCAN(m_dataInfo, m_dEps, m_nMinPts); m_Clusters = m_DBSCANCluster.GetClusters(); //保存到shp SaveShapefile shapefile = new SaveShapefile(m_dataInfo, m_Clusters); shapefile.CreatePolygonShapefile(); shapefile.CreatePointsShapefile(); IFeatureLayer pointLayer = shapefile.GetPointFeatureLayer(); IFeatureLayer polygonLayer = shapefile.GetPolygonFeatureLayer(); //渲染显示 RenderLayer layerRenderer = new RenderLayer(); layerRenderer.DefinePointUniqueValueRenderer(pointLayer as IGeoFeatureLayer, "index"); layerRenderer.DefinePolygonUniqueValueRenderer(polygonLayer as IGeoFeatureLayer, "index"); m_mapControl.AddLayer(polygonLayer as ILayer); m_mapControl.AddLayer(pointLayer as ILayer); this.m_mapControl.Refresh(); this.Close(); }
private Clusters m_clusters; //聚类结果 public SaveShapefile(DataInformation dataInfo, Clusters clusters) { m_dataInfo = dataInfo; m_clusters = clusters; }