Subset network evaluators


Purpose
This sample includes two custom evaluators that can be plugged into a network dataset and used by the ArcGIS Network Analyst extension. The FilterSubset evaluator can be used to restrict streets based on the current selection in ArcMap. The ScaleSubset evaluator can be used to slow down streets that fall within polygon graphics on the map. Both evaluators use parameterized attributes to pass information from ArcMap to the evaluator.
Building the solution installs these two custom evaluators, adds a custom command to ArcMap, and automatically adds two context items to the ArcCatalog network dataset context menu, which is used to help create or remove network attributes that use these evaluators.
While the functionality provided by this sample is more easily handled by using polygon barriers in your analysis, the purpose of the sample is to provide help getting started using custom evaluators.
The same concepts can be used to create and consume these evaluators in an ArcGIS Engine environment.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample.

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/SanFrancisco/SanFrancisco.gdb/Transportation/Streets_ND.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

Installation
  1. Start Visual Studio.
  2. Rebuild the SubsetNetworkEvaluators solution.

Editing the network dataset to use subset network evaluators in ArcCatalog
  1. Start ArcCatalog using an ArcGIS for Desktop Basic or higher license and check out an ArcGIS Network Analyst extension license to enable network dataset schema updates.
  2. Right-click the Streets_ND network dataset in the SanFrancisco.gdb/Transportation dataset in the SanFrancisco folder, and choose Add Subset Attributes to add new attributes that have parameters and are assigned the new custom evaluators (this can also be done manually by using the property page).
  3. If you decide to uninstall these sample subset evaluators, choose Remove Subset Attributes on any network dataset that has added them. Otherwise, the network dataset will not open because it cannot instantiate these custom evaluators. Alternatively, you can manually remove or edit any attributes that use these evaluators using the property page.

Using the auto update EID array parameters command in ArcMap
  1. Close ArcCatalog.
  2. Start ArcMap with a new document and add the Streets_ND network dataset in the SanFrancisco.gdb/Transportation dataset in the SanFrancisco folder. When prompted, add the feature classes to use the feature selection.
  3. Ensure that an ArcGIS Network Analyst extension license is checked out and the Network Analyst toolbar is active.
  4. On the Network Analyst drop-down command, choose the New Route command.
  5. On the Analysis Settings property page of the new Route NALayer, set the ScaleSubset_Minutes attribute as the impedance attribute, then select the FilterSubset restriction.
  6. On the Attribute Parameters property page of the new Route NALayer, the parameters were automatically added. On the ScaleSubset_Minutes attribute, the ScaleSubset_Factor parameter value defaults to 1. In this case, use these polygons as slowdown polygons in areas of severe congestion. Therefore, to slowdown elements within slowdown polygons by a factor of 5, type 5 for the parameter value. Also, notice the *_eids_* parameters on the Attribute Parameters property page. These are the network parameters that are automatically updated if the AutoUpdateNetworkElementArrayParametersCommand command is toggled on. These arrays can also be manually set by typing in the list on this property page or by other programmatic means.
  7. Add two or more stops to the new route and solve.
  8. In ArcMap, click Customize > Custom Mode. On the Customize dialog box, click the Commands tab and the Network Analyst Samples category, then add the AutoUpdateNetworkElementArrayParametersCommand to the Network Analyst toolbar.
  9. Click the command to toggle on the auto update subset parameters, and toggle off to stop listening to selection change and graphic element change events.
  10. Select some street features, including some streets overlapping the previously solved route. Solve again. Since the AutoUpdateNetworkElementArrayParametersCommand is toggled on and you are using the FilterSubset restriction attribute for this NALayer, the selected features update the subset parameters to restrict the network elements corresponding to the selected features. The path should not go on the selected features, or if you selected too many streets, the path might not be traversable.
  11. Clear the selection and solve again. The path should go back to the original path.
  12. On the Drawing toolbar's Drawing drop-down command, click Default Symbol Properties and change the symbol to have a hollow or hatched fill symbol so you can see through polygon graphic elements added to ArcMap.
  13. Using one of the polygon drawing tools, such as New Polygon on the Drawing toolbar, digitize in one or more polygons in the vicinity of the path or stops, and resolve the route.
  14. Solve again, and the route might change. If it did not change, increase the scale factor or add larger slowdown polygon graphic elements. Unlike the filter scale evaluator, if necessary, the route can still traverse elements in the subset.
  15. Toggle off the AutoUpdateNetworkElementArrayParametersCommand to clear the EID array parameters and stop listening for selection or graphic element changes.

