示例#1
0
        /// <summary>
        /// Create a feature class in the default geodatabase of the project.
        /// </summary>
        /// <param name="featureclassName">Name of the feature class to be created.</param>
        /// <param name="featureclassType">Type of feature class to be created. Options are:
        /// <list type="bullet">
        /// <item>POINT</item>
        /// <item>MULTIPOINT</item>
        /// <item>POLYLINE</item>
        /// <item>POLYGON</item></list></param>
        /// <returns></returns>
        public static async Task CreateFeatureClass(string featureclassName, EnumFeatureClassType featureclassType)
        {
            List <object> arguments = new List <object>
            {
                // store the results in the default geodatabase
                CoreModule.CurrentProject.DefaultGeodatabasePath,
                // name of the feature class
                featureclassName,
                // type of geometry
                featureclassType.ToString(),
                // no template
                "",
                // no z values
                "DISABLED",
                // no m values
                "DISABLED"
            };
            await QueuedTask.Run(() =>
            {
                // spatial reference
                arguments.Add(SpatialReferenceBuilder.CreateSpatialReference(3857));
            });

            IGPResult result = await Geoprocessing.ExecuteToolAsync("CreateFeatureclass_management", Geoprocessing.MakeValueArray(arguments.ToArray()));
        }
示例#2
0
        internal static async Task CreateFcWithAttributesAsync(string fcName, EnumFeatureClassType fcType)
        {
            // Create feature class T1
            await Module1.CreateFeatureClass(fcName, fcType);

            // double check to see if the layer was added to the map
            var fcLayer = MapView.Active.Map.GetLayersAsFlattenedList().Where((l) => l.Name == fcName).FirstOrDefault() as BasicFeatureLayer;

            if (fcLayer == null)
            {
                MessageBox.Show($@"Unable to find {fcName} in the active map");
                return;
            }
            {
                // add a description field to the layer
                var dataSource = await Module1.GetDataSource(fcLayer);

                System.Diagnostics.Debug.WriteLine($@"{dataSource} was found ... adding a Field");
                await
                Module1.
                ExecuteAddFieldToolAsync(fcLayer,
                                         new KeyValuePair <string, string>("Description", "Desc."), "Text", 50);
            }
        }