private void NewFeatureLayer(DotSpatial.Controls.IMap map, string directory) { string filename = Path.Combine(directory, this.Name + ".shp"); if (!File.Exists(filename)) { CreateFeature(map.Projection, directory); } this.Feature = FeatureSet.Open(filename); if (this.Feature.FeatureType == FeatureType.Polygon) { var layer = new MapPolygonLayer(this.Feature); map.Layers.Add(layer); this.FeatureLayer = layer; } else if (this.Feature.FeatureType == FeatureType.Line) { var layer = new MapLineLayer(this.Feature); map.Layers.Add(layer); this.FeatureLayer = layer; } else if (this.Feature.FeatureType == FeatureType.Point) { var layer = new MapPointLayer(this.Feature); map.Layers.Add(layer); this.FeatureLayer = layer; } }
public virtual void Attach(DotSpatial.Controls.IMap map, string directory) { string filename = Path.Combine(directory, this.Name + ".shp"); this.FeatureLayer = MapHelper.Select(filename, map, ModelService.ProjectDirectory) as IMapFeatureLayer; if (this.FeatureLayer != null) { this.Feature = this.FeatureLayer.DataSet; } if (this.FeatureLayer == null) { NewFeatureLayer(map, directory); } }