private void OpenLayer() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Shapefiles|*.shp"; if (ofd.ShowDialog() != DialogResult.OK) return; FeatureSet fs = new FeatureSet(); fs.Open(ofd.FileName); geoMap1.Layers.Add(fs); FeatureSet newFeature = new FeatureSet(); newFeature.CopyTableSchema(fs); foreach(Feature f in fs.Features) { newFeature.Features.Add(f); } bool stop = true; }
private void RemoveAndInsert() { FeatureSet cities = new FeatureSet(); FeatureSet states = new FeatureSet(); cities.Open(@"C:\dev\SampleData\HIS_Desktop\cities.shp"); states.Open(@"C:\dev\SampleData\HIS_Desktop\states.shp"); IMapFeatureLayer cityLayer = geoMap1.Layers.Add(cities); IMapFeatureLayer stateLayer = geoMap1.Layers.Add(states); geoMap1.Layers.Remove(stateLayer); geoMap1.Layers.Insert(0, stateLayer); }
private void CreateLayers() { FeatureSet cities = new FeatureSet(); FeatureSet states = new FeatureSet(); cities.Open(@"C:\dev\SampleData\HIS_Desktop\cities.shp"); states.Open(@"C:\dev\SampleData\HIS_Desktop\states.shp"); IMapFeatureLayer cityLayer = new MapPointLayer(cities); IMapFeatureLayer stateLayer = new MapPolygonLayer(states); geoMap1.Layers.Insert(0, cityLayer); geoMap1.Layers.Insert(0, stateLayer); }
private bool ImportFieldsFromDbf() { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "DBase Files (*.dbf)|*.DBF"; FeatureSet fs = new FeatureSet(); FeatureSet fsTemp = new FeatureSet(); fsTemp.CopyFeatures(_featureLayer.DataSet, true); if (dlg.ShowDialog() != DialogResult.OK) return false; string shapeFilePath2 = dlg.FileName; int count = shapeFilePath2.Length; shapeFilePath2 = shapeFilePath2.Remove(count - 4, 4);//remove the extension of the file shapeFilePath2 = shapeFilePath2 + ".shp";//add fs.Open(shapeFilePath2); int noOfCol = fs.DataTable.Columns.Count; //Add all column header for (int i = 0; i < noOfCol; i++) { DataColumn dtcol = new DataColumn(fs.DataTable.Columns[i].ColumnName, fs.DataTable.Columns[i].DataType); if (fsTemp.DataTable.Columns.Contains(fs.DataTable.Columns[i].ColumnName) == false) fsTemp.DataTable.Columns.Add(dtcol); } dataGridView1.DataSource = fsTemp.DataTable; return true; }