Example #1
0
        /// <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);
        }
        /// <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();
        }
Example #3
0
        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);
        }