Esempio n. 1
0
        /// <summary>
        /// Moves points or vertices to coincide exactly with the vertices, edges, or end points of other features.
        /// Snapping rules can be specified to control whether the input vertices are snapped to the nearest vertex, edge, or
        /// endpoint within a specified distance
        /// </summary>
        /// <param name="source">The input features whose vertices will be snapped to the vertices, edges, or end points of other
        /// features. The input features can be points, multipoints, lines, or polygons.</param>
        /// <param name="snap">The features that the input features' vertices will be snapped to. These features can be points,
        /// multipoints, lines, or polygons.</param>
        /// <param name="snapType">The type of feature part that the input features' vertices can be snapped to (END | VERTEX |
        /// EDGE).</param>
        /// <param name="distance">The distance within which the input features' vertices will be snapped to the nearest vertex,
        /// edge, or end point.</param>
        /// <param name="units">The units.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        public static void Snap(this IFeatureClass source, IFeatureClass snap, SnapType snapType, double distance, esriUnits units, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            IUnitConverter converter = new UnitConverterClass();
            object         row       = string.Format("{0} {1} '{2} {3}'", snap.GetAbsolutePath(), snapType.ToString().ToUpperInvariant(), distance, converter.EsriUnitsAsString(units, esriCaseAppearance.esriCaseAppearanceUpper, true));

            IGpValueTableObject table = new GpValueTableObjectClass();

            table.SetColumns(3);
            table.AddRow(ref row);

            source.Snap(table, trackCancel, eventHandler);
        }
Esempio n. 2
0
        /// <summary>
        ///     Joins attributes from one feature to another based on the spatial relationship. The target features and the joined
        ///     attributes from the join features are written to the output feature class.
        /// </summary>
        /// <param name="source">
        ///     The source features and the attributes from the joined features are transferred to the output
        ///     feature class. However, a subset of attributes can be defined in the field map parameter.
        /// </param>
        /// <param name="join">The attributes from the join features are joined to the attributes of the source features.</param>
        /// <param name="tableName">A new feature class containing the attributes of the target and join features.</param>
        /// <param name="operation">
        ///     Determines how joins between the target features and join features will be handled in the
        ///     output feature class if multiple join features are found that have the same spatial relationship with a single
        ///     target feature.
        /// </param>
        /// <param name="isOuterJoin">
        ///     if set to <c>true</c> if all target features will be maintained in the output feature class
        ///     (known as outer join), or only those that have the specified spatial relationship with the join features (inner
        ///     join).
        /// </param>
        /// <param name="option">Defines the criteria used to match rows.</param>
        /// <param name="caseFields">The attribute fields will be in the output feature class.</param>
        /// <param name="searchRadius">
        ///     Join features within this distance of a target feature will be considered for the spatial
        ///     join.
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>Returns a <see cref="IFeatureClass" /> representing the feature class of the joined data.</returns>
        public static IFeatureClass Join(this IFeatureClass source, IFeatureClass join, string tableName, JoinOperation operation, bool isOuterJoin, SpatialOperation option, string[] caseFields, double searchRadius, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            IGpFieldMappingsObject fieldMappings = new GpFieldMappingsObjectClass();

            fieldMappings.AddTable(source.GetAbsolutePath());
            fieldMappings.AddTable(join.GetAbsolutePath());

            int[] caseIndexes = caseFields.Select(fieldMappings.FindFieldMapIndex).ToArray();

            for (int i = fieldMappings.FieldCount - 1; i >= 0; i--)
            {
                if (caseIndexes.Contains(i))
                {
                    continue;
                }

                fieldMappings.RemoveFieldMap(i);
            }

            return(source.Join(join, tableName, operation, isOuterJoin, option, fieldMappings, searchRadius, trackCancel, eventHandler));
        }