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