/// <summary> /// Exports the source table using the query filter to the table in the output workspace. /// </summary> /// <param name="source">The source.</param> /// <param name="filter">The filter.</param> /// <param name="tableName">Name of the output table.</param> /// <param name="workspace">The output workspace.</param> /// <param name="requiredFields">The required fields.</param> /// <param name="handle">The handle.</param> /// <param name="surrogate">The surrogate for the event handler.</param> /// <param name="invalid">The errors that occured during the export.</param> /// <param name="errors">The field errors.</param> /// <returns> /// Returns a <see cref="IFeatureClass" /> representing the feature class that was exported. /// </returns> public static ITable Export(this ITable source, IQueryFilter filter, string tableName, IWorkspace workspace, IFields requiredFields, int handle, FeatureProgress surrogate, out IEnumInvalidObject invalid, out IEnumFieldError errors) { var ds = (IDataset)source; var input = ds.Workspace.Define(ds.Name, new TableNameClass()); var output = workspace.Define(tableName, new TableNameClass()); workspace.Delete(output); IFieldChecker fieldChecker = new FieldCheckerClass(); fieldChecker.InputWorkspace = ds.Workspace; fieldChecker.ValidateWorkspace = workspace; IFields targetFields; fieldChecker.Validate(requiredFields, out errors, out targetFields); var featureDataConverter = new FeatureDataConverterClass(); if (surrogate != null) { surrogate.Advise(featureDataConverter); } invalid = featureDataConverter.ConvertTable(input, filter, null, output, targetFields, "", 1000, handle); return(((IName)output).Open() as ITable); }
/// <summary> /// Converts the event route source to a stand-alone feature class. /// </summary> /// <param name="outputTableName">The name of the output feature class.</param> /// <param name="filter">The filter used to limit the number of features converted.</param> /// <param name="workspace">The workspace that will contain the feature class.</param> /// <returns> /// Returns a <see cref="IFeatureClass" /> representing the results of the conversion. /// </returns> public IFeatureClass Convert(string outputTableName, IQueryFilter filter, IWorkspace workspace) { var source = (IFeatureClass)this.FeatureClass; var geometryDef = ((IClone)source.GetGeometryDef()) as IGeometryDef; IFieldChecker checker = new FieldCheckerClass(); IEnumFieldError errors; IFields fields; checker.InputWorkspace = workspace; checker.ValidateWorkspace = workspace; checker.Validate(source.Fields, out errors, out fields); var outputClassName = workspace.Define(outputTableName, new FeatureClassNameClass()); workspace.Delete(outputClassName); var dataConverter = new FeatureDataConverterClass(); var invalidObjects = dataConverter.ConvertFeatureClass((IDatasetName)this.Name, filter, null, null, outputClassName, geometryDef, fields, "", 1000, 0); if (invalidObjects.AsEnumerable().Any()) { return(null); } var route = workspace.GetFeatureClass(outputTableName); return(route); }
/// <summary> /// Locates the polygon features along the route and writes the result to a new line event table. /// </summary> /// <param name="locatePolygonsAlongRouteName">Name of the locate polygons along route.</param> /// <param name="polygons">The polygons to locate.</param> /// <param name="keepZeroLengthEvents"> /// if set to <c>true</c> allows you to keep or not keep the zero length line events in /// the output event table. The zero length line events result from a case where the geometric intersection of the /// route (line) and the polygon is a point. /// </param> /// <param name="properties"> /// Parameter consisting of the route location fields and the type of events that will be written /// to the output event table. /// </param> /// <param name="filter">An optional filter used to use a subset of the polygon data.</param> /// <param name="keepAllFields"> /// Allows you to include or disinclude the attributes of the point feature class. If this is /// set to False, the output event table will only contain the route event properties. /// </param> /// <param name="workspace">The workspace that will contain the event data table.</param> /// <returns> /// Returns a <see cref="ITable" /> representing the event table of the results. /// </returns> public ITable Locate(string locatePolygonsAlongRouteName, IFeatureClass polygons, bool keepZeroLengthEvents, IRouteMeasureLineProperties properties, IQueryFilter filter, bool keepAllFields, IWorkspace workspace) { var locator = this.GetRouteLocatorOperations(filter, polygons); var outputClassName = workspace.Define(locatePolygonsAlongRouteName, new TableNameClass()); workspace.Delete(outputClassName); return(locator.LocatePolygonFeatures((IRouteEventProperties)properties, keepAllFields, keepZeroLengthEvents, outputClassName, "", null)); }
/// <summary> /// Locate line features along the route and writes the result to a new line event table. /// </summary> /// <param name="locateLinesAlongRouteName">The name of the event table of the located features.</param> /// <param name="lines">The lines to locate.</param> /// <param name="clusterTolerance"> /// The cluster tolerance which is a numeric value /// representing the maximum tolerated distance between the input lines and the target routes. /// </param> /// <param name="properties"> /// Parameter consisting of the route location fields and the type of events that will be written /// to the output event table. /// </param> /// <param name="filter">An optional filter used to use a subset of the line data.</param> /// <param name="keepAllFields"> /// Allows you to include or disinclude the attributes of the point feature class. If this is /// set to False, the output event table will only contain the route event properties. /// </param> /// <param name="workspace">The workspace that will contain the event data table.</param> /// <returns> /// Returns a <see cref="ITable" /> representing the event table of the results. /// </returns> public ITable Locate(string locateLinesAlongRouteName, IFeatureClass lines, double clusterTolerance, IRouteMeasureLineProperties properties, IQueryFilter filter, bool keepAllFields, IWorkspace workspace) { var locator = this.GetRouteLocatorOperations(filter, lines); var outputClassName = workspace.Define(locateLinesAlongRouteName, new TableNameClass()); workspace.Delete(outputClassName); return(locator.LocateLineFeatures(clusterTolerance, (IRouteEventProperties)properties, keepAllFields, outputClassName, "", null)); }
/// <summary> /// Locate point features along the route and writes the result to a new point event table. /// </summary> /// <param name="locatePointsAlongRouteName">The name of the event table of the located features.</param> /// <param name="points">The points to locate.</param> /// <param name="searchRadius"> /// If the input features are points, the search radius is a numeric value defining how far around each point a search /// will be done to find a target route. If the input features are lines, the search tolerance is really a cluster /// tolerance, which is a numeric value /// representing the maximum tolerated distance between the input lines and the target routes. If the input features /// are polygons, this parameter is ignored since no search radius is used. /// </param> /// <param name="searchMultipleLocations"> /// If the point falls on more than one route for the given search radius, you can /// have the option to create multiple event records that correspond to each route in the search radius vicinity /// </param> /// <param name="properties"> /// Parameter consisting of the route location fields and the type of events that will be written /// to the output event table. /// </param> /// <param name="filter">An optional filter used to use a subset of the point data.</param> /// <param name="keepAllFields"> /// Allows you to include or disinclude the attributes of the point feature class. If this is /// set to False, the output event table will only contain the route event properties. /// </param> /// <param name="workspace">The workspace that will contain the event data table.</param> /// <returns> /// Returns a <see cref="ITable" /> representing the event table of the results. /// </returns> public ITable Locate(string locatePointsAlongRouteName, IFeatureClass points, double searchRadius, bool searchMultipleLocations, IRouteMeasurePointProperties properties, IQueryFilter filter, bool keepAllFields, IWorkspace workspace) { var locator = this.GetRouteLocatorOperations(filter, points); var outputClassName = workspace.Define(locatePointsAlongRouteName, new TableNameClass()); workspace.Delete(outputClassName); return(locator.LocatePointFeatures(searchRadius, searchMultipleLocations, (IRouteEventProperties)properties, keepAllFields, outputClassName, "", null)); }
/// <summary> /// Identifies those features in the source table that are contained by features in the table being joined. /// </summary> /// <param name="source">The source.</param> /// <param name="join">The spatial table to append fields from.</param> /// <param name="isLeftOuterJoin"> /// if set to <c>true</c> when a match is required before adding a record from the source /// feature class to the result. If TRUE, all records in the source feature class are added regardless of whether there /// is a match. /// </param> /// <param name="workspace">The workspace.</param> /// <param name="outputName">Name of the output.</param> /// <returns>Returns a <see cref="IFeatureClass" /> representing the joined feature class.</returns> public static IFeatureClass Within(this IFeatureClass source, ITable join, bool isLeftOuterJoin, IWorkspace workspace, string outputName) { ISpatialJoin sj = new SpatialJoinClass(); sj.ShowProcess[true] = 0; sj.LeftOuterJoin = isLeftOuterJoin; sj.SourceTable = (ITable)source; sj.JoinTable = join; var ds = workspace.Define(outputName, new FeatureClassNameClass()); workspace.Delete(ds); return(sj.JoinWithin(ds)); }
/// <summary> /// Creates a feature class containing points generated from specified vertices or locations of the input features. /// </summary> /// <param name="source">The source.</param> /// <param name="outputTableName">Name of the output table.</param> /// <param name="workspace">The workspace.</param> /// <param name="trackCancel">The track cancel.</param> /// <param name="eventHandler">The events.</param> /// <param name="location">The location.</param> /// <remarks>License ArcGIS Desktop Advanced: Yes</remarks> /// <returns> /// Returns a <see cref="IFeatureClass" /> representing the feature class. /// </returns> private static IFeatureClass CreateVertexPointsImpl(IFeatureClass source, string outputTableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler, string location) { var tableName = workspace.Define(outputTableName, new FeatureClassNameClass()); workspace.Delete(tableName); FeatureVerticesToPoints gp = new FeatureVerticesToPoints(); gp.in_features = source; gp.out_feature_class = workspace.GetAbsolutePath(outputTableName); gp.point_location = location; var status = gp.Run(trackCancel, eventHandler); return(status == esriJobStatus.esriJobSucceeded ? workspace.GetFeatureClass(outputTableName) : null); }
/// <summary> /// Exports the source table using the query filter to the table in the output workspace. /// </summary> /// <param name="source">The source.</param> /// <param name="filter">The filter.</param> /// <param name="tableName">Name of the output table.</param> /// <param name="workspace">The output workspace.</param> /// <param name="requiredFields">The required fields.</param> /// <param name="handle">The handle.</param> /// <param name="keepFeatureDatset">if set to <c>true</c> when the feature class should be created within feature datset.</param> /// <param name="surrogate">The surrogate for the event handler.</param> /// <param name="invalid">The errors that occured during the export.</param> /// <param name="errors">The field errors.</param> /// <returns> /// Returns a <see cref="IFeatureClass" /> representing the feature class that was exported. /// </returns> public static IFeatureClass Export(this IFeatureClass source, IQueryFilter filter, string tableName, IWorkspace workspace, IFields requiredFields, int handle, bool keepFeatureDatset, FeatureProgress surrogate, out IEnumInvalidObject invalid, out IEnumFieldError errors) { var ds = (IDataset)source; var input = ds.Workspace.Define(ds.Name, new FeatureClassNameClass()); var output = workspace.Define(tableName, new FeatureClassNameClass()); if (source.FeatureDataset != null && keepFeatureDatset) { output.FeatureDatasetName = source.FeatureDataset.FullName as IDatasetName; } var i = source.Fields.FindField(source.ShapeFieldName); var field = source.Fields.Field[i]; var clone = (IClone)field.GeometryDef; var geometryDef = (IGeometryDef)clone.Clone(); workspace.Delete(output); IFieldChecker fieldChecker = new FieldCheckerClass(); fieldChecker.InputWorkspace = ds.Workspace; fieldChecker.ValidateWorkspace = workspace; IFields targetFields; fieldChecker.Validate(requiredFields, out errors, out targetFields); var featureDataConverter = new FeatureDataConverterClass(); if (surrogate != null) { surrogate.Advise(featureDataConverter); } invalid = featureDataConverter.ConvertFeatureClass(input, filter, null, output, geometryDef, targetFields, "", 1000, handle); return(((IName)output).Open() as IFeatureClass); }