/// <summary> /// /// </summary> public static void AddBaseLayers(Map pMap) { var mBasemap = new MapGroup(); mBasemap.LegendText = "Base Map"; var mLandFilename = Application.StartupPath + "\\GisData\\land.shp"; PolygonLayer mLandLayer = (PolygonLayer)mBasemap.Layers.Add(mLandFilename); mLandLayer.Symbolizer = new PolygonSymbolizer(GoogleMapsColors.Land); mLandLayer.LegendText = "Abu Dhabi Emirate"; mLandLayer.Projection = KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone40N; mLandLayer.Reproject(pMap.Projection); var mRoadsFilename = Application.StartupPath + "\\GisData\\roadssub.shp"; LineLayer mRoadsLayer = (LineLayer)mBasemap.Layers.Add(mRoadsFilename); mRoadsLayer.Symbolizer = new LineSymbolizer(GoogleMapsColors.MajorRoad, 2); mRoadsLayer.LegendText = "Approved Roads"; mRoadsLayer.Projection = KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone40N; mRoadsLayer.Reproject(pMap.Projection); var ms = new ShapefileDataProvider(); var ms2 = ms.Open(Application.StartupPath + "\\GisData\\roadssub.shp"); pMap.Layers.Add(mBasemap); pMap.Legend.RefreshNodes(); mLandLayer.SelectionEnabled = false; mRoadsLayer.SelectionEnabled = false; ExtFunctions.AddLabelsForFeatureLayer(mRoadsLayer, "Road IDs", "[ADRROADID]", Color.LightBlue, "Arial", 10, true); pMap.ViewExtents = mRoadsLayer.Extent; pMap.Refresh(); }
/// <summary> /// This create new method implies that this provider has the priority for creating a new file. /// An instance of the dataset should be created and then returned. By this time, the fileName /// will already be checked to see if it exists, and deleted if the user wants to overwrite it. /// </summary> /// <param name="fileName">The string fileName for the new instance.</param> /// <param name="featureType">Point, Line, Polygon etc. Sometimes this will be specified, sometimes it will be "Unspecified".</param> /// <param name="inRam">Boolean, true if the dataset should attempt to store data entirely in ram.</param> /// <param name="container">The container for this layer. This can be null.</param> /// <param name="progressHandler">An IProgressHandler for status messages.</param> /// <returns>An IRaster.</returns> public IFeatureLayer CreateNew(string fileName, FeatureType featureType, bool inRam, ICollection <ILayer> container, IProgressHandler progressHandler) { ShapefileDataProvider dp = new ShapefileDataProvider(); if (progressHandler == null) { progressHandler = LayerManager.DefaultLayerManager.ProgressHandler; } IFeatureSet fs = dp.CreateNew(fileName, featureType, inRam, progressHandler); if (fs.FeatureType == FeatureType.Line) { return(new MapLineLayer(fs, container)); } if (fs.FeatureType == FeatureType.Polygon) { return(new MapPolygonLayer(fs, container)); } if (fs.FeatureType == FeatureType.Point || fs.FeatureType == FeatureType.MultiPoint) { return(new MapPointLayer(fs, container)); } return(null); }
/// <summary> /// Opens a shapefile, but returns it as a FeatureLayer. /// </summary> /// <param name="fileName">The string fileName.</param> /// <param name="inRam">Boolean, if this is true it will attempt to open the entire layer in memory.</param> /// <param name="container">A container to hold this layer.</param> /// <param name="progressHandler">The progress handler that should receive status messages.</param> /// <returns>An IFeatureLayer.</returns> public ILayer OpenLayer(string fileName, bool inRam, ICollection <ILayer> container, IProgressHandler progressHandler) { ShapefileDataProvider dp = new ShapefileDataProvider(); IFeatureSet fs = dp.Open(fileName); if (fs != null) { if (fs.FeatureType == FeatureType.Line) { return(new MapLineLayer(fs, container)); } if (fs.FeatureType == FeatureType.Polygon) { return(new MapPolygonLayer(fs, container)); } if (fs.FeatureType == FeatureType.Point || fs.FeatureType == FeatureType.MultiPoint) { return(new MapPointLayer(fs, container)); } } return(null); }
public static IFeatureSet OpenFeatureSet(string dataPath) { IFeatureSet dataSet = null; string extension = Path.GetExtension(dataPath); ShapefileDataProvider shapefileDataProvider = new ShapefileDataProvider(); if (GetSupportedExtensions(shapefileDataProvider.DialogReadFilter).Contains(extension)) { dataSet = shapefileDataProvider.Open(dataPath); } return(dataSet); }