/// <summary>
        ///     Locates the along route implementation.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="locateAlongRouteName">Name of the locate along route.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="sourceWhereClause">The source where clause.</param>
        /// <param name="route">The route.</param>
        /// <param name="routeWhereClause">The route where clause.</param>
        /// <param name="routeIDFieldName">Name of the route identifier field.</param>
        /// <param name="radiusOrTolerance">The radius or tolerance.</param>
        /// <param name="radiusOrToleranceUnits">The radius or tolerance units.</param>
        /// <param name="searchMultipleLocations">if set to <c>true</c> [search multiple locations].</param>
        /// <param name="keepAllFields">if set to <c>true</c> [keep all fields].</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns></returns>
        private static ITable LocateAlongRouteImpl(IFeatureClass source, string locateAlongRouteName, IWorkspace workspace, string sourceWhereClause, IFeatureClass route, string routeWhereClause, string routeIDFieldName, double radiusOrTolerance, esriUnits radiusOrToleranceUnits, bool searchMultipleLocations, bool keepAllFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            var ds = (IDataset)source;

            object input    = route;
            object features = source;

            if (!string.IsNullOrEmpty(routeWhereClause))
            {
                var name = string.Format("{0}_V", ((IDataset)route).Name);
                input = route.MakeView(name, routeWhereClause, null, trackCancel, eventHandler);
            }

            if (!string.IsNullOrEmpty(sourceWhereClause))
            {
                var name = string.Format("{0}_V", ds.Name);
                features = source.MakeView(name, sourceWhereClause, null, trackCancel, eventHandler);
            }

            LocateFeaturesAlongRoutes gp = new LocateFeaturesAlongRoutes();

            gp.in_features    = features;
            gp.in_fields      = keepAllFields ? "FIELDS" : "NO_FIELDS";
            gp.in_routes      = input;
            gp.route_id_field = routeIDFieldName;

            gp.out_table = workspace.GetAbsolutePath(locateAlongRouteName);

            if (source.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                gp.out_event_properties = string.Format("{0} LINE FMEASURE TMEASURE", routeIDFieldName);
            }
            else
            {
                gp.out_event_properties = string.Format("{0} POINT MEASURE", routeIDFieldName);
            }

            IUnitConverter converter = new UnitConverterClass();

            gp.radius_or_tolerance = string.Format("{0} {1}", radiusOrTolerance, converter.EsriUnitsAsString(radiusOrToleranceUnits, esriCaseAppearance.esriCaseAppearanceUpper, true));

            gp.route_locations = searchMultipleLocations ? "ALL" : "FIRST";

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                return(workspace.GetTable(locateAlongRouteName));
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        ///     Convert ESRI unit enumerations to strings.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="appearance">The appearance to specify the case (eg. lower or upper case) of the string.</param>
        /// <param name="plural">
        ///     if set to <c>true</c> the
        ///     string specifies a many unit(s) otherwise single unit.
        /// </param>
        /// <returns>
        ///     A <see cref="System.String" /> that represents the enumeration as a string.
        /// </returns>
        public static string ToString(this esriUnits source, esriCaseAppearance appearance, bool plural)
        {
            IUnitConverter converter = new UnitConverterClass();

            return(converter.EsriUnitsAsString(source, appearance, plural));
        }
Esempio n. 3
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);
        }