SubsetNetworkEvaluators\FilterSubsetEvaluator.cs Filter subset evaluator restricts a subset of network elements, for example, the elements corresponding to the selected features.
SubsetNetworkEvaluators\ScaleSubsetEvaluator.cs Scale subset evaluator scales a subset of elements from another cost attribute by a slowdown factor parameter value. Subset could be identified by slowdown polygon graphic elements.
SubsetNetworkEvaluators\SubsetHelper.cs Utility class for shared functionality used by both subset evaluators for setting up and evaluating attributes that use these evaluators.
SubsetNetworkEvaluatorsUI\AddSubsetAttributesCommand.cs ArcCatalog network dataset context menu item used to automatically add network attributes setup to use these evaluators to the context network dataset.
SubsetNetworkEvaluatorsUI\RemoveSubsetAttributesCommand.cs ArcCatalog network dataset context menu item used to automatically remove network attributes setup to use these evaluators from the context network dataset.
SubsetNetworkEvaluatorsUI\AutoUpdateNetworkElementArrayParametersCommand.cs ArcMap command used to automatically toggle synchronization of subset parameters based on feature selected and slowdown polygon graphic element edit events.
SubsetNetworkEvaluatorsUI\FilterSubsetEvaluatorEditor.cs Registered evaluator editor used to support interactive assignment, editing, and property inspection of filter subset evaluator network attribute assignments in ArcCatalog network dataset property pages.
SubsetNetworkEvaluatorsUI\ScaleSubsetEvaluatorEditor.cs Registered evaluator editor used to support interactive assignment, editing, and property inspection of scale subset evaluator network attribute assignments in ArcCatalog network dataset property pages.
SubsetNetworkEvaluatorsUI\SimpleEvaluatorProperties.cs Evaluator properties dialog box used to summarize the properties of a subset evaluator from the Evaluators dialog box of the Network Attributes Property page in ArcCatalog.
SubsetNetworkEvaluatorsUI\SubsetHelperUI.cs Utility class for shared functionality used by both subset evaluators for managing parameter EID arrays.
Download the C# files
SubsetNetworkEvaluators\FilterSubsetEvaluator.vb Filter subset evaluator restricts a subset of network elements, for example, the elements corresponding to the selected features.
SubsetNetworkEvaluators\ScaleSubsetEvaluator.vb Scale subset evaluator scales a subset of elements from another cost attribute by a slowdown factor parameter value. Subset could be identified by slowdown polygon graphic elements.
SubsetNetworkEvaluators\SubsetHelper.vb Utility class for shared functionality used by both subset evaluators for setting up and evaluating attributes that use these evaluators.
SubsetNetworkEvaluatorsUI\AddSubsetAttributesCommand.vb ArcCatalog network dataset context menu item used to automatically add network attributes setup to use these evaluators to the context network dataset.
SubsetNetworkEvaluatorsUI\RemoveSubsetAttributesCommand.vb ArcCatalog network dataset context menu item used to automatically remove network attributes setup to use these evaluators from the context network dataset.
SubsetNetworkEvaluatorsUI\AutoUpdateNetworkElementArrayParametersCommand.vb ArcMap command used to automatically toggle synchronization of subset parameters based on the feature selected and slowdown polygon graphic element edit events.
SubsetNetworkEvaluatorsUI\FilterSubsetEvaluatorEditor.vb Registered evaluator editor used to support interactive assignment, editing, and property inspection of filter subset evaluator network attribute assignments in ArcCatalog network dataset property pages.
SubsetNetworkEvaluatorsUI\ScaleSubsetEvaluatorEditor.vb Registered evaluator editor used to support interactive assignment, editing, and property inspection of scale subset evaluator network attribute assignments in ArcCatalog network dataset property pages.
SubsetNetworkEvaluatorsUI\SimpleEvaluatorProperties.vb Evaluator properties dialog box used to summarize the properties of a subset evaluator from the Evaluators dialog box of the Network Attributes property page in ArcCatalog.
SubsetNetworkEvaluatorsUI\SubsetHelperUI.vb Utility class for shared functionality used by both subset evaluators for managing parameter EID arrays.
Download the VB.NET files

Download the files for all languages

See Also:

Programming with the ArcGIS Network Analyst extension
What is the ArcGIS Network Analyst extension?
What is a network dataset?
Geodatabase
About the ArcGIS Network Analyst extension tutorial
NetworkAnalyst
ArcGIS Network Analyst extension Object Model Diagram
An overview of the Network Analyst toolbox




Development licensing Deployment licensing
ArcGIS for Desktop Basic: Network Analyst ArcGIS for Desktop Basic: Network Analyst
ArcGIS for Desktop Standard: Network Analyst ArcGIS for Desktop Standard: Network Analyst
ArcGIS for Desktop Advanced: Network Analyst ArcGIS for Desktop Advanced: Network Analyst